openapi: 3.1.0
info:
  title: API Reference
  version: '1.0'
  description: Aira API Reference
  x-logo:
    url: https://static.useaira.com/images/airalogo.svg
    backgroundColor: '#FFFFFF'
    altText: Aira Logo
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      description: API Key Authentication.
      name: X-API-KEY
      in: header
  schemas: {}
paths:
  /v1/customers/:
    post:
      summary: Create customer
      tags:
        - Customers
      description: >-
        Creates a customer of the `type` of the body, with the payment account
        of `paymentAccount` when the body has one. The customer follows the
        dunning schedule of `dunningScheduleId`, or the default dunning schedule
        when the body leaves it out. A `subsidiary` needs the `parentCustomerId`
        of its organization, and each contract of that organization that
        includes new subsidiaries in its usage scope adds the subsidiary there
        and updates the invoices of its open billing cycles that have started.


        Requires the role `customers:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                externalId:
                  description: >-
                    The external id of the customer: the key that you give it,
                    which no other customer has. Events and license balances
                    name their customer by it.
                  type: string
                  pattern: ^[a-zA-Z0-9_-]+$
                  example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                name:
                  description: The name of the customer.
                  type: string
                  example: Acme Inc.
                parentCustomerId:
                  description: >-
                    The id of the organization that the customer belongs to when
                    it is a subsidiary, or null for an individual or an
                    organization.
                  type:
                    - 'null'
                    - string
                  format: uuid
                dunningScheduleId:
                  description: >-
                    The id of the dunning schedule that the customer follows, or
                    null for none. Leave it out for the default dunning
                    schedule.
                  type:
                    - 'null'
                    - string
                  format: uuid
                customFields:
                  type: object
                  description: >-
                    Custom fields that can be associated with the entity. The
                    fields must be previously created in the system before they
                    can be used.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
                type:
                  description: >-
                    The type of the customer: an `individual`, an
                    `organization`, which groups zero or more subsidiaries, or a
                    `subsidiary`, which belongs to one organization.
                  type: string
                  enum:
                    - individual
                    - organization
                    - subsidiary
                  default: individual
                  example: individual
                paymentAccount:
                  type: object
                  description: >-
                    The payment account to create for the customer, in the same
                    transaction: the record of who pays its invoices. Leave it
                    out for a customer with no payment account.
                  properties:
                    legalEntity:
                      type: object
                      description: >-
                        The company or person who pays the invoices of the
                        payment account: its names, its tax id, its phone, its
                        address and its invoice recipients.
                      properties:
                        tradeName:
                          type: string
                          nullable: true
                          description: >-
                            The trade name (nome fantasia) of the legal entity,
                            or null when it has none.
                          example: Padaria Central
                        businessName:
                          type: string
                          description: >-
                            The registered business name (razão social) of the
                            legal entity.
                          example: Padaria Central Ltda
                        emails:
                          type: array
                          items:
                            type: string
                            format: email
                          default: []
                          description: >-
                            The e-mails of the legal entity. When the legal
                            entity belongs to a payment account, its e-mails are
                            the invoice recipients of that account: they receive
                            the invoices billed to it.
                        taxId:
                          type: string
                          pattern: ^(^\d{14}$|^\d{11}$)$
                          description: >-
                            The tax id of the legal entity, digits only: the 14
                            digits of a CNPJ or the 11 digits of a CPF.
                          example: '01234567000195'
                        taxIdType:
                          type: string
                          enum:
                            - cnpj
                            - cpf
                          description: >-
                            The kind of tax id in `taxId`: `cnpj` for a company
                            or `cpf` for a person.
                        zipCode:
                          type: string
                          pattern: ^[0-9]{8}$
                          nullable: true
                          description: >-
                            The postal code (CEP) of the address of the legal
                            entity, as 8 digits with no mask, or null when it
                            has none.
                          example: '01310100'
                        street:
                          type: string
                          nullable: true
                          description: >-
                            The street of the address of the legal entity, or
                            null when it has none.
                          example: Avenida Paulista
                        number:
                          type: string
                          nullable: true
                          description: >-
                            The street number of the address of the legal
                            entity, or null when it has none.
                          example: '1000'
                        neighborhood:
                          type: string
                          nullable: true
                          description: >-
                            The neighborhood (bairro) of the address of the
                            legal entity, or null when it has none.
                          example: Bela Vista
                        city:
                          type: string
                          nullable: true
                          description: >-
                            The city of the address of the legal entity, or null
                            when it has none.
                          example: São Paulo
                        state:
                          type:
                            - 'null'
                            - string
                          enum:
                            - AC
                            - AL
                            - AP
                            - AM
                            - BA
                            - CE
                            - DF
                            - ES
                            - GO
                            - MA
                            - MT
                            - MS
                            - MG
                            - PA
                            - PB
                            - PR
                            - PE
                            - PI
                            - RJ
                            - RN
                            - RS
                            - RO
                            - RR
                            - SC
                            - SP
                            - SE
                            - TO
                            - null
                          description: >-
                            The state of the address of the legal entity, as its
                            two-letter code, or null when it has none.
                        country:
                          type:
                            - 'null'
                            - string
                          enum:
                            - Brasil
                            - null
                          description: >-
                            The country of the address of the legal entity, or
                            null when it has none.
                        complement:
                          type: string
                          nullable: true
                          description: >-
                            The complement of the address of the legal entity,
                            such as a suite or a floor, or null when it has
                            none.
                          example: Sala 12
                        customFields:
                          type: object
                          description: >-
                            Custom fields that can be associated with the
                            entity. The fields must be previously created in the
                            system before they can be used.
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          default: {}
                          example:
                            customField1: value1
                            customField2:
                              - value2
                              - value3
                        phone:
                          type: string
                          pattern: ^\d{10,11}$
                          nullable: true
                          description: >-
                            Phone of the payment account: the 10 or 11 digits of
                            a Brazilian landline or mobile number with its area
                            code, with no mask and no country code. Aira rejects
                            a number that does not exist in Brazil, such as one
                            with an area code that does not exist. Null when
                            absent.
                          errorMessage:
                            pattern: >-
                              must hold only the 10 or 11 digits of a Brazilian
                              number with its area code, as in 11987654321
                          example: '11987654321'
                      required:
                        - businessName
                        - taxId
                        - taxIdType
                        - customFields
                      additionalProperties: false
                  required:
                    - legalEntity
                  additionalProperties: false
              required:
                - externalId
                - name
              additionalProperties: false
        required: true
        description: The customer to create, with at most one payment account.
      parameters:
        - schema:
            type: boolean
            default: false
          in: header
          name: override-tax-id-uniqueness
          required: false
          description: When true, accepts a tax ID that another payment account holds.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_customer_hierarchy
          when: >-
            `type` is `subsidiary` and `parentCustomerId` is missing or is not
            the id of an organization, or `parentCustomerId` comes with a `type`
            other than `subsidiary`
        - status: 400
          code: external_id_belongs_to_another_customer
          when: another customer has the `externalId`
        - status: 400
          code: invalid_custom_fields
          when: >-
            `customFields` leaves out a required custom field of customers, has
            a key that is not a custom field of customers, or has a value that
            its custom field does not accept
        - status: 400
          code: dunning_schedule_not_assignable
          when: the dunning schedule of `dunningScheduleId` is archived
        - status: 400
          code: invalid_license_proration_allocation
          when: >-
            the organization of the subsidiary has a contract that includes new
            subsidiaries in its usage scope and splits its invoices by the usage
            of each customer, and a billing cycle of that contract that is open
            and has started bills a license-based charge with the proration
            billing model
        - status: 400
          code: invalid_tax_id
          when: >-
            the `taxId` of the payment account is not a valid CNPJ or CPF for
            its `taxIdType`
        - status: 400
          code: invalid_phone
          when: >-
            the `phone` of the payment account is not the 10 or 11 digits of a
            Brazilian number with its area code
        - status: 400
          code: tax_id_belongs_to_another_payment_account
          when: >-
            a payment account of another customer holds the `taxId`, with
            neither that payment account nor that customer archived, and the
            `override-tax-id-uniqueness` header is not true
        - status: 400
          code: payment_account_without_address
          when: >-
            the payment account has some but not all of `zipCode`, `number`,
            `street`, `neighborhood`, `city`, `state` and `country`, or has none
            of them while the integration with Celcash is on
        - status: 404
          code: dunning_schedule_not_found
          when: no dunning schedule has the `dunningScheduleId`
      x-required-roles: &ref_0
        - customers:write
      responses:
        '201':
          description: >-
            A customer: the company or person that you bill. Contracts, usage
            and invoices belong to a customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the customer in our system.
                    type: string
                    format: uuid
                  externalId:
                    description: >-
                      The external id of the customer: the key that you give it,
                      which no other customer has. Events and license balances
                      name their customer by it.
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                  name:
                    description: The name of the customer.
                    type: string
                    example: Acme Inc.
                  invoicePrefix:
                    description: >-
                      The prefix of the numbers of the customer's invoices,
                      which Aira makes from the name of the customer when it
                      creates the customer, and which never changes.
                    type: string
                    example: ACMEI
                  type:
                    description: >-
                      The type of the customer: an `individual`, an
                      `organization`, which groups zero or more subsidiaries, or
                      a `subsidiary`, which belongs to one organization.
                    type: string
                    enum:
                      - individual
                      - organization
                      - subsidiary
                    example: individual
                  parentCustomerId:
                    description: >-
                      The id of the organization that the customer belongs to
                      when it is a subsidiary, or null for an individual or an
                      organization.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  dunningScheduleId:
                    description: >-
                      The id of the dunning schedule that the customer follows,
                      or null when the customer follows none and gets no dunning
                      e-mails.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  archivedAt:
                    description: >-
                      The instant when the customer was archived, or null when
                      it is not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                required:
                  - id
                  - externalId
                  - name
                  - type
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `invalid_customer_hierarchy`: `type` is `subsidiary` and
            `parentCustomerId` is missing or is not the id of an organization,
            or `parentCustomerId` comes with a `type` other than `subsidiary`.

            - `external_id_belongs_to_another_customer`: another customer has
            the `externalId`.

            - `invalid_custom_fields`: `customFields` leaves out a required
            custom field of customers, has a key that is not a custom field of
            customers, or has a value that its custom field does not accept.

            - `dunning_schedule_not_assignable`: the dunning schedule of
            `dunningScheduleId` is archived.

            - `invalid_license_proration_allocation`: the organization of the
            subsidiary has a contract that includes new subsidiaries in its
            usage scope and splits its invoices by the usage of each customer,
            and a billing cycle of that contract that is open and has started
            bills a license-based charge with the proration billing model.

            - `invalid_tax_id`: the `taxId` of the payment account is not a
            valid CNPJ or CPF for its `taxIdType`.

            - `invalid_phone`: the `phone` of the payment account is not the 10
            or 11 digits of a Brazilian number with its area code.

            - `tax_id_belongs_to_another_payment_account`: a payment account of
            another customer holds the `taxId`, with neither that payment
            account nor that customer archived, and the
            `override-tax-id-uniqueness` header is not true.

            - `payment_account_without_address`: the payment account has some
            but not all of `zipCode`, `number`, `street`, `neighborhood`,
            `city`, `state` and `country`, or has none of them while the
            integration with Celcash is on.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_customer_hierarchy
                      - external_id_belongs_to_another_customer
                      - invalid_custom_fields
                      - dunning_schedule_not_assignable
                      - invalid_license_proration_allocation
                      - invalid_tax_id
                      - invalid_phone
                      - tax_id_belongs_to_another_payment_account
                      - payment_account_without_address
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''externalId'' is required'
                    code: json_schema_validation_error
                invalid_customer_hierarchy:
                  value:
                    message: contract usage scope must include at least one customer
                    code: invalid_customer_hierarchy
                external_id_belongs_to_another_customer:
                  value:
                    message: externalId belongs to another customer
                    code: external_id_belongs_to_another_customer
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
                dunning_schedule_not_assignable:
                  value:
                    message: cannot assign an archived dunning schedule
                    code: dunning_schedule_not_assignable
                invalid_license_proration_allocation:
                  value:
                    message: >-
                      prorated license charges are not supported on contracts
                      that split invoices by subsidiary usage
                    code: invalid_license_proration_allocation
                invalid_tax_id:
                  value:
                    message: Invalid tax id
                    code: invalid_tax_id
                invalid_phone:
                  value:
                    message: >-
                      Invalid phone: send the 10 or 11 digits of a Brazilian
                      number with its area code, as in 11987654321
                    code: invalid_phone
                tax_id_belongs_to_another_payment_account:
                  value:
                    message: >-
                      Tax id belongs to a payment account from a different
                      customer
                    code: tax_id_belongs_to_another_payment_account
                payment_account_without_address:
                  value:
                    message: payment account without address
                    code: payment_account_without_address
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role customers:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `dunning_schedule_not_found`: no dunning schedule has the
            `dunningScheduleId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - dunning_schedule_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                dunning_schedule_not_found:
                  value:
                    message: dunning schedule not found
                    code: dunning_schedule_not_found
    get:
      summary: List customers
      tags:
        - Customers
      description: >-
        Lists the individuals and organizations, or only the types of `types[]`,
        newest first by creation time, and the archived ones only when
        `includeArchived` is true. `GET /v1/customers/{id}/subsidiaries` lists
        the subsidiaries of an organization.


        Requires the role `customers:read`.
      parameters:
        - schema:
            type: string
          example: Padaria
          in: query
          name: search
          required: false
          description: >-
            Text that the name of the customer contains, ignoring case and
            accents, or the whole external id of the customer, ignoring case, or
            the whole tax id of a payment account of the customer that is not
            archived, with or without its dots, slashes and dashes.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeArchived
          required: false
          description: Whether archived customers should be returned.
        - schema:
            type: array
            maxItems: 2
            items:
              type: string
              enum:
                - individual
                - organization
          in: query
          name: types[]
          required: false
          description: >-
            The types of the customers to return. Leave it out for individuals
            and organizations.
        - schema:
            type: array
            maxItems: 100
            items:
              type: string
              format: uuid
          in: query
          name: paymentAccountIds[]
          required: false
          description: >-
            The ids of payment accounts, to return only the customers that own
            one of them, or whose subsidiaries own one. An archived payment
            account does not count.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - &ref_1
          status: 429
          code: too_many_reads_per_second
          when: you already made 50 reads in this second across all your API keys
        - &ref_2
          status: 429
          code: too_many_reads_in_flight
          when: you already have 20 reads in flight across all your API keys
      x-required-roles: &ref_3
        - customers:read
      responses:
        '200':
          description: The customers that match the filters, newest first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A customer: the company or person that you bill.
                        Contracts, usage and invoices belong to a customer.
                      properties:
                        id:
                          description: The unique identifier of the customer in our system.
                          type: string
                          format: uuid
                        externalId:
                          description: >-
                            The external id of the customer: the key that you
                            give it, which no other customer has. Events and
                            license balances name their customer by it.
                          type: string
                          pattern: ^[a-zA-Z0-9_-]+$
                          example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                        name:
                          description: The name of the customer.
                          type: string
                          example: Acme Inc.
                        invoicePrefix:
                          description: >-
                            The prefix of the numbers of the customer's
                            invoices, which Aira makes from the name of the
                            customer when it creates the customer, and which
                            never changes.
                          type: string
                          example: ACMEI
                        type:
                          description: >-
                            The type of the customer: an `individual`, an
                            `organization`, which groups zero or more
                            subsidiaries, or a `subsidiary`, which belongs to
                            one organization.
                          type: string
                          enum:
                            - individual
                            - organization
                            - subsidiary
                          example: individual
                        parentCustomerId:
                          description: >-
                            The id of the organization that the customer belongs
                            to when it is a subsidiary, or null for an
                            individual or an organization.
                          type:
                            - 'null'
                            - string
                          format: uuid
                        dunningScheduleId:
                          description: >-
                            The id of the dunning schedule that the customer
                            follows, or null when the customer follows none and
                            gets no dunning e-mails.
                          type:
                            - 'null'
                            - string
                          format: uuid
                        archivedAt:
                          description: >-
                            The instant when the customer was archived, or null
                            when it is not archived.
                          type:
                            - 'null'
                            - string
                          format: date-time
                        customFields:
                          type: object
                          description: >-
                            Custom fields that can be associated with the
                            entity. The fields must be previously created in the
                            system before they can be used.
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          default: {}
                          example:
                            customField1: value1
                            customField2:
                              - value2
                              - value3
                      required:
                        - id
                        - externalId
                        - name
                        - type
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''search'' must be string'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role customers:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/customers/{id}:
    delete:
      summary: Delete customer
      tags:
        - Customers
      description: >-
        Deletes a customer, and each subsidiary of an organization with it, with
        their contracts, billing cycles, invoices, payment accounts and credit
        pools, so that no route finds them anymore.


        Requires the role `customers:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the customer in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: cannot_delete_subsidiary_customer
          when: the customer is a subsidiary
        - status: 400
          code: customer_has_non_deletable_invoices
          when: >-
            the customer, or a subsidiary of it, has an invoice that is not
            open, in review or canceled
        - status: 404
          code: customer_not_found
          when: no customer has the `id`
      x-required-roles: *ref_0
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `cannot_delete_subsidiary_customer`: the customer is a subsidiary.

            - `customer_has_non_deletable_invoices`: the customer, or a
            subsidiary of it, has an invoice that is not open, in review or
            canceled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - cannot_delete_subsidiary_customer
                      - customer_has_non_deletable_invoices
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                cannot_delete_subsidiary_customer:
                  value:
                    message: subsidiary customers cannot be deleted
                    code: cannot_delete_subsidiary_customer
                customer_has_non_deletable_invoices:
                  value:
                    message: >-
                      customer cannot be deleted when it has invoices in issued
                      or post-issued statuses
                    code: customer_has_non_deletable_invoices
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role customers:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `customer_not_found`: no customer has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - customer_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
    put:
      summary: Update customer
      tags:
        - Customers
      description: >-
        Replaces the name and the custom fields of a customer, changes its
        external id when the body has one, and changes the dunning schedule that
        it follows when the body has `dunningScheduleId`.


        Requires the role `customers:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                externalId:
                  description: >-
                    The external id of the customer: the key that you give it,
                    which no other customer has. Events and license balances
                    name their customer by it.
                  type: string
                  pattern: ^[a-zA-Z0-9_-]+$
                  example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                name:
                  description: The name of the customer.
                  type: string
                  example: Acme Inc.
                dunningScheduleId:
                  description: >-
                    The id of the dunning schedule that the customer follows
                    from now on, or null for none. Leave it out to keep the
                    dunning schedule that the customer follows.
                  type:
                    - 'null'
                    - string
                  format: uuid
                customFields:
                  type: object
                  description: >-
                    Custom fields that can be associated with the entity. The
                    fields must be previously created in the system before they
                    can be used.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
              required:
                - name
              additionalProperties: false
        required: true
        description: >-
          The new name and custom fields of the customer, its new external id
          when the body has one, and its new dunning schedule when the body has
          `dunningScheduleId`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the customer in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_custom_fields
          when: >-
            `customFields` leaves out a required custom field of customers, has
            a key that is not a custom field of customers, or has a value that
            its custom field does not accept
        - status: 400
          code: dunning_schedule_not_assignable
          when: the dunning schedule of `dunningScheduleId` is archived
        - status: 404
          code: customer_not_found
          when: no customer has the `id`
        - status: 404
          code: dunning_schedule_not_found
          when: no dunning schedule has the `dunningScheduleId`
        - status: 409
          code: external_id_belongs_to_another_customer
          when: another customer has the `externalId`
      x-required-roles: *ref_0
      responses:
        '200':
          description: >-
            A customer: the company or person that you bill. Contracts, usage
            and invoices belong to a customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the customer in our system.
                    type: string
                    format: uuid
                  externalId:
                    description: >-
                      The external id of the customer: the key that you give it,
                      which no other customer has. Events and license balances
                      name their customer by it.
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                  name:
                    description: The name of the customer.
                    type: string
                    example: Acme Inc.
                  invoicePrefix:
                    description: >-
                      The prefix of the numbers of the customer's invoices,
                      which Aira makes from the name of the customer when it
                      creates the customer, and which never changes.
                    type: string
                    example: ACMEI
                  type:
                    description: >-
                      The type of the customer: an `individual`, an
                      `organization`, which groups zero or more subsidiaries, or
                      a `subsidiary`, which belongs to one organization.
                    type: string
                    enum:
                      - individual
                      - organization
                      - subsidiary
                    example: individual
                  parentCustomerId:
                    description: >-
                      The id of the organization that the customer belongs to
                      when it is a subsidiary, or null for an individual or an
                      organization.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  dunningScheduleId:
                    description: >-
                      The id of the dunning schedule that the customer follows,
                      or null when the customer follows none and gets no dunning
                      e-mails.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  archivedAt:
                    description: >-
                      The instant when the customer was archived, or null when
                      it is not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                required:
                  - id
                  - externalId
                  - name
                  - type
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invalid_custom_fields`: `customFields` leaves out a required
            custom field of customers, has a key that is not a custom field of
            customers, or has a value that its custom field does not accept.

            - `dunning_schedule_not_assignable`: the dunning schedule of
            `dunningScheduleId` is archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_custom_fields
                      - dunning_schedule_not_assignable
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
                dunning_schedule_not_assignable:
                  value:
                    message: cannot assign an archived dunning schedule
                    code: dunning_schedule_not_assignable
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role customers:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `customer_not_found`: no customer has the `id`.

            - `dunning_schedule_not_found`: no dunning schedule has the
            `dunningScheduleId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - customer_not_found
                      - dunning_schedule_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
                dunning_schedule_not_found:
                  value:
                    message: dunning schedule not found
                    code: dunning_schedule_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `external_id_belongs_to_another_customer`: another customer has
            the `externalId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - external_id_belongs_to_another_customer
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                external_id_belongs_to_another_customer:
                  value:
                    message: externalId belongs to another customer
                    code: external_id_belongs_to_another_customer
    get:
      summary: Fetch customer
      tags:
        - Customers
      description: |-
        Returns a customer by id, archived or not.

        Requires the role `customers:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the customer in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: customer_not_found
          when: no customer has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_3
      responses:
        '200':
          description: >-
            A customer: the company or person that you bill. Contracts, usage
            and invoices belong to a customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the customer in our system.
                    type: string
                    format: uuid
                  externalId:
                    description: >-
                      The external id of the customer: the key that you give it,
                      which no other customer has. Events and license balances
                      name their customer by it.
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                  name:
                    description: The name of the customer.
                    type: string
                    example: Acme Inc.
                  invoicePrefix:
                    description: >-
                      The prefix of the numbers of the customer's invoices,
                      which Aira makes from the name of the customer when it
                      creates the customer, and which never changes.
                    type: string
                    example: ACMEI
                  type:
                    description: >-
                      The type of the customer: an `individual`, an
                      `organization`, which groups zero or more subsidiaries, or
                      a `subsidiary`, which belongs to one organization.
                    type: string
                    enum:
                      - individual
                      - organization
                      - subsidiary
                    example: individual
                  parentCustomerId:
                    description: >-
                      The id of the organization that the customer belongs to
                      when it is a subsidiary, or null for an individual or an
                      organization.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  dunningScheduleId:
                    description: >-
                      The id of the dunning schedule that the customer follows,
                      or null when the customer follows none and gets no dunning
                      e-mails.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  archivedAt:
                    description: >-
                      The instant when the customer was archived, or null when
                      it is not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                required:
                  - id
                  - externalId
                  - name
                  - type
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role customers:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `customer_not_found`: no customer has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - customer_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/customers/by-external-id/{externalId}:
    delete:
      summary: Delete customer by external ID
      tags:
        - Customers
      description: >-
        Deletes the customer that has the `externalId`, and each subsidiary of
        an organization with it, with their contracts, billing cycles, invoices,
        payment accounts and credit pools, so that no route finds them anymore.


        Requires the role `customers:write`.
      parameters:
        - schema:
            type: string
            pattern: ^[a-zA-Z0-9_-]+$
          example: 705faf65-9c8b-4053-8c0b-2021281ce83f
          in: path
          name: externalId
          required: true
          description: >-
            The external id of the customer: the key that you give it, which no
            other customer has. Events and license balances name their customer
            by it.
      x-public-api: true
      x-errors:
        - status: 400
          code: cannot_delete_subsidiary_customer
          when: the customer is a subsidiary
        - status: 400
          code: customer_has_non_deletable_invoices
          when: >-
            the customer, or a subsidiary of it, has an invoice that is not
            open, in review or canceled
        - status: 404
          code: customer_not_found
          when: no customer has the `externalId`
      x-required-roles: *ref_0
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `cannot_delete_subsidiary_customer`: the customer is a subsidiary.

            - `customer_has_non_deletable_invoices`: the customer, or a
            subsidiary of it, has an invoice that is not open, in review or
            canceled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - cannot_delete_subsidiary_customer
                      - customer_has_non_deletable_invoices
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''externalId'' must be string'
                    code: json_schema_validation_error
                cannot_delete_subsidiary_customer:
                  value:
                    message: subsidiary customers cannot be deleted
                    code: cannot_delete_subsidiary_customer
                customer_has_non_deletable_invoices:
                  value:
                    message: >-
                      customer cannot be deleted when it has invoices in issued
                      or post-issued statuses
                    code: customer_has_non_deletable_invoices
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role customers:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `customer_not_found`: no customer has the `externalId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - customer_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
    put:
      summary: Update customer by external ID
      tags:
        - Customers
      description: >-
        Replaces the name and the custom fields of the customer that has the
        `externalId`, and changes the dunning schedule that it follows when the
        body has `dunningScheduleId`.


        Requires the role `customers:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  description: The name of the customer.
                  type: string
                  example: Acme Inc.
                dunningScheduleId:
                  description: >-
                    The id of the dunning schedule that the customer follows
                    from now on, or null for none. Leave it out to keep the
                    dunning schedule that the customer follows.
                  type:
                    - 'null'
                    - string
                  format: uuid
                customFields:
                  type: object
                  description: >-
                    Custom fields that can be associated with the entity. The
                    fields must be previously created in the system before they
                    can be used.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
              required:
                - name
              additionalProperties: false
        required: true
        description: >-
          The new name and custom fields of the customer, and its new dunning
          schedule when the body has `dunningScheduleId`.
      parameters:
        - schema:
            type: string
            pattern: ^[a-zA-Z0-9_-]+$
          example: 705faf65-9c8b-4053-8c0b-2021281ce83f
          in: path
          name: externalId
          required: true
          description: >-
            The external id of the customer: the key that you give it, which no
            other customer has. Events and license balances name their customer
            by it.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_custom_fields
          when: >-
            `customFields` leaves out a required custom field of customers, has
            a key that is not a custom field of customers, or has a value that
            its custom field does not accept
        - status: 400
          code: dunning_schedule_not_assignable
          when: the dunning schedule of `dunningScheduleId` is archived
        - status: 404
          code: customer_not_found
          when: no customer has the `externalId`
        - status: 404
          code: dunning_schedule_not_found
          when: no dunning schedule has the `dunningScheduleId`
      x-required-roles: *ref_0
      responses:
        '200':
          description: >-
            A customer: the company or person that you bill. Contracts, usage
            and invoices belong to a customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the customer in our system.
                    type: string
                    format: uuid
                  externalId:
                    description: >-
                      The external id of the customer: the key that you give it,
                      which no other customer has. Events and license balances
                      name their customer by it.
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                  name:
                    description: The name of the customer.
                    type: string
                    example: Acme Inc.
                  invoicePrefix:
                    description: >-
                      The prefix of the numbers of the customer's invoices,
                      which Aira makes from the name of the customer when it
                      creates the customer, and which never changes.
                    type: string
                    example: ACMEI
                  type:
                    description: >-
                      The type of the customer: an `individual`, an
                      `organization`, which groups zero or more subsidiaries, or
                      a `subsidiary`, which belongs to one organization.
                    type: string
                    enum:
                      - individual
                      - organization
                      - subsidiary
                    example: individual
                  parentCustomerId:
                    description: >-
                      The id of the organization that the customer belongs to
                      when it is a subsidiary, or null for an individual or an
                      organization.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  dunningScheduleId:
                    description: >-
                      The id of the dunning schedule that the customer follows,
                      or null when the customer follows none and gets no dunning
                      e-mails.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  archivedAt:
                    description: >-
                      The instant when the customer was archived, or null when
                      it is not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                required:
                  - id
                  - externalId
                  - name
                  - type
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invalid_custom_fields`: `customFields` leaves out a required
            custom field of customers, has a key that is not a custom field of
            customers, or has a value that its custom field does not accept.

            - `dunning_schedule_not_assignable`: the dunning schedule of
            `dunningScheduleId` is archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_custom_fields
                      - dunning_schedule_not_assignable
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
                dunning_schedule_not_assignable:
                  value:
                    message: cannot assign an archived dunning schedule
                    code: dunning_schedule_not_assignable
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role customers:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `customer_not_found`: no customer has the `externalId`.

            - `dunning_schedule_not_found`: no dunning schedule has the
            `dunningScheduleId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - customer_not_found
                      - dunning_schedule_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
                dunning_schedule_not_found:
                  value:
                    message: dunning schedule not found
                    code: dunning_schedule_not_found
    get:
      summary: Fetch customer by external ID
      tags:
        - Customers
      description: |-
        Returns the customer that has the `externalId`, archived or not.

        Requires the role `customers:read`.
      parameters:
        - schema:
            type: string
            pattern: ^[a-zA-Z0-9_-]+$
          example: 705faf65-9c8b-4053-8c0b-2021281ce83f
          in: path
          name: externalId
          required: true
          description: >-
            The external id of the customer: the key that you give it, which no
            other customer has. Events and license balances name their customer
            by it.
      x-public-api: true
      x-errors:
        - status: 404
          code: customer_not_found
          when: no customer has the `externalId`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_3
      responses:
        '200':
          description: >-
            A customer: the company or person that you bill. Contracts, usage
            and invoices belong to a customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the customer in our system.
                    type: string
                    format: uuid
                  externalId:
                    description: >-
                      The external id of the customer: the key that you give it,
                      which no other customer has. Events and license balances
                      name their customer by it.
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                  name:
                    description: The name of the customer.
                    type: string
                    example: Acme Inc.
                  invoicePrefix:
                    description: >-
                      The prefix of the numbers of the customer's invoices,
                      which Aira makes from the name of the customer when it
                      creates the customer, and which never changes.
                    type: string
                    example: ACMEI
                  type:
                    description: >-
                      The type of the customer: an `individual`, an
                      `organization`, which groups zero or more subsidiaries, or
                      a `subsidiary`, which belongs to one organization.
                    type: string
                    enum:
                      - individual
                      - organization
                      - subsidiary
                    example: individual
                  parentCustomerId:
                    description: >-
                      The id of the organization that the customer belongs to
                      when it is a subsidiary, or null for an individual or an
                      organization.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  dunningScheduleId:
                    description: >-
                      The id of the dunning schedule that the customer follows,
                      or null when the customer follows none and gets no dunning
                      e-mails.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  archivedAt:
                    description: >-
                      The instant when the customer was archived, or null when
                      it is not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                required:
                  - id
                  - externalId
                  - name
                  - type
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''externalId'' must be string'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role customers:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `customer_not_found`: no customer has the `externalId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - customer_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/customers/{id}/archive:
    post:
      summary: Archive customer
      tags:
        - Customers
      description: >-
        Archives a customer, and each subsidiary of an organization with it, so
        that the lists of customers and of subsidiaries return them only when
        `includeArchived` is true.


        Requires the role `customers:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the customer in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: customer_is_already_archived
          when: the customer is already archived
        - status: 400
          code: customer_being_used_by_contracts
          when: >-
            the customer is a subsidiary in the usage scope of an active or
            draft contract, or a payment account of it receives the invoices of
            one
        - status: 400
          code: customer_has_non_canceled_contracts
          when: the customer owns an active or draft contract
        - status: 404
          code: customer_not_found
          when: no customer has the `id`
      x-required-roles: *ref_0
      responses:
        '200':
          description: >-
            A customer: the company or person that you bill. Contracts, usage
            and invoices belong to a customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the customer in our system.
                    type: string
                    format: uuid
                  externalId:
                    description: >-
                      The external id of the customer: the key that you give it,
                      which no other customer has. Events and license balances
                      name their customer by it.
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                  name:
                    description: The name of the customer.
                    type: string
                    example: Acme Inc.
                  invoicePrefix:
                    description: >-
                      The prefix of the numbers of the customer's invoices,
                      which Aira makes from the name of the customer when it
                      creates the customer, and which never changes.
                    type: string
                    example: ACMEI
                  type:
                    description: >-
                      The type of the customer: an `individual`, an
                      `organization`, which groups zero or more subsidiaries, or
                      a `subsidiary`, which belongs to one organization.
                    type: string
                    enum:
                      - individual
                      - organization
                      - subsidiary
                    example: individual
                  parentCustomerId:
                    description: >-
                      The id of the organization that the customer belongs to
                      when it is a subsidiary, or null for an individual or an
                      organization.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  dunningScheduleId:
                    description: >-
                      The id of the dunning schedule that the customer follows,
                      or null when the customer follows none and gets no dunning
                      e-mails.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  archivedAt:
                    description: >-
                      The instant when the customer was archived, or null when
                      it is not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                required:
                  - id
                  - externalId
                  - name
                  - type
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `customer_is_already_archived`: the customer is already archived.

            - `customer_being_used_by_contracts`: the customer is a subsidiary
            in the usage scope of an active or draft contract, or a payment
            account of it receives the invoices of one.

            - `customer_has_non_canceled_contracts`: the customer owns an active
            or draft contract.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - customer_is_already_archived
                      - customer_being_used_by_contracts
                      - customer_has_non_canceled_contracts
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                customer_is_already_archived:
                  value:
                    message: customer is archived
                    code: customer_is_already_archived
                customer_being_used_by_contracts:
                  value:
                    message: >-
                      customer cannot be archived while linked to active or
                      draft contracts
                    code: customer_being_used_by_contracts
                customer_has_non_canceled_contracts:
                  value:
                    message: >-
                      customer can only be archived when all contracts are
                      canceled
                    code: customer_has_non_canceled_contracts
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role customers:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `customer_not_found`: no customer has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - customer_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
  /v1/customers/{id}/unarchive:
    post:
      summary: Unarchive customer
      tags:
        - Customers
      description: >-
        Unarchives a customer, so that the lists of customers return it again
        without `includeArchived`. The subsidiaries of an organization stay
        archived, and its contracts stay as they are.


        Requires the role `customers:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the customer in our system.
        - schema:
            type: boolean
            default: false
          in: header
          name: override-tax-id-uniqueness
          required: false
          description: >-
            When true, unarchives a subsidiary even when another payment account
            holds the tax id of its payment account.
      x-public-api: true
      x-errors:
        - status: 400
          code: customer_is_not_archived
          when: the customer is not archived
        - status: 400
          code: tax_id_belongs_to_payment_account_from_the_same_customer
          when: >-
            the customer is a subsidiary, another payment account of it that is
            not archived holds the tax id of its payment account, and the
            `override-tax-id-uniqueness` header is not true
        - status: 400
          code: tax_id_belongs_to_another_payment_account
          when: >-
            the customer is a subsidiary, a payment account of another customer
            holds the tax id of its payment account, with neither that payment
            account nor that customer archived, and the
            `override-tax-id-uniqueness` header is not true
        - status: 404
          code: customer_not_found
          when: no customer has the `id`
      x-required-roles: *ref_0
      responses:
        '200':
          description: >-
            A customer: the company or person that you bill. Contracts, usage
            and invoices belong to a customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the customer in our system.
                    type: string
                    format: uuid
                  externalId:
                    description: >-
                      The external id of the customer: the key that you give it,
                      which no other customer has. Events and license balances
                      name their customer by it.
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                  name:
                    description: The name of the customer.
                    type: string
                    example: Acme Inc.
                  invoicePrefix:
                    description: >-
                      The prefix of the numbers of the customer's invoices,
                      which Aira makes from the name of the customer when it
                      creates the customer, and which never changes.
                    type: string
                    example: ACMEI
                  type:
                    description: >-
                      The type of the customer: an `individual`, an
                      `organization`, which groups zero or more subsidiaries, or
                      a `subsidiary`, which belongs to one organization.
                    type: string
                    enum:
                      - individual
                      - organization
                      - subsidiary
                    example: individual
                  parentCustomerId:
                    description: >-
                      The id of the organization that the customer belongs to
                      when it is a subsidiary, or null for an individual or an
                      organization.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  dunningScheduleId:
                    description: >-
                      The id of the dunning schedule that the customer follows,
                      or null when the customer follows none and gets no dunning
                      e-mails.
                    type:
                      - 'null'
                      - string
                    format: uuid
                  archivedAt:
                    description: >-
                      The instant when the customer was archived, or null when
                      it is not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                required:
                  - id
                  - externalId
                  - name
                  - type
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `customer_is_not_archived`: the customer is not archived.

            - `tax_id_belongs_to_payment_account_from_the_same_customer`: the
            customer is a subsidiary, another payment account of it that is not
            archived holds the tax id of its payment account, and the
            `override-tax-id-uniqueness` header is not true.

            - `tax_id_belongs_to_another_payment_account`: the customer is a
            subsidiary, a payment account of another customer holds the tax id
            of its payment account, with neither that payment account nor that
            customer archived, and the `override-tax-id-uniqueness` header is
            not true.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - customer_is_not_archived
                      - tax_id_belongs_to_payment_account_from_the_same_customer
                      - tax_id_belongs_to_another_payment_account
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                customer_is_not_archived:
                  value:
                    message: customer is not archived
                    code: customer_is_not_archived
                tax_id_belongs_to_payment_account_from_the_same_customer:
                  value:
                    message: Tax id belongs to a payment account from the same customer
                    code: tax_id_belongs_to_payment_account_from_the_same_customer
                tax_id_belongs_to_another_payment_account:
                  value:
                    message: >-
                      Tax id belongs to a payment account from a different
                      customer
                    code: tax_id_belongs_to_another_payment_account
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role customers:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `customer_not_found`: no customer has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - customer_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
  /v1/customers/{id}/subsidiaries:
    get:
      summary: List customer subsidiaries
      tags:
        - Customers
      description: >-
        Lists the subsidiaries of an organization, oldest first. Archived
        subsidiaries are listed only when `includeArchived` is true.


        Requires the role `customers:read`.
      parameters:
        - schema:
            type: boolean
            default: false
          in: query
          name: includeArchived
          required: false
          description: Whether archived subsidiaries should be returned.
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the customer in our system.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: *ref_3
      responses:
        '200':
          description: The subsidiaries of the organization, oldest first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A customer: the company or person that you bill.
                        Contracts, usage and invoices belong to a customer.
                      properties:
                        id:
                          description: The unique identifier of the customer in our system.
                          type: string
                          format: uuid
                        externalId:
                          description: >-
                            The external id of the customer: the key that you
                            give it, which no other customer has. Events and
                            license balances name their customer by it.
                          type: string
                          pattern: ^[a-zA-Z0-9_-]+$
                          example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                        name:
                          description: The name of the customer.
                          type: string
                          example: Acme Inc.
                        invoicePrefix:
                          description: >-
                            The prefix of the numbers of the customer's
                            invoices, which Aira makes from the name of the
                            customer when it creates the customer, and which
                            never changes.
                          type: string
                          example: ACMEI
                        type:
                          description: >-
                            The type of the customer: an `individual`, an
                            `organization`, which groups zero or more
                            subsidiaries, or a `subsidiary`, which belongs to
                            one organization.
                          type: string
                          enum:
                            - individual
                            - organization
                            - subsidiary
                          example: individual
                        parentCustomerId:
                          description: >-
                            The id of the organization that the customer belongs
                            to when it is a subsidiary, or null for an
                            individual or an organization.
                          type:
                            - 'null'
                            - string
                          format: uuid
                        dunningScheduleId:
                          description: >-
                            The id of the dunning schedule that the customer
                            follows, or null when the customer follows none and
                            gets no dunning e-mails.
                          type:
                            - 'null'
                            - string
                          format: uuid
                        archivedAt:
                          description: >-
                            The instant when the customer was archived, or null
                            when it is not archived.
                          type:
                            - 'null'
                            - string
                          format: date-time
                        customFields:
                          type: object
                          description: >-
                            Custom fields that can be associated with the
                            entity. The fields must be previously created in the
                            system before they can be used.
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          default: {}
                          example:
                            customField1: value1
                            customField2:
                              - value2
                              - value3
                      required:
                        - id
                        - externalId
                        - name
                        - type
                      additionalProperties: false
                    description: A list of items.
                required:
                  - items
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or a query
            parameter breaks the schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role customers:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/resources/:
    post:
      summary: Create resource
      tags:
        - Resources
      description: >-
        Creates a resource, a named measure of usage: the events that its
        filters select and how its aggregation adds them up. The billing model
        defaults to `in_full`, and it is `in_full` whenever the proration of
        resources is off.


        Requires the role `resources:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  description: The name of the resource.
                  type: string
                  example: Emails sent
                type:
                  description: >-
                    Whether the resource measures usage in units (`unit`) or in
                    money (`currency`).
                  type: string
                  enum:
                    - unit
                    - currency
                aggregation:
                  description: >-
                    How the resource turns the events of a charge period into
                    one number from the aggregated property: their sum (`sum`),
                    the last value (`last_during_period`) or the count of
                    distinct values (`unique`).
                  type: string
                  enum:
                    - sum
                    - last_during_period
                    - unique
                aggregateByField:
                  description: >-
                    The aggregated property: the property of the events that the
                    aggregation reads.
                  type: string
                  example: value
                billingModel:
                  description: >-
                    How the resource reads its values in a charge period:
                    `in_full` takes all the events, and `proration` weighs each
                    value by the days that it was in effect.
                  type: string
                  enum:
                    - in_full
                    - proration
                itemId:
                  description: >-
                    The id of the item of the resource, the catalog record that
                    names what a charge on the resource bills.
                  type: string
                  format: uuid
                filters:
                  description: >-
                    The event filters of the resource: the event names and the
                    property values that an event must have to count for the
                    resource. The filters of one property match when any of them
                    matches, and the filters of different properties must all
                    match. At least one filter must have the property
                    `eventName`.
                  type: array
                  items:
                    type: object
                    properties:
                      property:
                        description: >-
                          The property that the filter compares: `eventName`
                          compares the event name, and any other value compares
                          the property of the event with that name. Repeat a
                          property to match any of several values.
                        type: string
                        pattern: ^[a-zA-Z0-9_-]+$
                        example: eventName
                      operator:
                        description: >-
                          How the filter compares the property with the value:
                          `equals`, the default, matches a property that equals
                          the value.
                        type: string
                        enum:
                          - equals
                      value:
                        description: >-
                          The value that the filter compares the property with,
                          as written, with no change of case or accents.
                        type: string
                        example: email_sent
                    required:
                      - property
                      - value
                    additionalProperties: false
                  example:
                    - property: eventName
                      operator: equals
                      value: email_sent
                    - property: type
                      operator: equals
                      value: transactional
                    - property: type
                      operator: equals
                      value: marketing
              required:
                - name
                - type
                - aggregation
                - aggregateByField
                - itemId
                - filters
              additionalProperties: false
        required: true
        description: >-
          The name, the type, the aggregation, the aggregated property, the
          billing model, the item and the filters of the resource to create.
      x-public-api: true
      x-errors:
        - status: 400
          code: missing_resource_event_name_filter
          when: no filter of `filters` has the `property` `eventName`
        - status: 400
          code: invalid_resource_filter_value
          when: >-
            the `value` of a filter on `eventName` holds a character other than
            a letter, a digit, a hyphen or an underscore
        - status: 400
          code: invalid_billing_model_for_resource_aggregation
          when: >-
            the proration of resources is on, `billingModel` is `proration`, and
            `aggregation` is not `last_during_period`
        - status: 400
          code: item_not_found
          when: no item has the `itemId`
      x-required-roles: &ref_4
        - resources:write
      responses:
        '201':
          description: >-
            A resource: a named measure of usage, in units or in money, that
            says which events count and how they add up. A resource has no
            price.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the resource in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the resource.
                    type: string
                    example: Emails sent
                  type:
                    description: >-
                      Whether the resource measures usage in units (`unit`) or
                      in money (`currency`).
                    type: string
                    enum:
                      - unit
                      - currency
                  aggregation:
                    description: >-
                      How the resource turns the events of a charge period into
                      one number from the aggregated property: their sum
                      (`sum`), the last value (`last_during_period`) or the
                      count of distinct values (`unique`).
                    type: string
                    enum:
                      - sum
                      - last_during_period
                      - unique
                  aggregateByField:
                    description: >-
                      The aggregated property: the property of the events that
                      the aggregation reads.
                    type: string
                    example: value
                  billingModel:
                    description: >-
                      How the resource reads its values in a charge period:
                      `in_full` takes all the events, and `proration` weighs
                      each value by the days that it was in effect.
                    type: string
                    enum:
                      - in_full
                      - proration
                  itemId:
                    description: >-
                      The id of the item of the resource, the catalog record
                      that names what a charge on the resource bills.
                    type: string
                    format: uuid
                  filters:
                    description: >-
                      The event filters of the resource: the event names and the
                      property values that an event must have to count for the
                      resource. The filters of one `group` match when any of
                      them matches, and every group must match. At least one
                      filter has the property `eventName`.
                    type: array
                    items:
                      type: object
                      properties:
                        property:
                          description: >-
                            The property that the filter compares: `eventName`
                            compares the event name, and any other value
                            compares the property of the event with that name.
                            Repeat a property to match any of several values.
                          type: string
                          pattern: ^[a-zA-Z0-9_-]+$
                          example: eventName
                        operator:
                          description: >-
                            How the filter compares the property with the value:
                            `equals` matches a property that equals the value.
                          type: string
                          enum:
                            - equals
                        value:
                          description: >-
                            The value that the filter compares the property
                            with, as written, with no change of case or accents.
                          type: string
                          example: email_sent
                        group:
                          description: >-
                            The group of the filter, which is its property. The
                            filters of one group match when any of them matches,
                            and every group must match.
                          type: string
                          example: type
                      required:
                        - property
                        - operator
                        - value
                        - group
                      additionalProperties: false
                    example:
                      - property: eventName
                        operator: equals
                        value: email_sent
                        group: eventName
                      - property: type
                        operator: equals
                        value: transactional
                        group: type
                      - property: type
                        operator: equals
                        value: marketing
                        group: type
                  archivedAt:
                    description: >-
                      When the resource was archived, or null when it is not
                      archived.
                    type: string
                    format: date-time
                    nullable: true
                required:
                  - id
                  - name
                  - type
                  - aggregation
                  - aggregateByField
                  - billingModel
                  - itemId
                  - filters
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `missing_resource_event_name_filter`: no filter of `filters` has
            the `property` `eventName`.

            - `invalid_resource_filter_value`: the `value` of a filter on
            `eventName` holds a character other than a letter, a digit, a hyphen
            or an underscore.

            - `invalid_billing_model_for_resource_aggregation`: the proration of
            resources is on, `billingModel` is `proration`, and `aggregation` is
            not `last_during_period`.

            - `item_not_found`: no item has the `itemId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - missing_resource_event_name_filter
                      - invalid_resource_filter_value
                      - invalid_billing_model_for_resource_aggregation
                      - item_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                missing_resource_event_name_filter:
                  value:
                    message: resource must have at least one eventName filter
                    code: missing_resource_event_name_filter
                invalid_resource_filter_value:
                  value:
                    message: >-
                      invalid resource filter value '{value}' for property
                      '{property}'. Only alphanumeric characters, hyphens and
                      underscores are allowed
                    code: invalid_resource_filter_value
                invalid_billing_model_for_resource_aggregation:
                  value:
                    message: invalid billing model for resource aggregation
                    code: invalid_billing_model_for_resource_aggregation
                item_not_found:
                  value:
                    message: item not found
                    code: item_not_found
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role resources:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
    get:
      summary: List resources
      tags:
        - Resources
      description: >-
        Lists the resources that match the filters, newest first by creation
        time, each with its filters. Archived resources are listed only when
        `includeArchived` is true.


        Requires the role `resources:read`.
      parameters:
        - schema:
            type: string
          example: emails
          in: query
          name: search
          required: false
          description: Free-text search over the resource name, ignoring case and accents.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeArchived
          required: false
          description: Whether archived resources should be returned.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: &ref_5
        - resources:read
      responses:
        '200':
          description: The resources that match the filters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A resource: a named measure of usage, in units or in
                        money, that says which events count and how they add up.
                        A resource has no price.
                      properties:
                        id:
                          description: The unique identifier of the resource in our system.
                          type: string
                          format: uuid
                        name:
                          description: The name of the resource.
                          type: string
                          example: Emails sent
                        type:
                          description: >-
                            Whether the resource measures usage in units
                            (`unit`) or in money (`currency`).
                          type: string
                          enum:
                            - unit
                            - currency
                        aggregation:
                          description: >-
                            How the resource turns the events of a charge period
                            into one number from the aggregated property: their
                            sum (`sum`), the last value (`last_during_period`)
                            or the count of distinct values (`unique`).
                          type: string
                          enum:
                            - sum
                            - last_during_period
                            - unique
                        aggregateByField:
                          description: >-
                            The aggregated property: the property of the events
                            that the aggregation reads.
                          type: string
                          example: value
                        billingModel:
                          description: >-
                            How the resource reads its values in a charge
                            period: `in_full` takes all the events, and
                            `proration` weighs each value by the days that it
                            was in effect.
                          type: string
                          enum:
                            - in_full
                            - proration
                        itemId:
                          description: >-
                            The id of the item of the resource, the catalog
                            record that names what a charge on the resource
                            bills.
                          type: string
                          format: uuid
                        filters:
                          description: >-
                            The event filters of the resource: the event names
                            and the property values that an event must have to
                            count for the resource. The filters of one `group`
                            match when any of them matches, and every group must
                            match. At least one filter has the property
                            `eventName`.
                          type: array
                          items:
                            type: object
                            properties:
                              property:
                                description: >-
                                  The property that the filter compares:
                                  `eventName` compares the event name, and any
                                  other value compares the property of the event
                                  with that name. Repeat a property to match any
                                  of several values.
                                type: string
                                pattern: ^[a-zA-Z0-9_-]+$
                                example: eventName
                              operator:
                                description: >-
                                  How the filter compares the property with the
                                  value: `equals` matches a property that equals
                                  the value.
                                type: string
                                enum:
                                  - equals
                              value:
                                description: >-
                                  The value that the filter compares the
                                  property with, as written, with no change of
                                  case or accents.
                                type: string
                                example: email_sent
                              group:
                                description: >-
                                  The group of the filter, which is its
                                  property. The filters of one group match when
                                  any of them matches, and every group must
                                  match.
                                type: string
                                example: type
                            required:
                              - property
                              - operator
                              - value
                              - group
                            additionalProperties: false
                          example:
                            - property: eventName
                              operator: equals
                              value: email_sent
                              group: eventName
                            - property: type
                              operator: equals
                              value: transactional
                              group: type
                            - property: type
                              operator: equals
                              value: marketing
                              group: type
                        archivedAt:
                          description: >-
                            When the resource was archived, or null when it is
                            not archived.
                          type: string
                          format: date-time
                          nullable: true
                      required:
                        - id
                        - name
                        - type
                        - aggregation
                        - aggregateByField
                        - billingModel
                        - itemId
                        - filters
                        - archivedAt
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''search'' must be string'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role resources:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/resources/{id}:
    put:
      summary: Update resource
      tags:
        - Resources
      description: >-
        Replaces the name, the aggregation, the aggregated property and the
        filters of a resource, while its type, its item and its billing model
        stay as they are.


        Requires the role `resources:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  description: The name of the resource.
                  type: string
                  example: Emails sent
                aggregation:
                  description: >-
                    How the resource turns the events of a charge period into
                    one number from the aggregated property: their sum (`sum`),
                    the last value (`last_during_period`) or the count of
                    distinct values (`unique`).
                  type: string
                  enum:
                    - sum
                    - last_during_period
                    - unique
                aggregateByField:
                  description: >-
                    The aggregated property: the property of the events that the
                    aggregation reads.
                  type: string
                  example: value
                filters:
                  description: >-
                    The event filters of the resource: the event names and the
                    property values that an event must have to count for the
                    resource. The filters of one property match when any of them
                    matches, and the filters of different properties must all
                    match. At least one filter must have the property
                    `eventName`.
                  type: array
                  items:
                    type: object
                    properties:
                      property:
                        description: >-
                          The property that the filter compares: `eventName`
                          compares the event name, and any other value compares
                          the property of the event with that name. Repeat a
                          property to match any of several values.
                        type: string
                        pattern: ^[a-zA-Z0-9_-]+$
                        example: eventName
                      operator:
                        description: >-
                          How the filter compares the property with the value:
                          `equals`, the default, matches a property that equals
                          the value.
                        type: string
                        enum:
                          - equals
                      value:
                        description: >-
                          The value that the filter compares the property with,
                          as written, with no change of case or accents.
                        type: string
                        example: email_sent
                    required:
                      - property
                      - value
                    additionalProperties: false
                  example:
                    - property: eventName
                      operator: equals
                      value: email_sent
                    - property: type
                      operator: equals
                      value: transactional
                    - property: type
                      operator: equals
                      value: marketing
              required:
                - name
                - aggregation
                - aggregateByField
                - filters
              additionalProperties: false
        required: true
        description: >-
          The name, the aggregation, the aggregated property and the filters
          that replace those of the resource.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the resource in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: missing_resource_event_name_filter
          when: no filter of `filters` has the `property` `eventName`
        - status: 400
          code: invalid_resource_filter_value
          when: >-
            the `value` of a filter on `eventName` holds a character other than
            a letter, a digit, a hyphen or an underscore
        - status: 400
          code: invalid_billing_model_for_resource_aggregation
          when: >-
            the billing model of the resource is `proration` and `aggregation`
            is not `last_during_period`
        - status: 404
          code: resource_not_found
          when: no resource has the `id`
      x-required-roles: *ref_4
      responses:
        '200':
          description: >-
            A resource: a named measure of usage, in units or in money, that
            says which events count and how they add up. A resource has no
            price.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the resource in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the resource.
                    type: string
                    example: Emails sent
                  type:
                    description: >-
                      Whether the resource measures usage in units (`unit`) or
                      in money (`currency`).
                    type: string
                    enum:
                      - unit
                      - currency
                  aggregation:
                    description: >-
                      How the resource turns the events of a charge period into
                      one number from the aggregated property: their sum
                      (`sum`), the last value (`last_during_period`) or the
                      count of distinct values (`unique`).
                    type: string
                    enum:
                      - sum
                      - last_during_period
                      - unique
                  aggregateByField:
                    description: >-
                      The aggregated property: the property of the events that
                      the aggregation reads.
                    type: string
                    example: value
                  billingModel:
                    description: >-
                      How the resource reads its values in a charge period:
                      `in_full` takes all the events, and `proration` weighs
                      each value by the days that it was in effect.
                    type: string
                    enum:
                      - in_full
                      - proration
                  itemId:
                    description: >-
                      The id of the item of the resource, the catalog record
                      that names what a charge on the resource bills.
                    type: string
                    format: uuid
                  filters:
                    description: >-
                      The event filters of the resource: the event names and the
                      property values that an event must have to count for the
                      resource. The filters of one `group` match when any of
                      them matches, and every group must match. At least one
                      filter has the property `eventName`.
                    type: array
                    items:
                      type: object
                      properties:
                        property:
                          description: >-
                            The property that the filter compares: `eventName`
                            compares the event name, and any other value
                            compares the property of the event with that name.
                            Repeat a property to match any of several values.
                          type: string
                          pattern: ^[a-zA-Z0-9_-]+$
                          example: eventName
                        operator:
                          description: >-
                            How the filter compares the property with the value:
                            `equals` matches a property that equals the value.
                          type: string
                          enum:
                            - equals
                        value:
                          description: >-
                            The value that the filter compares the property
                            with, as written, with no change of case or accents.
                          type: string
                          example: email_sent
                        group:
                          description: >-
                            The group of the filter, which is its property. The
                            filters of one group match when any of them matches,
                            and every group must match.
                          type: string
                          example: type
                      required:
                        - property
                        - operator
                        - value
                        - group
                      additionalProperties: false
                    example:
                      - property: eventName
                        operator: equals
                        value: email_sent
                        group: eventName
                      - property: type
                        operator: equals
                        value: transactional
                        group: type
                      - property: type
                        operator: equals
                        value: marketing
                        group: type
                  archivedAt:
                    description: >-
                      When the resource was archived, or null when it is not
                      archived.
                    type: string
                    format: date-time
                    nullable: true
                required:
                  - id
                  - name
                  - type
                  - aggregation
                  - aggregateByField
                  - billingModel
                  - itemId
                  - filters
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `missing_resource_event_name_filter`: no filter of `filters` has
            the `property` `eventName`.

            - `invalid_resource_filter_value`: the `value` of a filter on
            `eventName` holds a character other than a letter, a digit, a hyphen
            or an underscore.

            - `invalid_billing_model_for_resource_aggregation`: the billing
            model of the resource is `proration` and `aggregation` is not
            `last_during_period`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - missing_resource_event_name_filter
                      - invalid_resource_filter_value
                      - invalid_billing_model_for_resource_aggregation
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                missing_resource_event_name_filter:
                  value:
                    message: resource must have at least one eventName filter
                    code: missing_resource_event_name_filter
                invalid_resource_filter_value:
                  value:
                    message: >-
                      invalid resource filter value '{value}' for property
                      '{property}'. Only alphanumeric characters, hyphens and
                      underscores are allowed
                    code: invalid_resource_filter_value
                invalid_billing_model_for_resource_aggregation:
                  value:
                    message: invalid billing model for resource aggregation
                    code: invalid_billing_model_for_resource_aggregation
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role resources:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `resource_not_found`: no resource has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - resource_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                resource_not_found:
                  value:
                    message: resource not found
                    code: resource_not_found
    delete:
      summary: Delete resource
      tags:
        - Resources
      description: >-
        Deletes a resource, so that `GET /v1/resources` leaves it out even when
        `includeArchived` is true, and `GET /v1/resources/{id}` no longer finds
        it.


        Requires the role `resources:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the resource in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: resource_not_found
          when: no resource has the `id`
        - status: 409
          code: resource_has_blocking_references
          when: >-
            a plan charge or a line item of an invoice names the resource, and
            `details.references` gives, in `planCharges` and in
            `invoiceLineItems`, the `count` of those records and the
            `sampleNames` of up to three of them
      x-required-roles: *ref_4
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role resources:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `resource_not_found`: no resource has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - resource_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                resource_not_found:
                  value:
                    message: resource not found
                    code: resource_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `resource_has_blocking_references`: a plan charge or a line item
            of an invoice names the resource, and `details.references` gives, in
            `planCharges` and in `invoiceLineItems`, the `count` of those
            records and the `sampleNames` of up to three of them.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - resource_has_blocking_references
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                resource_has_blocking_references:
                  value:
                    message: resource has blocking references and cannot be deleted
                    code: resource_has_blocking_references
    get:
      summary: Fetch resource
      tags:
        - Resources
      description: |-
        Fetches a resource with its filters, archived or not.

        Requires the role `resources:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the resource in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: resource_not_found
          when: no resource has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_5
      responses:
        '200':
          description: >-
            A resource: a named measure of usage, in units or in money, that
            says which events count and how they add up. A resource has no
            price.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the resource in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the resource.
                    type: string
                    example: Emails sent
                  type:
                    description: >-
                      Whether the resource measures usage in units (`unit`) or
                      in money (`currency`).
                    type: string
                    enum:
                      - unit
                      - currency
                  aggregation:
                    description: >-
                      How the resource turns the events of a charge period into
                      one number from the aggregated property: their sum
                      (`sum`), the last value (`last_during_period`) or the
                      count of distinct values (`unique`).
                    type: string
                    enum:
                      - sum
                      - last_during_period
                      - unique
                  aggregateByField:
                    description: >-
                      The aggregated property: the property of the events that
                      the aggregation reads.
                    type: string
                    example: value
                  billingModel:
                    description: >-
                      How the resource reads its values in a charge period:
                      `in_full` takes all the events, and `proration` weighs
                      each value by the days that it was in effect.
                    type: string
                    enum:
                      - in_full
                      - proration
                  itemId:
                    description: >-
                      The id of the item of the resource, the catalog record
                      that names what a charge on the resource bills.
                    type: string
                    format: uuid
                  filters:
                    description: >-
                      The event filters of the resource: the event names and the
                      property values that an event must have to count for the
                      resource. The filters of one `group` match when any of
                      them matches, and every group must match. At least one
                      filter has the property `eventName`.
                    type: array
                    items:
                      type: object
                      properties:
                        property:
                          description: >-
                            The property that the filter compares: `eventName`
                            compares the event name, and any other value
                            compares the property of the event with that name.
                            Repeat a property to match any of several values.
                          type: string
                          pattern: ^[a-zA-Z0-9_-]+$
                          example: eventName
                        operator:
                          description: >-
                            How the filter compares the property with the value:
                            `equals` matches a property that equals the value.
                          type: string
                          enum:
                            - equals
                        value:
                          description: >-
                            The value that the filter compares the property
                            with, as written, with no change of case or accents.
                          type: string
                          example: email_sent
                        group:
                          description: >-
                            The group of the filter, which is its property. The
                            filters of one group match when any of them matches,
                            and every group must match.
                          type: string
                          example: type
                      required:
                        - property
                        - operator
                        - value
                        - group
                      additionalProperties: false
                    example:
                      - property: eventName
                        operator: equals
                        value: email_sent
                        group: eventName
                      - property: type
                        operator: equals
                        value: transactional
                        group: type
                      - property: type
                        operator: equals
                        value: marketing
                        group: type
                  archivedAt:
                    description: >-
                      When the resource was archived, or null when it is not
                      archived.
                    type: string
                    format: date-time
                    nullable: true
                required:
                  - id
                  - name
                  - type
                  - aggregation
                  - aggregateByField
                  - billingModel
                  - itemId
                  - filters
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role resources:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `resource_not_found`: no resource has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - resource_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                resource_not_found:
                  value:
                    message: resource not found
                    code: resource_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/resources/{id}/archive:
    post:
      summary: Archive resource
      tags:
        - Resources
      description: >-
        Archives a resource, so that `GET /v1/resources` leaves it out unless
        `includeArchived` is true.


        Requires the role `resources:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the resource in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: resource_is_already_archived
          when: the resource is already archived
        - status: 404
          code: resource_not_found
          when: no resource has the `id`
        - status: 409
          code: resource_has_active_plan_charge
          when: >-
            a plan charge names the resource, and
            `details.references.planCharges` gives the `count` of those plan
            charges and the `sampleNames` of up to three of them
      x-required-roles: *ref_4
      responses:
        '200':
          description: >-
            A resource: a named measure of usage, in units or in money, that
            says which events count and how they add up. A resource has no
            price.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the resource in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the resource.
                    type: string
                    example: Emails sent
                  type:
                    description: >-
                      Whether the resource measures usage in units (`unit`) or
                      in money (`currency`).
                    type: string
                    enum:
                      - unit
                      - currency
                  aggregation:
                    description: >-
                      How the resource turns the events of a charge period into
                      one number from the aggregated property: their sum
                      (`sum`), the last value (`last_during_period`) or the
                      count of distinct values (`unique`).
                    type: string
                    enum:
                      - sum
                      - last_during_period
                      - unique
                  aggregateByField:
                    description: >-
                      The aggregated property: the property of the events that
                      the aggregation reads.
                    type: string
                    example: value
                  billingModel:
                    description: >-
                      How the resource reads its values in a charge period:
                      `in_full` takes all the events, and `proration` weighs
                      each value by the days that it was in effect.
                    type: string
                    enum:
                      - in_full
                      - proration
                  itemId:
                    description: >-
                      The id of the item of the resource, the catalog record
                      that names what a charge on the resource bills.
                    type: string
                    format: uuid
                  filters:
                    description: >-
                      The event filters of the resource: the event names and the
                      property values that an event must have to count for the
                      resource. The filters of one `group` match when any of
                      them matches, and every group must match. At least one
                      filter has the property `eventName`.
                    type: array
                    items:
                      type: object
                      properties:
                        property:
                          description: >-
                            The property that the filter compares: `eventName`
                            compares the event name, and any other value
                            compares the property of the event with that name.
                            Repeat a property to match any of several values.
                          type: string
                          pattern: ^[a-zA-Z0-9_-]+$
                          example: eventName
                        operator:
                          description: >-
                            How the filter compares the property with the value:
                            `equals` matches a property that equals the value.
                          type: string
                          enum:
                            - equals
                        value:
                          description: >-
                            The value that the filter compares the property
                            with, as written, with no change of case or accents.
                          type: string
                          example: email_sent
                        group:
                          description: >-
                            The group of the filter, which is its property. The
                            filters of one group match when any of them matches,
                            and every group must match.
                          type: string
                          example: type
                      required:
                        - property
                        - operator
                        - value
                        - group
                      additionalProperties: false
                    example:
                      - property: eventName
                        operator: equals
                        value: email_sent
                        group: eventName
                      - property: type
                        operator: equals
                        value: transactional
                        group: type
                      - property: type
                        operator: equals
                        value: marketing
                        group: type
                  archivedAt:
                    description: >-
                      When the resource was archived, or null when it is not
                      archived.
                    type: string
                    format: date-time
                    nullable: true
                required:
                  - id
                  - name
                  - type
                  - aggregation
                  - aggregateByField
                  - billingModel
                  - itemId
                  - filters
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `resource_is_already_archived`: the resource is already archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - resource_is_already_archived
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                resource_is_already_archived:
                  value:
                    message: resource is already archived
                    code: resource_is_already_archived
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role resources:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `resource_not_found`: no resource has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - resource_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                resource_not_found:
                  value:
                    message: resource not found
                    code: resource_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `resource_has_active_plan_charge`: a plan charge names the
            resource, and `details.references.planCharges` gives the `count` of
            those plan charges and the `sampleNames` of up to three of them.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - resource_has_active_plan_charge
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                resource_has_active_plan_charge:
                  value:
                    message: >-
                      resource is in use by an active plan charge and cannot be
                      archived
                    code: resource_has_active_plan_charge
  /v1/resources/{id}/unarchive:
    post:
      summary: Unarchive resource
      tags:
        - Resources
      description: >-
        Unarchives a resource, so that `GET /v1/resources` lists it again
        without `includeArchived`.


        Requires the role `resources:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the resource in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: resource_is_not_archived
          when: the resource is not archived
        - status: 404
          code: resource_not_found
          when: no resource has the `id`
      x-required-roles: *ref_4
      responses:
        '200':
          description: >-
            A resource: a named measure of usage, in units or in money, that
            says which events count and how they add up. A resource has no
            price.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the resource in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the resource.
                    type: string
                    example: Emails sent
                  type:
                    description: >-
                      Whether the resource measures usage in units (`unit`) or
                      in money (`currency`).
                    type: string
                    enum:
                      - unit
                      - currency
                  aggregation:
                    description: >-
                      How the resource turns the events of a charge period into
                      one number from the aggregated property: their sum
                      (`sum`), the last value (`last_during_period`) or the
                      count of distinct values (`unique`).
                    type: string
                    enum:
                      - sum
                      - last_during_period
                      - unique
                  aggregateByField:
                    description: >-
                      The aggregated property: the property of the events that
                      the aggregation reads.
                    type: string
                    example: value
                  billingModel:
                    description: >-
                      How the resource reads its values in a charge period:
                      `in_full` takes all the events, and `proration` weighs
                      each value by the days that it was in effect.
                    type: string
                    enum:
                      - in_full
                      - proration
                  itemId:
                    description: >-
                      The id of the item of the resource, the catalog record
                      that names what a charge on the resource bills.
                    type: string
                    format: uuid
                  filters:
                    description: >-
                      The event filters of the resource: the event names and the
                      property values that an event must have to count for the
                      resource. The filters of one `group` match when any of
                      them matches, and every group must match. At least one
                      filter has the property `eventName`.
                    type: array
                    items:
                      type: object
                      properties:
                        property:
                          description: >-
                            The property that the filter compares: `eventName`
                            compares the event name, and any other value
                            compares the property of the event with that name.
                            Repeat a property to match any of several values.
                          type: string
                          pattern: ^[a-zA-Z0-9_-]+$
                          example: eventName
                        operator:
                          description: >-
                            How the filter compares the property with the value:
                            `equals` matches a property that equals the value.
                          type: string
                          enum:
                            - equals
                        value:
                          description: >-
                            The value that the filter compares the property
                            with, as written, with no change of case or accents.
                          type: string
                          example: email_sent
                        group:
                          description: >-
                            The group of the filter, which is its property. The
                            filters of one group match when any of them matches,
                            and every group must match.
                          type: string
                          example: type
                      required:
                        - property
                        - operator
                        - value
                        - group
                      additionalProperties: false
                    example:
                      - property: eventName
                        operator: equals
                        value: email_sent
                        group: eventName
                      - property: type
                        operator: equals
                        value: transactional
                        group: type
                      - property: type
                        operator: equals
                        value: marketing
                        group: type
                  archivedAt:
                    description: >-
                      When the resource was archived, or null when it is not
                      archived.
                    type: string
                    format: date-time
                    nullable: true
                required:
                  - id
                  - name
                  - type
                  - aggregation
                  - aggregateByField
                  - billingModel
                  - itemId
                  - filters
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `resource_is_not_archived`: the resource is not archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - resource_is_not_archived
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                resource_is_not_archived:
                  value:
                    message: resource is not archived
                    code: resource_is_not_archived
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role resources:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `resource_not_found`: no resource has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - resource_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                resource_not_found:
                  value:
                    message: resource not found
                    code: resource_not_found
  /v1/revenue-items/:
    get:
      summary: List revenue items
      tags:
        - Revenue Traceability
      description: >-
        Lists the revenue that the revenue traceabilities tag in a period of up
        to three months, ordered by the start date of the revenue traceability,
        the most recent first. Each revenue traceability whose dates overlap the
        period gives one item for each month and billing account of the invoices
        of its contract that were issued and are not canceled, in the status
        issued, synced, pending, paid, overdue or failed, and dated both in the
        period and inside the dates of the revenue traceability. The item sums,
        in cents, the line items of the product of the revenue traceability on
        those invoices. A revenue traceability with no such invoice gives one
        item with an amount of zero.


        Requires the role `contracts:admin`.
      parameters:
        - schema:
            type: string
            pattern: ^\d{4}-\d{2}$
          example: 2026-01
          in: query
          name: period.gte
          required: true
          description: The first month of the period, as YYYY-MM.
        - schema:
            type: string
            pattern: ^\d{4}-\d{2}$
          example: 2026-03
          in: query
          name: period.lte
          required: true
          description: >-
            The last month of the period, as YYYY-MM, at most two months after
            period.gte.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 200
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_period_range
          when: the `period.lte` is more than two months after the `period.gte`
        - *ref_1
        - *ref_2
      x-required-roles:
        - contracts:admin
      responses:
        '200':
          description: >-
            The revenue items of the period, ordered by the start date of their
            revenue traceability, the most recent first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        The revenue that one revenue traceability tags in one
                        month, from the invoices of one billing account.
                      properties:
                        period:
                          type: string
                          pattern: ^\d{4}-\d{2}$
                          description: >-
                            The month of the item, as YYYY-MM: the month of its
                            invoices, or, for an item with no invoice, the later
                            of the month in which the revenue traceability
                            starts and the first month of the period.
                          example: 2026-02
                        proposal:
                          type: string
                          description: >-
                            The value of the proposal custom field of the
                            revenue traceability. An empty string when the
                            revenue traceability has none.
                          example: PROP-2026-014
                        amountCents:
                          type: number
                          description: >-
                            The sum, in cents, of the line items of the product
                            on the invoices of the item. Zero for an item with
                            no invoice.
                        customer:
                          type: object
                          description: >-
                            The customer of the contract, with the name and the
                            tax id of the billing account of the invoices of the
                            item.
                          properties:
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the customer in our
                                system.
                            name:
                              type: string
                              description: >-
                                The business name of the billing account of the
                                invoices. An empty string for an item with no
                                invoice.
                              example: Padaria Central Ltda
                            externalId:
                              type: string
                              description: >-
                                The unique identifier of the customer in your
                                system.
                              example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                            taxId:
                              type: string
                              description: >-
                                The tax id of the billing account of the
                                invoices. An empty string for an item with no
                                invoice.
                              example: '01234567000195'
                            taxIdType:
                              type: string
                              enum:
                                - cnpj
                                - cpf
                              description: >-
                                The type of the tax id of the billing account of
                                the invoices, or cpf for an item with no
                                invoice.
                          required:
                            - id
                            - name
                            - externalId
                            - taxId
                            - taxIdType
                          additionalProperties: false
                        product:
                          type: object
                          description: >-
                            The product whose revenue the revenue traceability
                            tags.
                          properties:
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product in our
                                system.
                            name:
                              type: string
                              description: The name of the product.
                              example: Platform subscription
                            customFields:
                              type: object
                              description: >-
                                The values of the custom fields of products on
                                the product, keyed by the key of each custom
                                field.
                              additionalProperties:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                              default: {}
                              example:
                                customField1: value1
                                customField2:
                                  - value2
                                  - value3
                          required:
                            - id
                            - name
                            - customFields
                          additionalProperties: false
                      required:
                        - period
                        - proposal
                        - amountCents
                        - customer
                        - product
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.

            - `invalid_period_range`: the `period.lte` is more than two months
            after the `period.gte`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_period_range
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''period.gte'' must be string'
                    code: json_schema_validation_error
                invalid_period_range:
                  value:
                    message: occurredAt.gte must not be after occurredAt.lte
                    code: invalid_period_range
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:admin can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/revenue-traceability/:
    get:
      summary: List revenue traceabilities
      tags:
        - Revenue Traceability
      description: >-
        Lists the revenue traceabilities of a contract, each with its
        attributions, in an order that stays the same from page to page.


        Requires the role `contracts:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: query
          name: contractId
          required: true
          description: >-
            The unique identifier of the contract whose revenue traceabilities
            to list.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - status: 404
          code: contract_not_found
          when: no contract has the `contractId`
        - *ref_1
        - *ref_2
      x-required-roles: &ref_6
        - contracts:read
      responses:
        '200':
          description: >-
            The revenue traceabilities of the contract, each with its
            attributions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A revenue traceability: a dated record that tags the
                        revenue of a product that a contract bills with custom
                        fields. Its attributions are dated records inside it
                        whose custom fields name who takes part in that revenue.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the revenue traceability in
                            our system.
                        contractId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the contract that bills the
                            product.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product whose revenue
                            the record tags.
                        startDate:
                          type: string
                          format: date
                          description: The first day that the record covers.
                        endDate:
                          type: string
                          format: date
                          nullable: true
                          description: >-
                            The last day that the record covers. Null when the
                            record has no end.
                        customFields:
                          type: object
                          description: >-
                            The values of the custom fields of revenue
                            traceabilities on the revenue traceability, keyed by
                            the key of each custom field.
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          default: {}
                          example:
                            customField1: value1
                            customField2:
                              - value2
                              - value3
                        attributions:
                          type: array
                          items:
                            type: object
                            description: >-
                              An attribution: a dated record inside a revenue
                              traceability whose custom fields name who takes
                              part in its revenue.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the attribution in
                                  our system.
                              startDate:
                                type: string
                                format: date
                                description: The first day that the attribution covers.
                              endDate:
                                type: string
                                format: date
                                nullable: true
                                description: >-
                                  The last day that the attribution covers. Null
                                  when the attribution has no end.
                              customFields:
                                type: object
                                description: >-
                                  The values of the custom fields of
                                  attributions on the attribution, keyed by the
                                  key of each custom field.
                                additionalProperties:
                                  anyOf:
                                    - type: string
                                    - type: array
                                      items:
                                        type: string
                                default: {}
                                example:
                                  customField1: value1
                                  customField2:
                                    - value2
                                    - value3
                            required:
                              - id
                              - startDate
                              - endDate
                              - customFields
                            additionalProperties: false
                          description: The attributions of the record.
                      required:
                        - id
                        - contractId
                        - productId
                        - startDate
                        - endDate
                        - customFields
                        - attributions
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''contractId'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `contract_not_found`: no contract has the `contractId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/revenue-traceability/contract-products:
    get:
      summary: List the products that a contract bills
      tags:
        - Revenue Traceability
      description: >-
        Lists, by name, the products that the plan charges of the plan instances
        of a contract bill, in any version of each plan instance. Only a product
        of this list can get a new revenue traceability on the contract.


        Requires the role `contracts:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: query
          name: contractId
          required: true
          description: The unique identifier of the contract whose products to list.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - status: 404
          code: contract_not_found
          when: no contract has the `contractId`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_6
      responses:
        '200':
          description: The products that the contract bills, ordered by name.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A product, a good or service that you sell, that a plan
                        charge of a version of a plan instance of the contract
                        bills.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: The unique identifier of the product in our system.
                        name:
                          type: string
                          description: The name of the product.
                          example: Platform subscription
                        isActive:
                          type: boolean
                          description: >-
                            Whether the active version of an active plan
                            instance of the contract bills the product. False
                            when only a plan instance that is not active, or an
                            earlier version of a plan instance, bills it.
                      required:
                        - id
                        - name
                        - isActive
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''contractId'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `contract_not_found`: no contract has the `contractId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/revenue-traceability/{contractId}:
    put:
      summary: Replace revenue traceabilities
      tags:
        - Revenue Traceability
      description: >-
        Replaces the revenue traceabilities of a contract with the items sent,
        and returns them. An item with the id of a revenue traceability of the
        contract for the same product keeps that record, with the dates, custom
        fields and attributions sent. Any other item creates a revenue
        traceability with an id of its own, and the request deletes each revenue
        traceability of the contract that no item keeps. The attributions of an
        item follow the same rule inside it. The list of the revenue
        traceabilities of the contract, and the revenue items, then read only
        the revenue traceabilities that the reply returns for the contract.


        Requires the role `contracts:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                items:
                  type: array
                  items:
                    type: object
                    description: >-
                      A revenue traceability: a dated record that tags the
                      revenue of a product that a contract bills with custom
                      fields. Its attributions are dated records inside it whose
                      custom fields name who takes part in that revenue.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the revenue traceability in
                          our system.
                      productId:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the product whose revenue the
                          record tags.
                      startDate:
                        type: string
                        format: date
                        description: The first day that the record covers.
                      endDate:
                        type: string
                        format: date
                        nullable: true
                        description: >-
                          The last day that the record covers. Null when the
                          record has no end.
                      customFields:
                        type: object
                        description: >-
                          The values of the custom fields of revenue
                          traceabilities on the revenue traceability, keyed by
                          the key of each custom field.
                        additionalProperties:
                          anyOf:
                            - type: string
                            - type: array
                              items:
                                type: string
                        default: {}
                        example:
                          customField1: value1
                          customField2:
                            - value2
                            - value3
                      attributions:
                        type: array
                        items:
                          type: object
                          description: >-
                            An attribution: a dated record inside a revenue
                            traceability whose custom fields name who takes part
                            in its revenue.
                          properties:
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the attribution in our
                                system.
                            startDate:
                              type: string
                              format: date
                              description: The first day that the attribution covers.
                            endDate:
                              type: string
                              format: date
                              nullable: true
                              description: >-
                                The last day that the attribution covers. Null
                                when the attribution has no end.
                            customFields:
                              type: object
                              description: >-
                                The values of the custom fields of attributions
                                on the attribution, keyed by the key of each
                                custom field.
                              additionalProperties:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                              default: {}
                              example:
                                customField1: value1
                                customField2:
                                  - value2
                                  - value3
                          required:
                            - id
                            - startDate
                            - endDate
                            - customFields
                          additionalProperties: false
                        description: The attributions of the record.
                    required:
                      - id
                      - productId
                      - startDate
                      - endDate
                      - customFields
                      - attributions
                    additionalProperties: false
                  description: A list of items.
              required:
                - items
              additionalProperties: false
        required: true
        description: >-
          The revenue traceabilities that replace those of the contract, each
          with its attributions.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: contractId
          required: true
          description: >-
            The unique identifier of the contract whose revenue traceabilities
            the items replace.
      x-public-api: true
      x-errors:
        - status: 400
          code: duplicate_revenue_traceability_id
          when: two items have the same `id`
        - status: 400
          code: duplicate_revenue_attribution_id
          when: two attributions of the same item have the same `id`
        - status: 400
          code: invalid_revenue_traceability_window
          when: >-
            the `endDate` of an item or of one of its attributions is before its
            `startDate`
        - status: 400
          code: product_not_on_contract
          when: >-
            an item names a `productId` that no revenue traceability of the
            contract has and that no plan charge of a version of a plan instance
            of the contract bills
        - status: 400
          code: invalid_custom_fields
          when: >-
            the `customFields` of an item or of an attribution leave out a
            required custom field of that kind of record, name a key that no
            custom field of that kind of record has, or give a custom field a
            value that it does not take
        - status: 404
          code: contract_not_found
          when: no contract has the `contractId`
      x-required-roles:
        - contracts:write
      responses:
        '200':
          description: >-
            The revenue traceabilities of the contract after the replacement,
            each with its attributions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A revenue traceability: a dated record that tags the
                        revenue of a product that a contract bills with custom
                        fields. Its attributions are dated records inside it
                        whose custom fields name who takes part in that revenue.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the revenue traceability in
                            our system.
                        contractId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the contract that bills the
                            product.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product whose revenue
                            the record tags.
                        startDate:
                          type: string
                          format: date
                          description: The first day that the record covers.
                        endDate:
                          type: string
                          format: date
                          nullable: true
                          description: >-
                            The last day that the record covers. Null when the
                            record has no end.
                        customFields:
                          type: object
                          description: >-
                            The values of the custom fields of revenue
                            traceabilities on the revenue traceability, keyed by
                            the key of each custom field.
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          default: {}
                          example:
                            customField1: value1
                            customField2:
                              - value2
                              - value3
                        attributions:
                          type: array
                          items:
                            type: object
                            description: >-
                              An attribution: a dated record inside a revenue
                              traceability whose custom fields name who takes
                              part in its revenue.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the attribution in
                                  our system.
                              startDate:
                                type: string
                                format: date
                                description: The first day that the attribution covers.
                              endDate:
                                type: string
                                format: date
                                nullable: true
                                description: >-
                                  The last day that the attribution covers. Null
                                  when the attribution has no end.
                              customFields:
                                type: object
                                description: >-
                                  The values of the custom fields of
                                  attributions on the attribution, keyed by the
                                  key of each custom field.
                                additionalProperties:
                                  anyOf:
                                    - type: string
                                    - type: array
                                      items:
                                        type: string
                                default: {}
                                example:
                                  customField1: value1
                                  customField2:
                                    - value2
                                    - value3
                            required:
                              - id
                              - startDate
                              - endDate
                              - customFields
                            additionalProperties: false
                          description: The attributions of the record.
                      required:
                        - id
                        - contractId
                        - productId
                        - startDate
                        - endDate
                        - customFields
                        - attributions
                      additionalProperties: false
                    description: A list of items.
                required:
                  - items
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `duplicate_revenue_traceability_id`: two items have the same `id`.

            - `duplicate_revenue_attribution_id`: two attributions of the same
            item have the same `id`.

            - `invalid_revenue_traceability_window`: the `endDate` of an item or
            of one of its attributions is before its `startDate`.

            - `product_not_on_contract`: an item names a `productId` that no
            revenue traceability of the contract has and that no plan charge of
            a version of a plan instance of the contract bills.

            - `invalid_custom_fields`: the `customFields` of an item or of an
            attribution leave out a required custom field of that kind of
            record, name a key that no custom field of that kind of record has,
            or give a custom field a value that it does not take.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - duplicate_revenue_traceability_id
                      - duplicate_revenue_attribution_id
                      - invalid_revenue_traceability_window
                      - product_not_on_contract
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''items'' is required'
                    code: json_schema_validation_error
                duplicate_revenue_traceability_id:
                  value:
                    message: >-
                      revenue traceability id appears more than once in the
                      payload: {id}
                    code: duplicate_revenue_traceability_id
                duplicate_revenue_attribution_id:
                  value:
                    message: >-
                      revenue attribution id appears more than once on the same
                      annotation: {id}
                    code: duplicate_revenue_attribution_id
                invalid_revenue_traceability_window:
                  value:
                    message: >-
                      revenue traceability window end date must not be before
                      start date
                    code: invalid_revenue_traceability_window
                product_not_on_contract:
                  value:
                    message: >-
                      revenue traceability can only cover products the contract
                      bills: {value}
                    code: product_not_on_contract
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `contract_not_found`: no contract has the `contractId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
  /v1/invoices/{id}:
    get:
      summary: Fetch invoice
      tags:
        - Invoices
      description: >-
        Fetches an invoice by its id, with its payments, its status history, its
        customer, its contract and its invoice artifacts.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the invoice in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_not_found
          when: no invoice has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: &ref_7
        - invoices:read
      responses:
        '200':
          description: >-
            The invoice, with its payments, its status history, its customer,
            its contract and its invoice artifacts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  invoice:
                    type: object
                    description: >-
                      The invoice, including its line item groups and standalone
                      line items.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the invoice in our system.
                      idempotencyKey:
                        type: string
                        description: >-
                          A unique key that identifies the invoice for
                          idempotent creation. Supplied by the caller for
                          one-off invoices; generated by the billing engine for
                          contract invoices.
                        example: padaria-central-2026-11
                      customerId:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the customer this invoice
                          bills.
                      paymentAccountId:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the customer payment account
                          used as the billing account for this invoice.
                      contractId:
                        type: string
                        nullable: true
                        format: uuid
                        description: >-
                          The unique identifier of the contract that generated
                          this invoice. Null for invoices not generated from a
                          contract (e.g. one-off and imported invoices).
                      contractInvoiceSequence:
                        type: integer
                        minimum: 1
                        nullable: true
                        description: >-
                          The number of the invoice within its contract, in the
                          order that Aira created the contract's invoices: 1 for
                          the first, 2 for the next, and so on. Every invoice
                          gets its own number, including each invoice of a split
                          across payment accounts and the replacement of a
                          reopened invoice, and a number never changes and is
                          never reused. Null for invoices without a contract.
                      issuingAccount:
                        type: object
                        description: >-
                          Snapshot of the legal entity issuing the invoice (the
                          seller), captured at invoice creation.
                        properties:
                          tradeName:
                            type: string
                            nullable: true
                            description: >-
                              Trade name (nome fantasia) of the legal entity.
                              Null when absent.
                            example: Padaria Central
                          businessName:
                            type: string
                            description: >-
                              Registered business name (razão social) of the
                              legal entity.
                            example: Padaria Central Ltda
                          emails:
                            type: array
                            items:
                              type: string
                              format: email
                            description: >-
                              Billing contact email addresses of the legal
                              entity.
                          taxId:
                            type: string
                            description: >-
                              Tax identification number of the legal entity,
                              digits only.
                            example: '01234567000195'
                          taxIdType:
                            type: string
                            enum:
                              - cnpj
                              - cpf
                            description: >-
                              The kind of tax identification number in taxId
                              (e.g. CNPJ for Brazilian companies, CPF for
                              individuals).
                          zipCode:
                            type: string
                            nullable: true
                            description: >-
                              Postal code of the legal entity address. Null when
                              absent.
                            example: '01310100'
                          street:
                            type: string
                            nullable: true
                            description: >-
                              Street of the legal entity address. Null when
                              absent.
                            example: Avenida Paulista
                          number:
                            type: string
                            nullable: true
                            description: >-
                              Street number of the legal entity address. Null
                              when absent.
                            example: '1000'
                          neighborhood:
                            type: string
                            nullable: true
                            description: >-
                              Neighborhood of the legal entity address. Null
                              when absent.
                            example: Bela Vista
                          city:
                            type: string
                            nullable: true
                            description: >-
                              City of the legal entity address. Null when
                              absent.
                            example: São Paulo
                          state:
                            type: string
                            enum:
                              - AC
                              - AL
                              - AP
                              - AM
                              - BA
                              - CE
                              - DF
                              - ES
                              - GO
                              - MA
                              - MT
                              - MS
                              - MG
                              - PA
                              - PB
                              - PR
                              - PE
                              - PI
                              - RJ
                              - RN
                              - RS
                              - RO
                              - RR
                              - SC
                              - SP
                              - SE
                              - TO
                              - null
                            nullable: true
                            description: >-
                              State of the legal entity address, as a two-letter
                              code. Null when absent.
                          country:
                            type: string
                            enum:
                              - Brasil
                              - null
                            nullable: true
                            description: >-
                              Country of the legal entity address. Null when
                              absent.
                          complement:
                            type: string
                            nullable: true
                            description: >-
                              Address complement of the legal entity address.
                              Null when absent.
                            example: Sala 12
                        required:
                          - tradeName
                          - businessName
                          - emails
                          - taxId
                          - taxIdType
                          - zipCode
                          - street
                          - number
                          - neighborhood
                          - city
                          - state
                          - country
                          - complement
                        additionalProperties: false
                      billingAccount:
                        type: object
                        description: >-
                          Snapshot of the billed party (the legal entity behind
                          the customer payment account), captured at invoice
                          creation.
                        properties:
                          tradeName:
                            type: string
                            nullable: true
                            description: >-
                              Trade name (nome fantasia) of the legal entity.
                              Null when absent.
                            example: Padaria Central
                          businessName:
                            type: string
                            description: >-
                              Registered business name (razão social) of the
                              legal entity.
                            example: Padaria Central Ltda
                          emails:
                            type: array
                            items:
                              type: string
                              format: email
                            description: >-
                              Billing contact email addresses of the legal
                              entity.
                          taxId:
                            type: string
                            description: >-
                              Tax identification number of the legal entity,
                              digits only.
                            example: '01234567000195'
                          taxIdType:
                            type: string
                            enum:
                              - cnpj
                              - cpf
                            description: >-
                              The kind of tax identification number in taxId
                              (e.g. CNPJ for Brazilian companies, CPF for
                              individuals).
                          zipCode:
                            type: string
                            nullable: true
                            description: >-
                              Postal code of the legal entity address. Null when
                              absent.
                            example: '01310100'
                          street:
                            type: string
                            nullable: true
                            description: >-
                              Street of the legal entity address. Null when
                              absent.
                            example: Avenida Paulista
                          number:
                            type: string
                            nullable: true
                            description: >-
                              Street number of the legal entity address. Null
                              when absent.
                            example: '1000'
                          neighborhood:
                            type: string
                            nullable: true
                            description: >-
                              Neighborhood of the legal entity address. Null
                              when absent.
                            example: Bela Vista
                          city:
                            type: string
                            nullable: true
                            description: >-
                              City of the legal entity address. Null when
                              absent.
                            example: São Paulo
                          state:
                            type: string
                            enum:
                              - AC
                              - AL
                              - AP
                              - AM
                              - BA
                              - CE
                              - DF
                              - ES
                              - GO
                              - MA
                              - MT
                              - MS
                              - MG
                              - PA
                              - PB
                              - PR
                              - PE
                              - PI
                              - RJ
                              - RN
                              - RS
                              - RO
                              - RR
                              - SC
                              - SP
                              - SE
                              - TO
                              - null
                            nullable: true
                            description: >-
                              State of the legal entity address, as a two-letter
                              code. Null when absent.
                          country:
                            type: string
                            enum:
                              - Brasil
                              - null
                            nullable: true
                            description: >-
                              Country of the legal entity address. Null when
                              absent.
                          complement:
                            type: string
                            nullable: true
                            description: >-
                              Address complement of the legal entity address.
                              Null when absent.
                            example: Sala 12
                        required:
                          - tradeName
                          - businessName
                          - emails
                          - taxId
                          - taxIdType
                          - zipCode
                          - street
                          - number
                          - neighborhood
                          - city
                          - state
                          - country
                          - complement
                        additionalProperties: false
                      invoiceAllocationStrategy:
                        type: string
                        enum:
                          - single
                          - percent_split
                          - subsidiary_usage_split
                        description: >-
                          How the originating contract distributes charges
                          across payment accounts: single bills a single payment
                          account; percent_split divides the total between
                          payment accounts by configured percentages;
                          subsidiary_usage_split divides it according to each
                          subsidiary's usage.
                      lastCalculatedAt:
                        type: string
                        format: date-time
                        nullable: true
                        description: >-
                          When the invoice amounts were last computed by the
                          billing engine. Null when the invoice has never been
                          calculated.
                      invoiceNumber:
                        type: string
                        description: >-
                          Human-readable invoice number, built from the
                          customer's invoice prefix plus a sequential counter.
                        example: ACMEI-0042
                      invoiceDate:
                        type: string
                        format: date
                        description: >-
                          The date of the invoice. On a contract invoice it is
                          the date of its billing act: the first day of the
                          first billing cycle that the contract invoices for an
                          activation invoice, and the last day of the billing
                          cycle for a closing invoice. Its line items state the
                          periods that it bills. On a one-off or imported
                          invoice it is the date given when the invoice was
                          created.
                      memo:
                        type: string
                        nullable: true
                        description: >-
                          Free-form memo attached to the invoice. On contract
                          invoices, it reads "Período <start> a <end>" with the
                          period of the line item that bills most often, such as
                          the month when a monthly fee is billed with an annual
                          fee. When two line items bill equally often, it uses
                          the earlier period. Null when absent.
                        example: Período 01/11/2026 a 30/11/2026
                      subtotalAmount:
                        type: number
                        description: >-
                          Sum of the line item subtotals before adjustments, in
                          cents.
                      adjustmentAmount:
                        type: number
                        description: >-
                          Net amount of all adjustments applied to the invoice
                          line items (discounts and allocation offsets), in
                          cents. Negative when adjustments reduce the amount
                          owed.
                      totalAmount:
                        type: number
                        description: >-
                          Final invoice amount, in cents: subtotalAmount +
                          adjustmentAmount.
                      discountAmount:
                        type: number
                        description: >-
                          The discount portion of adjustmentAmount, in cents
                          (sum of monetary discount adjustments only). Negative
                          when discounts were applied.
                      status:
                        type: string
                        enum:
                          - open
                          - in_review
                          - issued
                          - synced
                          - pending
                          - paid
                          - overdue
                          - canceled
                          - failed
                        description: >-
                          Current status of the invoice lifecycle: open
                          (accumulating charges, editable), in_review (flagged
                          for manual review before issuing), issued (finalized
                          and issued to the customer), synced (registered in the
                          external ERP/payment provider), pending (a payment was
                          initiated and awaits settlement), paid, overdue
                          (unpaid past the due date), canceled, or failed (an
                          issue/sync attempt failed and needs attention).
                      isLocked:
                        type: boolean
                        description: >-
                          Whether the invoice contents are locked against edits.
                          Aira locks an invoice when it issues or cancels it,
                          together with the other invoices of its allocation
                          group, except when it cancels the invoice because its
                          payment account left the allocation of the contract,
                          which locks only that invoice. A locked invoice stays
                          locked, also when its status later moves to failed.
                      failureReason:
                        type: string
                        nullable: true
                        description: >-
                          Reason for the most recent failure on the invoice
                          (e.g. an ERP sync or payment issue). Null when the
                          invoice has no active failure.
                        example: contract_sync_not_found
                      source:
                        type: string
                        enum:
                          - contract
                          - one_off
                          - import
                        description: >-
                          How the invoice originated: contract (generated by a
                          contract billing cycle), one_off (created manually or
                          through the API), or import (ingested from an external
                          system).
                      autoIssue:
                        type: boolean
                        description: >-
                          Whether the invoice is issued automatically when its
                          billing cycle closes, without manual review.
                      amountDue:
                        type: number
                        nullable: true
                        description: >-
                          Outstanding amount due on the invoice, in cents. Null
                          when not tracked.
                      dueDate:
                        type: string
                        format: date
                        nullable: true
                        description: >-
                          Payment due date of the invoice. Null when no due date
                          is set (e.g. before the invoice is issued).
                      lineItemGroups:
                        type: array
                        items:
                          type: object
                          description: >-
                            Schema representing a line item group: a container
                            that gathers the line items generated from one plan
                            instance (or created as a group on one-off
                            invoices). Monetary amounts are integers in cents.
                          properties:
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the line item group in
                                our system.
                            idempotencyKey:
                              type: string
                              description: >-
                                A unique key that identifies the group within
                                the invoice. Supplied by the caller for one-off
                                groups; generated by the billing engine
                                otherwise.
                              example: servicos-novembro
                            customerId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the customer whose
                                consumption this group bills.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product this group
                                belongs to.
                            planId:
                              type: string
                              nullable: true
                              format: uuid
                              description: >-
                                The unique identifier of the plan whose instance
                                generated this group. Null for groups not
                                generated from a plan (e.g. on one-off
                                invoices).
                            planInstanceId:
                              type: string
                              nullable: true
                              format: uuid
                              description: >-
                                The unique identifier of the plan instance that
                                generated this group. Null for groups not
                                generated from a plan instance.
                            name:
                              type: string
                              description: >-
                                Display name of the group as it appears on the
                                invoice, typically the plan or product name.
                              example: Plano Entregas
                            startDate:
                              type: string
                              format: date
                              description: >-
                                Start of the period that the group shows. On
                                contract invoices, it is the period of the
                                group's line item that bills most often, such as
                                the month when a monthly fee is billed with an
                                annual fee. When two line items bill equally
                                often, it is the earlier period.
                            endDate:
                              type: string
                              format: date
                              description: >-
                                End of the period that the group shows, which
                                `startDate` describes.
                            subtotalAmount:
                              type: number
                              description: >-
                                Sum of the group's line item subtotals before
                                adjustments, in cents.
                            adjustmentAmount:
                              type: number
                              description: >-
                                Net amount of the adjustments applied to the
                                group's line items (discounts and allocation
                                offsets), in cents. Negative when adjustments
                                reduce the amount owed.
                            totalAmount:
                              type: number
                              description: >-
                                Final group amount, in cents: subtotalAmount +
                                adjustmentAmount.
                            discountAmount:
                              type: number
                              description: >-
                                The discount portion of adjustmentAmount, in
                                cents (sum of monetary discount adjustments
                                only). Negative when discounts were applied.
                            lineItems:
                              type: array
                              items:
                                type: object
                                description: >-
                                  One amount on an invoice, such as a plan
                                  charge, the contract minimum, a tax gross-up
                                  (the withheld ISS, the municipal service tax,
                                  added on top), a one-off amount or an
                                  additional charge.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the line item in
                                      our system.
                                  idempotencyKey:
                                    type: string
                                    description: >-
                                      A unique key that identifies the line item
                                      within the invoice. Supplied by the caller
                                      for one-off line items; generated by the
                                      billing engine otherwise.
                                    example: entrega-novembro
                                  customerId:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the customer
                                      whose consumption this line item bills. On
                                      split or consolidated invoices it may be a
                                      subsidiary of the invoice's customer.
                                  productId:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the product this
                                      line item belongs to.
                                  itemId:
                                    type: string
                                    nullable: true
                                    format: uuid
                                    description: >-
                                      The unique identifier of the catalog item
                                      this line bills. Null for line items not
                                      backed by a catalog item.
                                  resourceId:
                                    type: string
                                    nullable: true
                                    format: uuid
                                    description: >-
                                      The unique identifier of the metered
                                      resource behind a usage_based line item.
                                      Null for line items not driven by resource
                                      usage.
                                  licenseId:
                                    type: string
                                    nullable: true
                                    format: uuid
                                    description: >-
                                      The unique identifier of the license
                                      behind a license_based line item. Null for
                                      line items not driven by a license count.
                                  lineItemGroupId:
                                    type: string
                                    nullable: true
                                    format: uuid
                                    description: >-
                                      The unique identifier of the line item
                                      group containing this line item. Null for
                                      standalone line items.
                                  name:
                                    type: string
                                    description: >-
                                      Display name of the line item as it
                                      appears on the invoice.
                                    example: Entregas
                                  scope:
                                    type: string
                                    enum:
                                      - credit_purchase
                                      - contract_minimum_commitment
                                      - minimum_commitment
                                      - fixed
                                      - usage_based
                                      - license_based
                                      - custom
                                      - additional_charge
                                      - one_off
                                      - tax_gross_up
                                    description: >-
                                      What the line item charges for:
                                      usage_based (metered resource
                                      consumption), license_based (a license's
                                      reported count billed in full), fixed
                                      (recurring fixed charge of a plan), custom
                                      (custom plan charge, priced by a
                                      calculator that Aira writes for you),
                                      minimum_commitment (plan-level minimum
                                      top-up), contract_minimum_commitment
                                      (contract-level minimum top-up),
                                      credit_purchase (credit pool top-up),
                                      additional_charge (extra charge added
                                      manually), one_off (line item of a one-off
                                      invoice), or tax_gross_up (tax gross-up
                                      charge).
                                  startDate:
                                    type: string
                                    format: date
                                    description: >-
                                      Start of the period covered by this line
                                      item.
                                  endDate:
                                    type: string
                                    format: date
                                    description: >-
                                      End of the period covered by this line
                                      item.
                                  totalUsage:
                                    type: number
                                    nullable: true
                                    description: >-
                                      Total usage billed by the line item, in
                                      the unit given by usageFormat. Null for
                                      line items without a single usage (e.g.
                                      fixed charges without a quantity, and
                                      custom line items whose calculator returns
                                      no total).
                                  usageFormat:
                                    type: string
                                    enum:
                                      - unit
                                      - currency
                                      - null
                                    nullable: true
                                    description: >-
                                      How to read totalUsage, and the usage of
                                      each sub-line item that has no usageFormat
                                      of its own: unit means a count of resource
                                      units or a fixed charge quantity; currency
                                      means a monetary base amount in cents.
                                      Null when the line item has no single
                                      usage, as a custom line item whose
                                      sub-line items bill different kinds of
                                      volume, each with its own usageFormat.
                                  subtotalAmount:
                                    type: number
                                    description: >-
                                      Line item amount before adjustments, in
                                      cents (sum of its sub-line item amounts).
                                  adjustmentAmount:
                                    type: number
                                    description: >-
                                      Net amount of the adjustments applied to
                                      this line item (discounts and allocation
                                      offsets), in cents. Negative when
                                      adjustments reduce the amount owed.
                                  totalAmount:
                                    type: number
                                    description: >-
                                      Final line item amount, in cents:
                                      subtotalAmount + adjustmentAmount.
                                  discountAmount:
                                    type: number
                                    description: >-
                                      The discount portion of adjustmentAmount,
                                      in cents (sum of monetary discount
                                      adjustments only). Negative when discounts
                                      were applied.
                                  metadata:
                                    description: >-
                                      Pricing metadata for the line item, where
                                      the shape is keyed by type. Always
                                      present, but null for line items without
                                      pricing metadata: credit_purchase,
                                      additional_charge, one_off, and
                                      tax_gross_up. It is populated for fixed
                                      (the billing timing), usage_based,
                                      license_based, minimum_commitment,
                                      contract_minimum_commitment, and custom
                                      (the definition and the calculation
                                      memory) line items.
                                    anyOf:
                                      - title: Fixed
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - fixed
                                            description: >-
                                              Discriminator: metadata for a fixed line
                                              item.
                                          billingTiming:
                                            type: string
                                            enum:
                                              - in_advance
                                              - in_arrears
                                            description: >-
                                              Whether the fee was billed in advance of
                                              its service period or after it.
                                        required:
                                          - type
                                          - billingTiming
                                      - title: Usage-based
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - usage_based
                                            description: >-
                                              Discriminator: metadata for a
                                              usage_based line item.
                                          billingModel:
                                            type: string
                                            enum:
                                              - in_full
                                              - proration
                                            description: >-
                                              How the metered resource accrues over
                                              the billing period: in_full bills the
                                              full usage of the period; proration
                                              weighs usage by the fraction of the
                                              period each amount was held.
                                          priceTierDivision:
                                            type: string
                                            enum:
                                              - unique_tier
                                              - progressive
                                            description: >-
                                              For tier-based pricing models only: how
                                              usage was divided across tiers.
                                              unique_tier prices all usage at the
                                              single tier that contains the total;
                                              progressive prices each tier's band
                                              separately. Absent for non-tiered
                                              models.
                                          pricingModel:
                                            type: string
                                            enum:
                                              - fixed
                                              - per_unit
                                              - per_package
                                              - percentage
                                              - tiered_per_unit
                                              - tiered_percentage
                                              - tiered_fixed
                                              - advanced
                                              - custom
                                            description: >-
                                              The pricing model of the plan charge
                                              that produced this line item. Charges
                                              priced before pricing models existed are
                                              reported as advanced.
                                        required:
                                          - type
                                          - billingModel
                                          - pricingModel
                                      - title: License-based
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - license_based
                                            description: >-
                                              Discriminator: metadata for a
                                              license_based line item.
                                          billingModel:
                                            type: string
                                            enum:
                                              - in_full
                                              - proration
                                            description: >-
                                              How the license count accrues over the
                                              billing period. Always in_full: the
                                              latest reported count is billed in full.
                                          priceTierDivision:
                                            type: string
                                            enum:
                                              - unique_tier
                                              - progressive
                                            description: >-
                                              For tier-based pricing models only: how
                                              the license count was divided across
                                              tiers. unique_tier prices the whole
                                              count at the single tier that contains
                                              the total; progressive prices each
                                              tier's band separately. Absent for
                                              non-tiered models.
                                          pricingModel:
                                            type: string
                                            enum:
                                              - fixed
                                              - per_unit
                                              - per_package
                                              - percentage
                                              - tiered_per_unit
                                              - tiered_percentage
                                              - tiered_fixed
                                              - advanced
                                              - custom
                                            description: >-
                                              The pricing model of the plan charge
                                              that produced this line item.
                                        required:
                                          - type
                                          - billingModel
                                          - pricingModel
                                      - title: Contract minimum commitment
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - contract_minimum_commitment
                                            description: >-
                                              Discriminator: metadata for a
                                              contract_minimum_commitment line item.
                                          minimumAmount:
                                            type: number
                                            description: >-
                                              The minimum amount committed for the
                                              whole contract in the billing period, in
                                              cents.
                                          minimumAmountApplied:
                                            type: number
                                            description: >-
                                              The top-up charged by this line item to
                                              reach the committed minimum, in cents:
                                              the difference between minimumAmount and
                                              what the contract's consumption amounted
                                              to.
                                        required:
                                          - type
                                          - minimumAmount
                                          - minimumAmountApplied
                                      - title: Minimum commitment
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - minimum_commitment
                                            description: >-
                                              Discriminator: metadata for a plan-level
                                              minimum_commitment line item.
                                          minimumAmount:
                                            type: number
                                            description: >-
                                              The minimum amount committed for the
                                              plan in the billing period, in cents.
                                          minimumAmountApplied:
                                            type: number
                                            description: >-
                                              The top-up charged by this line item to
                                              reach the committed minimum, in cents:
                                              the difference between minimumAmount and
                                              what the plan's consumption amounted to.
                                        required:
                                          - type
                                          - minimumAmount
                                          - minimumAmountApplied
                                      - title: Custom
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - custom
                                            description: >-
                                              Discriminator: metadata for a custom
                                              line item.
                                          definitionKey:
                                            type: string
                                            description: >-
                                              The key of the custom charge definition
                                              whose calculator priced the charge,
                                              following the
                                              custom:charge:<slug>:<name> convention.
                                            examples:
                                              - custom:charge:padaria-central:entregas
                                          memory:
                                            type: object
                                            additionalProperties: true
                                            description: >-
                                              The full calculation memory that the
                                              calculator returned, such as every tier
                                              it evaluated and the one it billed. Its
                                              shape belongs to the definition.
                                        required:
                                          - type
                                          - definitionKey
                                          - memory
                                      - title: No metadata
                                        type: 'null'
                                  subLineItems:
                                    type: array
                                    items:
                                      type: object
                                      description: >-
                                        Schema representing a sub-line item: one
                                        priced row of a line item's breakdown.
                                        The row type dictates the shape of
                                        metadata.
                                      properties:
                                        id:
                                          type: string
                                          format: uuid
                                          description: >-
                                            The unique identifier of the sub-line
                                            item in our system.
                                        type:
                                          type: string
                                          enum:
                                            - fixed_price
                                            - minimum_amount
                                            - price_tier_flat
                                            - price_tier_unit
                                            - price_tier_package
                                            - price_tier_percentage
                                            - proration
                                            - license_proration
                                            - license_proration_tier
                                            - unit_price
                                            - included_quantity
                                            - package_price
                                            - percentage
                                            - overage
                                            - original_amount
                                            - fixed_unit_price
                                            - custom
                                          description: >-
                                            The kind of priced row: fixed_price and
                                            minimum_amount are companions of
                                            usage-based charges; unit_price,
                                            package_price, percentage, and
                                            included_quantity break down
                                            single-model pricing; price_tier_* rows
                                            break down tiered pricing; overage bills
                                            usage beyond the last tier; proration
                                            bills per prorated interval;
                                            license_proration bills license deltas
                                            (removals are negative); original_amount
                                            surfaces the pre-adjustment amount of an
                                            adjusted line; fixed_unit_price breaks
                                            down a fixed charge billed as a quantity
                                            times a unit amount; custom bills one
                                            component of a custom plan charge.
                                        name:
                                          type: string
                                          description: >-
                                            Display name of the sub-line item as it
                                            appears on the invoice breakdown.
                                          example: '[A partir de 1] Unidades'
                                        description:
                                          type: string
                                          nullable: true
                                          description: >-
                                            Optional descriptive text for the row.
                                            Null when absent.
                                          example: 120 x 2,50
                                        usage:
                                          type: number
                                          nullable: true
                                          description: >-
                                            The usage billed by this row: a count of
                                            resource units (the quantity for a
                                            fixed_unit_price row), or a monetary
                                            base amount in cents for
                                            percentage-priced rows (see the row's
                                            usageFormat, or the line item
                                            usageFormat when the row has none). Null
                                            for rows without usage (e.g.
                                            companions).
                                        usageFormat:
                                          type: string
                                          enum:
                                            - unit
                                            - currency
                                            - null
                                          nullable: true
                                          description: >-
                                            How to read the usage of this row when
                                            the row has a format of its own, as the
                                            custom rows of a custom line item do:
                                            unit means a count, currency means an
                                            amount in cents. Null when the row reads
                                            its usage in the line item usageFormat.
                                        amount:
                                          type: number
                                          description: >-
                                            Amount billed by this row, in cents. The
                                            sum of a line item's sub-line amounts
                                            equals its subtotalAmount.
                                        metadata:
                                          description: >-
                                            Pricing details of the row, keyed by the
                                            row type (and pricingType for overage
                                            rows).
                                          anyOf:
                                            - type: object
                                              description: >-
                                                Fixed-price companion row: the charge's
                                                configured fixed amount, billed
                                                alongside the usage rows. Only rendered
                                                when configured greater than zero.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - fixed_price
                                                  description: >-
                                                    Discriminator: fixed-price companion
                                                    row.
                                                fixedPrice:
                                                  type: number
                                                  description: >-
                                                    The fixed amount configured on the
                                                    charge, in cents.
                                              required:
                                                - type
                                                - fixedPrice
                                            - type: object
                                              description: >-
                                                Minimum-amount companion row: tops the
                                                charge up to its configured minimum when
                                                usage alone stays below it. Only
                                                rendered when the top-up is greater than
                                                zero.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - minimum_amount
                                                  description: >-
                                                    Discriminator: minimum-amount companion
                                                    row.
                                                minimumAmount:
                                                  type: number
                                                  description: >-
                                                    The minimum amount configured on the
                                                    charge, in cents.
                                                minimumAmountApplied:
                                                  type: number
                                                  description: >-
                                                    The top-up billed by this row to reach
                                                    the configured minimum, in cents.
                                              required:
                                                - type
                                                - minimumAmount
                                                - minimumAmountApplied
                                            - type: object
                                              description: >-
                                                Flat-priced tier row: usage falling in
                                                this tier band is billed at a flat
                                                amount, regardless of the exact
                                                quantity.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - price_tier_flat
                                                  description: 'Discriminator: flat-priced tier row.'
                                                from:
                                                  type: number
                                                  description: >-
                                                    Lower bound of the tier band, in
                                                    resource units (inclusive).
                                                to:
                                                  type: number
                                                  nullable: true
                                                  description: >-
                                                    Upper bound of the tier band, in
                                                    resource units (inclusive). Null for an
                                                    unbounded final tier.
                                                fixedPrice:
                                                  type: string
                                                  description: >-
                                                    The flat amount billed for the tier, as
                                                    a decimal currency-unit string.
                                                  examples:
                                                    - '150.00'
                                              required:
                                                - type
                                                - from
                                                - to
                                                - fixedPrice
                                            - type: object
                                              description: >-
                                                Per-unit priced tier row: units
                                                attributed to this tier band are billed
                                                at the tier's unit price.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - price_tier_unit
                                                  description: 'Discriminator: per-unit priced tier row.'
                                                from:
                                                  type: number
                                                  description: >-
                                                    Lower bound of the tier band, in
                                                    resource units (inclusive).
                                                to:
                                                  type: number
                                                  nullable: true
                                                  description: >-
                                                    Upper bound of the tier band, in
                                                    resource units (inclusive). Null for an
                                                    unbounded final tier.
                                                price:
                                                  type: string
                                                  description: >-
                                                    Price per unit within the tier, as a
                                                    decimal currency-unit string.
                                                  examples:
                                                    - '0.25'
                                                fixedPrice:
                                                  type: string
                                                  nullable: true
                                                  description: >-
                                                    Optional flat fee billed on top when the
                                                    tier applies, as a decimal currency-unit
                                                    string. Null when the tier has no flat
                                                    fee.
                                                  examples:
                                                    - '10.00'
                                              required:
                                                - type
                                                - from
                                                - to
                                                - price
                                                - fixedPrice
                                            - type: object
                                              description: >-
                                                Package-priced tier row: units
                                                attributed to this tier band are billed
                                                per started package of packageSize
                                                units.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - price_tier_package
                                                  description: 'Discriminator: package-priced tier row.'
                                                from:
                                                  type: number
                                                  description: >-
                                                    Lower bound of the tier band, in
                                                    resource units (inclusive).
                                                to:
                                                  type: number
                                                  nullable: true
                                                  description: >-
                                                    Upper bound of the tier band, in
                                                    resource units (inclusive). Null for an
                                                    unbounded final tier.
                                                packageSize:
                                                  type: number
                                                  description: Number of resource units per package.
                                                price:
                                                  type: string
                                                  description: >-
                                                    Price per package, as a decimal
                                                    currency-unit string.
                                                  examples:
                                                    - '45.00'
                                              required:
                                                - type
                                                - from
                                                - to
                                                - packageSize
                                                - price
                                            - type: object
                                              description: >-
                                                Percentage-priced tier row: the monetary
                                                base amount attributed to this tier band
                                                is billed at a percentage.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - price_tier_percentage
                                                  description: >-
                                                    Discriminator: percentage-priced tier
                                                    row.
                                                from:
                                                  type: number
                                                  description: >-
                                                    Lower bound of the tier band, in cents
                                                    of the monetary base amount (inclusive).
                                                to:
                                                  type: number
                                                  nullable: true
                                                  description: >-
                                                    Upper bound of the tier band, in cents
                                                    of the monetary base amount (inclusive).
                                                    Null for an unbounded final tier.
                                                percentage:
                                                  type: string
                                                  pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                  description: >-
                                                    Percentage applied to the base amount
                                                    within the tier, as a decimal string
                                                    from 0 to 100 (up to 6 decimal places).
                                                  examples:
                                                    - '2.5'
                                              required:
                                                - type
                                                - from
                                                - to
                                                - percentage
                                            - type: object
                                              description: >-
                                                Proration interval row: for charges on
                                                prorated resources, each interval bills
                                                the usage held during it, priced as if
                                                held for the whole cycle and scaled by
                                                the interval's share of the cycle.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - proration
                                                  description: 'Discriminator: proration interval row.'
                                                intervalSize:
                                                  type: number
                                                  description: >-
                                                    Length of the interval, in days of the
                                                    billing cycle.
                                                amount:
                                                  type: string
                                                  description: >-
                                                    The prorated amount of the interval, as
                                                    a decimal currency-unit string: the
                                                    interval usage priced as if held for the
                                                    whole cycle, scaled by intervalSize over
                                                    the cycle length.
                                                  examples:
                                                    - '29.0322580645'
                                                usage:
                                                  type: number
                                                  description: The usage held during the interval.
                                                intervalStart:
                                                  type: string
                                                  format: date
                                                  description: First day of the interval.
                                                intervalEnd:
                                                  type: string
                                                  format: date
                                                  description: Last day of the interval.
                                              required:
                                                - type
                                                - intervalSize
                                                - amount
                                                - usage
                                                - intervalStart
                                                - intervalEnd
                                            - type: object
                                              description: >-
                                                License proration delta row: for
                                                per_unit license charges billing under
                                                the proration model, the cycle-start row
                                                bills the starting licenses beyond the
                                                included quantity at their full-cycle
                                                price, and each change row bills the
                                                change in those licenses prorated over
                                                the days remaining in the cycle. A
                                                change that stays inside the included
                                                quantity has no row. Tiered charges use
                                                license_proration_tier instead.
                                                quantityDelta and the row's amount are
                                                signed — removals are negative.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - license_proration
                                                  description: >-
                                                    Discriminator: license proration delta
                                                    row.
                                                changeDate:
                                                  type: string
                                                  format: date
                                                  nullable: true
                                                  description: >-
                                                    The day the combined license quantity
                                                    changed. Null on the cycle-start row.
                                                quantityDelta:
                                                  type: number
                                                  description: >-
                                                    Signed change in the licenses beyond the
                                                    included quantity (the starting licenses
                                                    beyond it on the cycle-start row).
                                                    Negative for removals.
                                                quantity:
                                                  type: number
                                                  description: >-
                                                    The combined license quantity after this
                                                    change.
                                                remainingDays:
                                                  type: number
                                                  description: >-
                                                    Days from the change (inclusive) to the
                                                    end of the cycle. Equals cycleDays on
                                                    the cycle-start row.
                                                cycleDays:
                                                  type: number
                                                  description: Length of the billing cycle, in days.
                                                proratedUnitRate:
                                                  type: string
                                                  description: >-
                                                    Absolute effective per-unit rate of the
                                                    row over the remaining window, as a
                                                    decimal currency-unit string: |amount| /
                                                    |quantityDelta|. On a cycle-start row
                                                    that bills no license, the unit price of
                                                    the charge.
                                                  examples:
                                                    - '16.1290322581'
                                                amount:
                                                  type: string
                                                  description: >-
                                                    The signed prorated amount of the row,
                                                    as a decimal currency-unit string.
                                                  examples:
                                                    - '48.3870967742'
                                              required:
                                                - type
                                                - changeDate
                                                - quantityDelta
                                                - quantity
                                                - remainingDays
                                                - cycleDays
                                                - proratedUnitRate
                                                - amount
                                            - type: object
                                              description: >-
                                                Tiered license proration delta row: one
                                                price band of a license charge billing
                                                under the proration model with
                                                tiered_per_unit pricing. The cycle-start
                                                rows bill each band's opening occupancy
                                                at its full-cycle unit price, and each
                                                change row bills that band's occupancy
                                                delta prorated over the days remaining
                                                in the cycle. quantityDelta and the
                                                row's amount are signed — removals are
                                                negative.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - license_proration_tier
                                                  description: >-
                                                    Discriminator: tiered license proration
                                                    delta row.
                                                changeDate:
                                                  type: string
                                                  format: date
                                                  nullable: true
                                                  description: >-
                                                    The day the combined license quantity
                                                    changed. Null on a cycle-start row.
                                                quantityDelta:
                                                  type: number
                                                  description: >-
                                                    Signed change in the units this band
                                                    holds (the band's opening occupancy on a
                                                    cycle-start row). Negative for removals.
                                                quantity:
                                                  type: number
                                                  description: >-
                                                    The combined license quantity across
                                                    every band after this change.
                                                remainingDays:
                                                  type: number
                                                  description: >-
                                                    Days from the change (inclusive) to the
                                                    end of the cycle. Equals cycleDays on a
                                                    cycle-start row.
                                                cycleDays:
                                                  type: number
                                                  description: Length of the billing cycle, in days.
                                                proratedUnitRate:
                                                  type: string
                                                  description: >-
                                                    Absolute effective per-unit rate of the
                                                    row over the remaining window, as a
                                                    decimal currency-unit string: |amount| /
                                                    |quantityDelta|.
                                                  examples:
                                                    - '16.1290322581'
                                                amount:
                                                  type: string
                                                  description: >-
                                                    The signed prorated amount of the row,
                                                    as a decimal currency-unit string.
                                                  examples:
                                                    - '48.3870967742'
                                                planChargeTierId:
                                                  type: string
                                                  description: >-
                                                    The unique identifier of the plan charge
                                                    tier this row moved through.
                                                  examples:
                                                    - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                                from:
                                                  type: number
                                                  description: >-
                                                    Inclusive lower bound of the band, in
                                                    licenses.
                                                to:
                                                  type: number
                                                  nullable: true
                                                  description: >-
                                                    Inclusive upper bound of the band, in
                                                    licenses. Null on the last, open-ended
                                                    band.
                                                unitPrice:
                                                  type: string
                                                  description: >-
                                                    The band's full-cycle price per unit, as
                                                    a decimal currency-unit string.
                                                    proratedUnitRate is this scaled by
                                                    remainingDays over cycleDays.
                                                  examples:
                                                    - '25.00'
                                              required:
                                                - type
                                                - changeDate
                                                - quantityDelta
                                                - quantity
                                                - remainingDays
                                                - cycleDays
                                                - proratedUnitRate
                                                - amount
                                                - planChargeTierId
                                                - from
                                                - to
                                                - unitPrice
                                            - type: object
                                              description: >-
                                                Unit-price row: billable units
                                                multiplied by a single price per unit.
                                                The row's usage holds the billable
                                                units.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - unit_price
                                                  description: 'Discriminator: unit-price row.'
                                                price:
                                                  type: string
                                                  pattern: ^\d+(\.\d{1,6})?$
                                                  description: >-
                                                    Price per unit, as a decimal
                                                    currency-unit string (up to 6 decimal
                                                    places).
                                                  examples:
                                                    - '0.25'
                                              required:
                                                - type
                                                - price
                                            - type: object
                                              description: >-
                                                Included-quantity row: the free
                                                allotment of the charge. The row's usage
                                                holds the units consumed within the
                                                allotment and its amount is always zero.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - included_quantity
                                                  description: 'Discriminator: included-quantity row.'
                                                includedQuantity:
                                                  type: number
                                                  description: >-
                                                    Number of resource units included at no
                                                    charge before billing starts.
                                              required:
                                                - type
                                                - includedQuantity
                                            - type: object
                                              description: >-
                                                Package-price row: billable units
                                                charged per started package of
                                                packageSize units. The row's usage holds
                                                the billable units.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - package_price
                                                  description: 'Discriminator: package-price row.'
                                                packageSize:
                                                  type: number
                                                  description: Number of resource units per package.
                                                price:
                                                  type: string
                                                  pattern: ^\d+(\.\d{1,6})?$
                                                  description: >-
                                                    Price per package, as a decimal
                                                    currency-unit string (up to 6 decimal
                                                    places).
                                                  examples:
                                                    - '45.00'
                                                packagesBilled:
                                                  type: number
                                                  description: >-
                                                    Number of packages billed: the billable
                                                    units divided by packageSize, rounded
                                                    up.
                                              required:
                                                - type
                                                - packageSize
                                                - price
                                                - packagesBilled
                                            - type: object
                                              description: >-
                                                Percentage row: a percentage applied
                                                over a monetary base amount. The row's
                                                usage holds the base amount, in cents.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - percentage
                                                  description: 'Discriminator: percentage row.'
                                                percentage:
                                                  type: string
                                                  pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                  description: >-
                                                    Percentage applied to the base amount,
                                                    as a decimal string from 0 to 100 (up to
                                                    6 decimal places).
                                                  examples:
                                                    - '2.5'
                                              required:
                                                - type
                                                - percentage
                                            - type: object
                                              description: >-
                                                Per-unit overage row: units beyond the
                                                last tier boundary, billed at the
                                                configured excess unit price. The row's
                                                usage holds the units over the boundary.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - overage
                                                  description: 'Discriminator: overage row.'
                                                pricingType:
                                                  type: string
                                                  enum:
                                                    - per_unit
                                                  description: 'Discriminator: overage billed per unit.'
                                                from:
                                                  type: number
                                                  description: >-
                                                    The boundary the overage starts from:
                                                    the upper bound of the last tier, in
                                                    resource units.
                                                price:
                                                  type: string
                                                  pattern: ^\d+(\.\d{1,6})?$
                                                  description: >-
                                                    Price per excess unit, as a decimal
                                                    currency-unit string (up to 6 decimal
                                                    places).
                                                  examples:
                                                    - '0.30'
                                              required:
                                                - type
                                                - pricingType
                                                - from
                                                - price
                                            - type: object
                                              description: >-
                                                Percentage overage row: the monetary
                                                base amount beyond the last tier
                                                boundary, billed at the configured
                                                excess percentage. The row's usage holds
                                                the base amount over the boundary, in
                                                cents.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - overage
                                                  description: 'Discriminator: overage row.'
                                                pricingType:
                                                  type: string
                                                  enum:
                                                    - percentage
                                                  description: >-
                                                    Discriminator: overage billed as a
                                                    percentage.
                                                from:
                                                  type: number
                                                  description: >-
                                                    The boundary the overage starts from:
                                                    the upper bound of the last tier, in
                                                    cents of the monetary base amount.
                                                percentage:
                                                  type: string
                                                  pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                  description: >-
                                                    Percentage applied to the excess base
                                                    amount, as a decimal string from 0 to
                                                    100 (up to 6 decimal places).
                                                  examples:
                                                    - '1.5'
                                              required:
                                                - type
                                                - pricingType
                                                - from
                                                - percentage
                                            - type: object
                                              description: >-
                                                Original-amount row: surfaces the line
                                                item's pre-adjustment amount when the
                                                line has adjustments (e.g. a discount)
                                                but no price-component rows of its own.
                                                The row's amount equals the line item's
                                                subtotalAmount.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - original_amount
                                                  description: 'Discriminator: original-amount row.'
                                              required:
                                                - type
                                            - type: object
                                              description: >-
                                                Fixed unit price row: the quantity of a
                                                fixed charge multiplied by its unit
                                                amount. The row's usage holds the
                                                quantity.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - fixed_unit_price
                                                  description: 'Discriminator: fixed unit price row.'
                                                amount:
                                                  type: integer
                                                  minimum: 0
                                                  description: Amount of one unit, in cents.
                                              required:
                                                - type
                                                - amount
                                            - type: object
                                              description: >-
                                                Custom row: one component of a custom
                                                plan charge, as its calculator billed
                                                it. The row's name, description, usage,
                                                usageFormat and amount hold the rest of
                                                the component.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - custom
                                                  description: 'Discriminator: custom row.'
                                                key:
                                                  type: string
                                                  description: >-
                                                    The key of the component in the sub-line
                                                    schema of the charge's custom charge
                                                    definition, such as documents_overage.
                                                  examples:
                                                    - documents_overage
                                              required:
                                                - type
                                                - key
                                      required:
                                        - id
                                        - type
                                        - name
                                        - description
                                        - usage
                                        - usageFormat
                                        - amount
                                        - metadata
                                      additionalProperties: false
                                    description: >-
                                      Breakdown of the line item amount into
                                      priced rows (included quantities,
                                      unit/package/tier prices, prorations,
                                      companions). Empty for line items without
                                      a breakdown.
                                  adjustments:
                                    type: array
                                    items:
                                      type: object
                                      description: >-
                                        Schema representing an adjustment
                                        applied on top of a line item subtotal,
                                        such as a discount or an allocation
                                        offset.
                                      properties:
                                        id:
                                          type: string
                                          format: uuid
                                          description: >-
                                            The unique identifier of the adjustment
                                            in our system.
                                        name:
                                          type: string
                                          description: >-
                                            Display name of the adjustment as it
                                            appears on the invoice.
                                          example: Desconto de boas-vindas
                                        type:
                                          type: string
                                          enum:
                                            - monetary_discount
                                            - allocation_offset
                                          description: >-
                                            The kind of adjustment:
                                            monetary_discount (a discount applied to
                                            the line item) or allocation_offset (the
                                            share of the amount moved to another
                                            payment account's invoice under a split
                                            allocation strategy).
                                        amount:
                                          type: number
                                          description: >-
                                            Amount of the adjustment, in cents.
                                            Negative when the adjustment reduces the
                                            line item total.
                                      required:
                                        - id
                                        - name
                                        - type
                                        - amount
                                      additionalProperties: false
                                    description: >-
                                      Adjustments applied on top of the line
                                      item subtotal, such as discounts and
                                      allocation offsets.
                                required:
                                  - id
                                  - idempotencyKey
                                  - customerId
                                  - productId
                                  - resourceId
                                  - licenseId
                                  - lineItemGroupId
                                  - name
                                  - scope
                                  - startDate
                                  - endDate
                                  - totalUsage
                                  - usageFormat
                                  - subtotalAmount
                                  - adjustmentAmount
                                  - totalAmount
                                  - discountAmount
                                  - metadata
                                  - subLineItems
                                  - adjustments
                                additionalProperties: false
                              description: The line items contained in this group.
                          required:
                            - id
                            - idempotencyKey
                            - customerId
                            - productId
                            - planId
                            - planInstanceId
                            - name
                            - startDate
                            - endDate
                            - subtotalAmount
                            - adjustmentAmount
                            - totalAmount
                            - discountAmount
                            - lineItems
                          additionalProperties: false
                        description: >-
                          Line item groups on the invoice. Each group gathers
                          the line items generated from one plan instance (or
                          created as a group on one-off invoices).
                      standaloneLineItems:
                        type: array
                        items:
                          type: object
                          description: >-
                            One amount on an invoice, such as a plan charge, the
                            contract minimum, a tax gross-up (the withheld ISS,
                            the municipal service tax, added on top), a one-off
                            amount or an additional charge.
                          properties:
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the line item in our
                                system.
                            idempotencyKey:
                              type: string
                              description: >-
                                A unique key that identifies the line item
                                within the invoice. Supplied by the caller for
                                one-off line items; generated by the billing
                                engine otherwise.
                              example: entrega-novembro
                            customerId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the customer whose
                                consumption this line item bills. On split or
                                consolidated invoices it may be a subsidiary of
                                the invoice's customer.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product this line
                                item belongs to.
                            itemId:
                              type: string
                              nullable: true
                              format: uuid
                              description: >-
                                The unique identifier of the catalog item this
                                line bills. Null for line items not backed by a
                                catalog item.
                            resourceId:
                              type: string
                              nullable: true
                              format: uuid
                              description: >-
                                The unique identifier of the metered resource
                                behind a usage_based line item. Null for line
                                items not driven by resource usage.
                            licenseId:
                              type: string
                              nullable: true
                              format: uuid
                              description: >-
                                The unique identifier of the license behind a
                                license_based line item. Null for line items not
                                driven by a license count.
                            lineItemGroupId:
                              type: string
                              nullable: true
                              format: uuid
                              description: >-
                                The unique identifier of the line item group
                                containing this line item. Null for standalone
                                line items.
                            name:
                              type: string
                              description: >-
                                Display name of the line item as it appears on
                                the invoice.
                              example: Entregas
                            scope:
                              type: string
                              enum:
                                - credit_purchase
                                - contract_minimum_commitment
                                - minimum_commitment
                                - fixed
                                - usage_based
                                - license_based
                                - custom
                                - additional_charge
                                - one_off
                                - tax_gross_up
                              description: >-
                                What the line item charges for: usage_based
                                (metered resource consumption), license_based (a
                                license's reported count billed in full), fixed
                                (recurring fixed charge of a plan), custom
                                (custom plan charge, priced by a calculator that
                                Aira writes for you), minimum_commitment
                                (plan-level minimum top-up),
                                contract_minimum_commitment (contract-level
                                minimum top-up), credit_purchase (credit pool
                                top-up), additional_charge (extra charge added
                                manually), one_off (line item of a one-off
                                invoice), or tax_gross_up (tax gross-up charge).
                            startDate:
                              type: string
                              format: date
                              description: Start of the period covered by this line item.
                            endDate:
                              type: string
                              format: date
                              description: End of the period covered by this line item.
                            totalUsage:
                              type: number
                              nullable: true
                              description: >-
                                Total usage billed by the line item, in the unit
                                given by usageFormat. Null for line items
                                without a single usage (e.g. fixed charges
                                without a quantity, and custom line items whose
                                calculator returns no total).
                            usageFormat:
                              type: string
                              enum:
                                - unit
                                - currency
                                - null
                              nullable: true
                              description: >-
                                How to read totalUsage, and the usage of each
                                sub-line item that has no usageFormat of its
                                own: unit means a count of resource units or a
                                fixed charge quantity; currency means a monetary
                                base amount in cents. Null when the line item
                                has no single usage, as a custom line item whose
                                sub-line items bill different kinds of volume,
                                each with its own usageFormat.
                            subtotalAmount:
                              type: number
                              description: >-
                                Line item amount before adjustments, in cents
                                (sum of its sub-line item amounts).
                            adjustmentAmount:
                              type: number
                              description: >-
                                Net amount of the adjustments applied to this
                                line item (discounts and allocation offsets), in
                                cents. Negative when adjustments reduce the
                                amount owed.
                            totalAmount:
                              type: number
                              description: >-
                                Final line item amount, in cents: subtotalAmount
                                + adjustmentAmount.
                            discountAmount:
                              type: number
                              description: >-
                                The discount portion of adjustmentAmount, in
                                cents (sum of monetary discount adjustments
                                only). Negative when discounts were applied.
                            metadata:
                              description: >-
                                Pricing metadata for the line item, where the
                                shape is keyed by type. Always present, but null
                                for line items without pricing metadata:
                                credit_purchase, additional_charge, one_off, and
                                tax_gross_up. It is populated for fixed (the
                                billing timing), usage_based, license_based,
                                minimum_commitment, contract_minimum_commitment,
                                and custom (the definition and the calculation
                                memory) line items.
                              anyOf:
                                - title: Fixed
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - fixed
                                      description: >-
                                        Discriminator: metadata for a fixed line
                                        item.
                                    billingTiming:
                                      type: string
                                      enum:
                                        - in_advance
                                        - in_arrears
                                      description: >-
                                        Whether the fee was billed in advance of
                                        its service period or after it.
                                  required:
                                    - type
                                    - billingTiming
                                - title: Usage-based
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - usage_based
                                      description: >-
                                        Discriminator: metadata for a
                                        usage_based line item.
                                    billingModel:
                                      type: string
                                      enum:
                                        - in_full
                                        - proration
                                      description: >-
                                        How the metered resource accrues over
                                        the billing period: in_full bills the
                                        full usage of the period; proration
                                        weighs usage by the fraction of the
                                        period each amount was held.
                                    priceTierDivision:
                                      type: string
                                      enum:
                                        - unique_tier
                                        - progressive
                                      description: >-
                                        For tier-based pricing models only: how
                                        usage was divided across tiers.
                                        unique_tier prices all usage at the
                                        single tier that contains the total;
                                        progressive prices each tier's band
                                        separately. Absent for non-tiered
                                        models.
                                    pricingModel:
                                      type: string
                                      enum:
                                        - fixed
                                        - per_unit
                                        - per_package
                                        - percentage
                                        - tiered_per_unit
                                        - tiered_percentage
                                        - tiered_fixed
                                        - advanced
                                        - custom
                                      description: >-
                                        The pricing model of the plan charge
                                        that produced this line item. Charges
                                        priced before pricing models existed are
                                        reported as advanced.
                                  required:
                                    - type
                                    - billingModel
                                    - pricingModel
                                - title: License-based
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - license_based
                                      description: >-
                                        Discriminator: metadata for a
                                        license_based line item.
                                    billingModel:
                                      type: string
                                      enum:
                                        - in_full
                                        - proration
                                      description: >-
                                        How the license count accrues over the
                                        billing period. Always in_full: the
                                        latest reported count is billed in full.
                                    priceTierDivision:
                                      type: string
                                      enum:
                                        - unique_tier
                                        - progressive
                                      description: >-
                                        For tier-based pricing models only: how
                                        the license count was divided across
                                        tiers. unique_tier prices the whole
                                        count at the single tier that contains
                                        the total; progressive prices each
                                        tier's band separately. Absent for
                                        non-tiered models.
                                    pricingModel:
                                      type: string
                                      enum:
                                        - fixed
                                        - per_unit
                                        - per_package
                                        - percentage
                                        - tiered_per_unit
                                        - tiered_percentage
                                        - tiered_fixed
                                        - advanced
                                        - custom
                                      description: >-
                                        The pricing model of the plan charge
                                        that produced this line item.
                                  required:
                                    - type
                                    - billingModel
                                    - pricingModel
                                - title: Contract minimum commitment
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - contract_minimum_commitment
                                      description: >-
                                        Discriminator: metadata for a
                                        contract_minimum_commitment line item.
                                    minimumAmount:
                                      type: number
                                      description: >-
                                        The minimum amount committed for the
                                        whole contract in the billing period, in
                                        cents.
                                    minimumAmountApplied:
                                      type: number
                                      description: >-
                                        The top-up charged by this line item to
                                        reach the committed minimum, in cents:
                                        the difference between minimumAmount and
                                        what the contract's consumption amounted
                                        to.
                                  required:
                                    - type
                                    - minimumAmount
                                    - minimumAmountApplied
                                - title: Minimum commitment
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - minimum_commitment
                                      description: >-
                                        Discriminator: metadata for a plan-level
                                        minimum_commitment line item.
                                    minimumAmount:
                                      type: number
                                      description: >-
                                        The minimum amount committed for the
                                        plan in the billing period, in cents.
                                    minimumAmountApplied:
                                      type: number
                                      description: >-
                                        The top-up charged by this line item to
                                        reach the committed minimum, in cents:
                                        the difference between minimumAmount and
                                        what the plan's consumption amounted to.
                                  required:
                                    - type
                                    - minimumAmount
                                    - minimumAmountApplied
                                - title: Custom
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - custom
                                      description: >-
                                        Discriminator: metadata for a custom
                                        line item.
                                    definitionKey:
                                      type: string
                                      description: >-
                                        The key of the custom charge definition
                                        whose calculator priced the charge,
                                        following the
                                        custom:charge:<slug>:<name> convention.
                                      examples:
                                        - custom:charge:padaria-central:entregas
                                    memory:
                                      type: object
                                      additionalProperties: true
                                      description: >-
                                        The full calculation memory that the
                                        calculator returned, such as every tier
                                        it evaluated and the one it billed. Its
                                        shape belongs to the definition.
                                  required:
                                    - type
                                    - definitionKey
                                    - memory
                                - title: No metadata
                                  type: 'null'
                            subLineItems:
                              type: array
                              items:
                                type: object
                                description: >-
                                  Schema representing a sub-line item: one
                                  priced row of a line item's breakdown. The row
                                  type dictates the shape of metadata.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the sub-line item
                                      in our system.
                                  type:
                                    type: string
                                    enum:
                                      - fixed_price
                                      - minimum_amount
                                      - price_tier_flat
                                      - price_tier_unit
                                      - price_tier_package
                                      - price_tier_percentage
                                      - proration
                                      - license_proration
                                      - license_proration_tier
                                      - unit_price
                                      - included_quantity
                                      - package_price
                                      - percentage
                                      - overage
                                      - original_amount
                                      - fixed_unit_price
                                      - custom
                                    description: >-
                                      The kind of priced row: fixed_price and
                                      minimum_amount are companions of
                                      usage-based charges; unit_price,
                                      package_price, percentage, and
                                      included_quantity break down single-model
                                      pricing; price_tier_* rows break down
                                      tiered pricing; overage bills usage beyond
                                      the last tier; proration bills per
                                      prorated interval; license_proration bills
                                      license deltas (removals are negative);
                                      original_amount surfaces the
                                      pre-adjustment amount of an adjusted line;
                                      fixed_unit_price breaks down a fixed
                                      charge billed as a quantity times a unit
                                      amount; custom bills one component of a
                                      custom plan charge.
                                  name:
                                    type: string
                                    description: >-
                                      Display name of the sub-line item as it
                                      appears on the invoice breakdown.
                                    example: '[A partir de 1] Unidades'
                                  description:
                                    type: string
                                    nullable: true
                                    description: >-
                                      Optional descriptive text for the row.
                                      Null when absent.
                                    example: 120 x 2,50
                                  usage:
                                    type: number
                                    nullable: true
                                    description: >-
                                      The usage billed by this row: a count of
                                      resource units (the quantity for a
                                      fixed_unit_price row), or a monetary base
                                      amount in cents for percentage-priced rows
                                      (see the row's usageFormat, or the line
                                      item usageFormat when the row has none).
                                      Null for rows without usage (e.g.
                                      companions).
                                  usageFormat:
                                    type: string
                                    enum:
                                      - unit
                                      - currency
                                      - null
                                    nullable: true
                                    description: >-
                                      How to read the usage of this row when the
                                      row has a format of its own, as the custom
                                      rows of a custom line item do: unit means
                                      a count, currency means an amount in
                                      cents. Null when the row reads its usage
                                      in the line item usageFormat.
                                  amount:
                                    type: number
                                    description: >-
                                      Amount billed by this row, in cents. The
                                      sum of a line item's sub-line amounts
                                      equals its subtotalAmount.
                                  metadata:
                                    description: >-
                                      Pricing details of the row, keyed by the
                                      row type (and pricingType for overage
                                      rows).
                                    anyOf:
                                      - type: object
                                        description: >-
                                          Fixed-price companion row: the charge's
                                          configured fixed amount, billed
                                          alongside the usage rows. Only rendered
                                          when configured greater than zero.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - fixed_price
                                            description: >-
                                              Discriminator: fixed-price companion
                                              row.
                                          fixedPrice:
                                            type: number
                                            description: >-
                                              The fixed amount configured on the
                                              charge, in cents.
                                        required:
                                          - type
                                          - fixedPrice
                                      - type: object
                                        description: >-
                                          Minimum-amount companion row: tops the
                                          charge up to its configured minimum when
                                          usage alone stays below it. Only
                                          rendered when the top-up is greater than
                                          zero.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - minimum_amount
                                            description: >-
                                              Discriminator: minimum-amount companion
                                              row.
                                          minimumAmount:
                                            type: number
                                            description: >-
                                              The minimum amount configured on the
                                              charge, in cents.
                                          minimumAmountApplied:
                                            type: number
                                            description: >-
                                              The top-up billed by this row to reach
                                              the configured minimum, in cents.
                                        required:
                                          - type
                                          - minimumAmount
                                          - minimumAmountApplied
                                      - type: object
                                        description: >-
                                          Flat-priced tier row: usage falling in
                                          this tier band is billed at a flat
                                          amount, regardless of the exact
                                          quantity.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - price_tier_flat
                                            description: 'Discriminator: flat-priced tier row.'
                                          from:
                                            type: number
                                            description: >-
                                              Lower bound of the tier band, in
                                              resource units (inclusive).
                                          to:
                                            type: number
                                            nullable: true
                                            description: >-
                                              Upper bound of the tier band, in
                                              resource units (inclusive). Null for an
                                              unbounded final tier.
                                          fixedPrice:
                                            type: string
                                            description: >-
                                              The flat amount billed for the tier, as
                                              a decimal currency-unit string.
                                            examples:
                                              - '150.00'
                                        required:
                                          - type
                                          - from
                                          - to
                                          - fixedPrice
                                      - type: object
                                        description: >-
                                          Per-unit priced tier row: units
                                          attributed to this tier band are billed
                                          at the tier's unit price.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - price_tier_unit
                                            description: 'Discriminator: per-unit priced tier row.'
                                          from:
                                            type: number
                                            description: >-
                                              Lower bound of the tier band, in
                                              resource units (inclusive).
                                          to:
                                            type: number
                                            nullable: true
                                            description: >-
                                              Upper bound of the tier band, in
                                              resource units (inclusive). Null for an
                                              unbounded final tier.
                                          price:
                                            type: string
                                            description: >-
                                              Price per unit within the tier, as a
                                              decimal currency-unit string.
                                            examples:
                                              - '0.25'
                                          fixedPrice:
                                            type: string
                                            nullable: true
                                            description: >-
                                              Optional flat fee billed on top when the
                                              tier applies, as a decimal currency-unit
                                              string. Null when the tier has no flat
                                              fee.
                                            examples:
                                              - '10.00'
                                        required:
                                          - type
                                          - from
                                          - to
                                          - price
                                          - fixedPrice
                                      - type: object
                                        description: >-
                                          Package-priced tier row: units
                                          attributed to this tier band are billed
                                          per started package of packageSize
                                          units.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - price_tier_package
                                            description: 'Discriminator: package-priced tier row.'
                                          from:
                                            type: number
                                            description: >-
                                              Lower bound of the tier band, in
                                              resource units (inclusive).
                                          to:
                                            type: number
                                            nullable: true
                                            description: >-
                                              Upper bound of the tier band, in
                                              resource units (inclusive). Null for an
                                              unbounded final tier.
                                          packageSize:
                                            type: number
                                            description: Number of resource units per package.
                                          price:
                                            type: string
                                            description: >-
                                              Price per package, as a decimal
                                              currency-unit string.
                                            examples:
                                              - '45.00'
                                        required:
                                          - type
                                          - from
                                          - to
                                          - packageSize
                                          - price
                                      - type: object
                                        description: >-
                                          Percentage-priced tier row: the monetary
                                          base amount attributed to this tier band
                                          is billed at a percentage.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - price_tier_percentage
                                            description: >-
                                              Discriminator: percentage-priced tier
                                              row.
                                          from:
                                            type: number
                                            description: >-
                                              Lower bound of the tier band, in cents
                                              of the monetary base amount (inclusive).
                                          to:
                                            type: number
                                            nullable: true
                                            description: >-
                                              Upper bound of the tier band, in cents
                                              of the monetary base amount (inclusive).
                                              Null for an unbounded final tier.
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              Percentage applied to the base amount
                                              within the tier, as a decimal string
                                              from 0 to 100 (up to 6 decimal places).
                                            examples:
                                              - '2.5'
                                        required:
                                          - type
                                          - from
                                          - to
                                          - percentage
                                      - type: object
                                        description: >-
                                          Proration interval row: for charges on
                                          prorated resources, each interval bills
                                          the usage held during it, priced as if
                                          held for the whole cycle and scaled by
                                          the interval's share of the cycle.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - proration
                                            description: 'Discriminator: proration interval row.'
                                          intervalSize:
                                            type: number
                                            description: >-
                                              Length of the interval, in days of the
                                              billing cycle.
                                          amount:
                                            type: string
                                            description: >-
                                              The prorated amount of the interval, as
                                              a decimal currency-unit string: the
                                              interval usage priced as if held for the
                                              whole cycle, scaled by intervalSize over
                                              the cycle length.
                                            examples:
                                              - '29.0322580645'
                                          usage:
                                            type: number
                                            description: The usage held during the interval.
                                          intervalStart:
                                            type: string
                                            format: date
                                            description: First day of the interval.
                                          intervalEnd:
                                            type: string
                                            format: date
                                            description: Last day of the interval.
                                        required:
                                          - type
                                          - intervalSize
                                          - amount
                                          - usage
                                          - intervalStart
                                          - intervalEnd
                                      - type: object
                                        description: >-
                                          License proration delta row: for
                                          per_unit license charges billing under
                                          the proration model, the cycle-start row
                                          bills the starting licenses beyond the
                                          included quantity at their full-cycle
                                          price, and each change row bills the
                                          change in those licenses prorated over
                                          the days remaining in the cycle. A
                                          change that stays inside the included
                                          quantity has no row. Tiered charges use
                                          license_proration_tier instead.
                                          quantityDelta and the row's amount are
                                          signed — removals are negative.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - license_proration
                                            description: >-
                                              Discriminator: license proration delta
                                              row.
                                          changeDate:
                                            type: string
                                            format: date
                                            nullable: true
                                            description: >-
                                              The day the combined license quantity
                                              changed. Null on the cycle-start row.
                                          quantityDelta:
                                            type: number
                                            description: >-
                                              Signed change in the licenses beyond the
                                              included quantity (the starting licenses
                                              beyond it on the cycle-start row).
                                              Negative for removals.
                                          quantity:
                                            type: number
                                            description: >-
                                              The combined license quantity after this
                                              change.
                                          remainingDays:
                                            type: number
                                            description: >-
                                              Days from the change (inclusive) to the
                                              end of the cycle. Equals cycleDays on
                                              the cycle-start row.
                                          cycleDays:
                                            type: number
                                            description: Length of the billing cycle, in days.
                                          proratedUnitRate:
                                            type: string
                                            description: >-
                                              Absolute effective per-unit rate of the
                                              row over the remaining window, as a
                                              decimal currency-unit string: |amount| /
                                              |quantityDelta|. On a cycle-start row
                                              that bills no license, the unit price of
                                              the charge.
                                            examples:
                                              - '16.1290322581'
                                          amount:
                                            type: string
                                            description: >-
                                              The signed prorated amount of the row,
                                              as a decimal currency-unit string.
                                            examples:
                                              - '48.3870967742'
                                        required:
                                          - type
                                          - changeDate
                                          - quantityDelta
                                          - quantity
                                          - remainingDays
                                          - cycleDays
                                          - proratedUnitRate
                                          - amount
                                      - type: object
                                        description: >-
                                          Tiered license proration delta row: one
                                          price band of a license charge billing
                                          under the proration model with
                                          tiered_per_unit pricing. The cycle-start
                                          rows bill each band's opening occupancy
                                          at its full-cycle unit price, and each
                                          change row bills that band's occupancy
                                          delta prorated over the days remaining
                                          in the cycle. quantityDelta and the
                                          row's amount are signed — removals are
                                          negative.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - license_proration_tier
                                            description: >-
                                              Discriminator: tiered license proration
                                              delta row.
                                          changeDate:
                                            type: string
                                            format: date
                                            nullable: true
                                            description: >-
                                              The day the combined license quantity
                                              changed. Null on a cycle-start row.
                                          quantityDelta:
                                            type: number
                                            description: >-
                                              Signed change in the units this band
                                              holds (the band's opening occupancy on a
                                              cycle-start row). Negative for removals.
                                          quantity:
                                            type: number
                                            description: >-
                                              The combined license quantity across
                                              every band after this change.
                                          remainingDays:
                                            type: number
                                            description: >-
                                              Days from the change (inclusive) to the
                                              end of the cycle. Equals cycleDays on a
                                              cycle-start row.
                                          cycleDays:
                                            type: number
                                            description: Length of the billing cycle, in days.
                                          proratedUnitRate:
                                            type: string
                                            description: >-
                                              Absolute effective per-unit rate of the
                                              row over the remaining window, as a
                                              decimal currency-unit string: |amount| /
                                              |quantityDelta|.
                                            examples:
                                              - '16.1290322581'
                                          amount:
                                            type: string
                                            description: >-
                                              The signed prorated amount of the row,
                                              as a decimal currency-unit string.
                                            examples:
                                              - '48.3870967742'
                                          planChargeTierId:
                                            type: string
                                            description: >-
                                              The unique identifier of the plan charge
                                              tier this row moved through.
                                            examples:
                                              - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                          from:
                                            type: number
                                            description: >-
                                              Inclusive lower bound of the band, in
                                              licenses.
                                          to:
                                            type: number
                                            nullable: true
                                            description: >-
                                              Inclusive upper bound of the band, in
                                              licenses. Null on the last, open-ended
                                              band.
                                          unitPrice:
                                            type: string
                                            description: >-
                                              The band's full-cycle price per unit, as
                                              a decimal currency-unit string.
                                              proratedUnitRate is this scaled by
                                              remainingDays over cycleDays.
                                            examples:
                                              - '25.00'
                                        required:
                                          - type
                                          - changeDate
                                          - quantityDelta
                                          - quantity
                                          - remainingDays
                                          - cycleDays
                                          - proratedUnitRate
                                          - amount
                                          - planChargeTierId
                                          - from
                                          - to
                                          - unitPrice
                                      - type: object
                                        description: >-
                                          Unit-price row: billable units
                                          multiplied by a single price per unit.
                                          The row's usage holds the billable
                                          units.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - unit_price
                                            description: 'Discriminator: unit-price row.'
                                          price:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              Price per unit, as a decimal
                                              currency-unit string (up to 6 decimal
                                              places).
                                            examples:
                                              - '0.25'
                                        required:
                                          - type
                                          - price
                                      - type: object
                                        description: >-
                                          Included-quantity row: the free
                                          allotment of the charge. The row's usage
                                          holds the units consumed within the
                                          allotment and its amount is always zero.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - included_quantity
                                            description: 'Discriminator: included-quantity row.'
                                          includedQuantity:
                                            type: number
                                            description: >-
                                              Number of resource units included at no
                                              charge before billing starts.
                                        required:
                                          - type
                                          - includedQuantity
                                      - type: object
                                        description: >-
                                          Package-price row: billable units
                                          charged per started package of
                                          packageSize units. The row's usage holds
                                          the billable units.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - package_price
                                            description: 'Discriminator: package-price row.'
                                          packageSize:
                                            type: number
                                            description: Number of resource units per package.
                                          price:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              Price per package, as a decimal
                                              currency-unit string (up to 6 decimal
                                              places).
                                            examples:
                                              - '45.00'
                                          packagesBilled:
                                            type: number
                                            description: >-
                                              Number of packages billed: the billable
                                              units divided by packageSize, rounded
                                              up.
                                        required:
                                          - type
                                          - packageSize
                                          - price
                                          - packagesBilled
                                      - type: object
                                        description: >-
                                          Percentage row: a percentage applied
                                          over a monetary base amount. The row's
                                          usage holds the base amount, in cents.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - percentage
                                            description: 'Discriminator: percentage row.'
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              Percentage applied to the base amount,
                                              as a decimal string from 0 to 100 (up to
                                              6 decimal places).
                                            examples:
                                              - '2.5'
                                        required:
                                          - type
                                          - percentage
                                      - type: object
                                        description: >-
                                          Per-unit overage row: units beyond the
                                          last tier boundary, billed at the
                                          configured excess unit price. The row's
                                          usage holds the units over the boundary.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - overage
                                            description: 'Discriminator: overage row.'
                                          pricingType:
                                            type: string
                                            enum:
                                              - per_unit
                                            description: 'Discriminator: overage billed per unit.'
                                          from:
                                            type: number
                                            description: >-
                                              The boundary the overage starts from:
                                              the upper bound of the last tier, in
                                              resource units.
                                          price:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              Price per excess unit, as a decimal
                                              currency-unit string (up to 6 decimal
                                              places).
                                            examples:
                                              - '0.30'
                                        required:
                                          - type
                                          - pricingType
                                          - from
                                          - price
                                      - type: object
                                        description: >-
                                          Percentage overage row: the monetary
                                          base amount beyond the last tier
                                          boundary, billed at the configured
                                          excess percentage. The row's usage holds
                                          the base amount over the boundary, in
                                          cents.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - overage
                                            description: 'Discriminator: overage row.'
                                          pricingType:
                                            type: string
                                            enum:
                                              - percentage
                                            description: >-
                                              Discriminator: overage billed as a
                                              percentage.
                                          from:
                                            type: number
                                            description: >-
                                              The boundary the overage starts from:
                                              the upper bound of the last tier, in
                                              cents of the monetary base amount.
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              Percentage applied to the excess base
                                              amount, as a decimal string from 0 to
                                              100 (up to 6 decimal places).
                                            examples:
                                              - '1.5'
                                        required:
                                          - type
                                          - pricingType
                                          - from
                                          - percentage
                                      - type: object
                                        description: >-
                                          Original-amount row: surfaces the line
                                          item's pre-adjustment amount when the
                                          line has adjustments (e.g. a discount)
                                          but no price-component rows of its own.
                                          The row's amount equals the line item's
                                          subtotalAmount.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - original_amount
                                            description: 'Discriminator: original-amount row.'
                                        required:
                                          - type
                                      - type: object
                                        description: >-
                                          Fixed unit price row: the quantity of a
                                          fixed charge multiplied by its unit
                                          amount. The row's usage holds the
                                          quantity.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - fixed_unit_price
                                            description: 'Discriminator: fixed unit price row.'
                                          amount:
                                            type: integer
                                            minimum: 0
                                            description: Amount of one unit, in cents.
                                        required:
                                          - type
                                          - amount
                                      - type: object
                                        description: >-
                                          Custom row: one component of a custom
                                          plan charge, as its calculator billed
                                          it. The row's name, description, usage,
                                          usageFormat and amount hold the rest of
                                          the component.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - custom
                                            description: 'Discriminator: custom row.'
                                          key:
                                            type: string
                                            description: >-
                                              The key of the component in the sub-line
                                              schema of the charge's custom charge
                                              definition, such as documents_overage.
                                            examples:
                                              - documents_overage
                                        required:
                                          - type
                                          - key
                                required:
                                  - id
                                  - type
                                  - name
                                  - description
                                  - usage
                                  - usageFormat
                                  - amount
                                  - metadata
                                additionalProperties: false
                              description: >-
                                Breakdown of the line item amount into priced
                                rows (included quantities, unit/package/tier
                                prices, prorations, companions). Empty for line
                                items without a breakdown.
                            adjustments:
                              type: array
                              items:
                                type: object
                                description: >-
                                  Schema representing an adjustment applied on
                                  top of a line item subtotal, such as a
                                  discount or an allocation offset.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the adjustment in
                                      our system.
                                  name:
                                    type: string
                                    description: >-
                                      Display name of the adjustment as it
                                      appears on the invoice.
                                    example: Desconto de boas-vindas
                                  type:
                                    type: string
                                    enum:
                                      - monetary_discount
                                      - allocation_offset
                                    description: >-
                                      The kind of adjustment: monetary_discount
                                      (a discount applied to the line item) or
                                      allocation_offset (the share of the amount
                                      moved to another payment account's invoice
                                      under a split allocation strategy).
                                  amount:
                                    type: number
                                    description: >-
                                      Amount of the adjustment, in cents.
                                      Negative when the adjustment reduces the
                                      line item total.
                                required:
                                  - id
                                  - name
                                  - type
                                  - amount
                                additionalProperties: false
                              description: >-
                                Adjustments applied on top of the line item
                                subtotal, such as discounts and allocation
                                offsets.
                          required:
                            - id
                            - idempotencyKey
                            - customerId
                            - productId
                            - resourceId
                            - licenseId
                            - lineItemGroupId
                            - name
                            - scope
                            - startDate
                            - endDate
                            - totalUsage
                            - usageFormat
                            - subtotalAmount
                            - adjustmentAmount
                            - totalAmount
                            - discountAmount
                            - metadata
                            - subLineItems
                            - adjustments
                          additionalProperties: false
                        description: >-
                          Line items that do not belong to any line item group
                          (e.g. contract-level minimum commitments, additional
                          charges, and ungrouped one-off items).
                      customFields:
                        type: object
                        description: >-
                          The values of the custom fields of invoices, keyed by
                          the key of each custom field. The object is empty when
                          the invoice holds no value. A user edits them in the
                          billing app, and `PUT /v1/invoices/{id}/custom-fields`
                          replaces the whole set, in any status of the invoice.
                        additionalProperties:
                          anyOf:
                            - type: string
                            - type: array
                              items:
                                type: string
                        default: {}
                        example:
                          customField1: value1
                          customField2:
                            - value2
                            - value3
                      sentAt:
                        type: string
                        format: date-time
                        nullable: true
                        description: >-
                          When Aira last sent the invoice by e-mail to its
                          invoice recipients, in an invoice delivery. Null when
                          Aira has not sent it.
                      replaceReason:
                        type: string
                        enum:
                          - contract_allocation_changed
                          - manually_reopened
                          - null
                        nullable: true
                        description: >-
                          Why one invoice of the same invoice slot replaced
                          another, on both invoices of the replacement:
                          manually_reopened for a reopening, and
                          contract_allocation_changed when a change to the
                          contract allocation canceled the invoice and a later
                          billing of its billing act replaced it. Null when the
                          invoice replaces no invoice and no invoice replaces
                          it.
                      replacesInvoiceId:
                        type: string
                        format: uuid
                        nullable: true
                        description: >-
                          The unique identifier of the canceled invoice that
                          this invoice replaces in its invoice slot. Null when
                          the invoice replaces no invoice.
                      replacedByInvoiceId:
                        type: string
                        format: uuid
                        nullable: true
                        description: >-
                          The unique identifier of the invoice that replaces
                          this canceled invoice in its invoice slot. Null when
                          no invoice replaces it.
                    required:
                      - id
                      - idempotencyKey
                      - customerId
                      - paymentAccountId
                      - contractId
                      - contractInvoiceSequence
                      - issuingAccount
                      - billingAccount
                      - invoiceAllocationStrategy
                      - lastCalculatedAt
                      - invoiceNumber
                      - invoiceDate
                      - memo
                      - subtotalAmount
                      - adjustmentAmount
                      - totalAmount
                      - discountAmount
                      - status
                      - isLocked
                      - failureReason
                      - source
                      - autoIssue
                      - amountDue
                      - dueDate
                      - lineItemGroups
                      - standaloneLineItems
                      - customFields
                      - sentAt
                      - replaceReason
                      - replacesInvoiceId
                      - replacedByInvoiceId
                    additionalProperties: false
                  payments:
                    type: array
                    items:
                      type: object
                      description: >-
                        A payment: one request to collect the amount of an
                        invoice through a payment provider, with its method, due
                        date and status. An invoice can have several. A payment
                        that the ERP issues and holds is an external payment.
                      properties:
                        id:
                          type: string
                          description: The unique identifier of the payment in our system.
                          example: 3c90c3cc-0d44-4b50-8888-8dd25736052a
                        amount:
                          type: number
                          multipleOf: 1
                          description: Amount charged by the payment, in cents.
                        dueDate:
                          type: string
                          format: date
                          nullable: true
                          description: >-
                            Due date of the payment charge. Null when the
                            payment has no due date.
                        paymentMethod:
                          type: string
                          enum:
                            - bolepix
                            - bank_slip
                            - pix
                            - credit_card
                            - bank_transfer
                          description: >-
                            How the payment is collected: pix, bank_slip
                            (boleto), bolepix (boleto payable via Pix),
                            credit_card, or bank_transfer.
                        status:
                          type: string
                          enum:
                            - created
                            - pending
                            - paid
                            - failed
                            - canceled
                            - expired
                          description: >-
                            Current status of the payment: created (registered
                            at the provider), pending (awaiting settlement),
                            paid, failed, canceled, or expired.
                        provider:
                          type: string
                          enum:
                            - celcash
                            - omie
                            - asaas
                            - contaazul
                          description: The payment provider that collects the payment.
                        paymentLinkUrl:
                          type: string
                          nullable: true
                          description: >-
                            The payment link: the page at the payment provider
                            where the customer pays. Null when the payment
                            provider gave none.
                          example: https://www.asaas.com/i/abc123def456
                      required:
                        - id
                        - amount
                        - dueDate
                        - paymentMethod
                        - status
                        - provider
                        - paymentLinkUrl
                      additionalProperties: false
                    description: >-
                      Payment charges registered for the invoice at the payment
                      provider, when any.
                  statusHistory:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing one status transition in the invoice
                        history, from the most recent to the oldest.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the status transition in
                            our system.
                        previousStatus:
                          type: string
                          enum:
                            - open
                            - in_review
                            - issued
                            - synced
                            - pending
                            - paid
                            - overdue
                            - canceled
                            - failed
                            - null
                          nullable: true
                          description: >-
                            The invoice status before the transition. Null on
                            the first entry (invoice creation).
                        newStatus:
                          type: string
                          enum:
                            - open
                            - in_review
                            - issued
                            - synced
                            - pending
                            - paid
                            - overdue
                            - canceled
                            - failed
                          description: The invoice status after the transition.
                        reason:
                          type: string
                          enum:
                            - invoice_created
                            - billing_cycle_closed
                            - billing_cycle_opened
                            - billing_cycle_canceled
                            - invoice_auto_issued
                            - retroactive_invoice_issued
                            - manually_issued
                            - contract_canceled
                            - manually_canceled
                            - manually_paid
                            - manually_unmarked_as_paid
                            - contract_allocation_removed
                            - erp_sync_failed
                            - payment_initiated
                            - erp_sync_success
                            - payment_failed
                            - payment_paid
                            - due_date_passed
                            - invoice_reopened
                            - invoice_created_after_reopening
                            - manually_canceled_via_api
                            - manually_marked_as_in_review_via_api
                          description: >-
                            What triggered the transition. Values name the
                            trigger event: billing cycle lifecycle (e.g.
                            billing_cycle_closed), issuing (invoice_auto_issued,
                            manually_issued), ERP sync outcomes
                            (erp_sync_success, erp_sync_failed), payment
                            lifecycle (payment_initiated, payment_paid,
                            payment_failed), due date passing (due_date_passed),
                            reopening (invoice_reopened), and manual or
                            API-driven actions (manually_canceled_via_api,
                            manually_marked_as_in_review_via_api).
                        occurredAt:
                          type: string
                          format: date-time
                          description: When the transition happened.
                        metadata:
                          type: object
                          nullable: true
                          additionalProperties: true
                          description: >-
                            Additional context recorded with the transition
                            (e.g. failure details), when available. Null
                            otherwise.
                      required:
                        - id
                        - previousStatus
                        - newStatus
                        - reason
                        - occurredAt
                        - metadata
                      additionalProperties: false
                    description: >-
                      Status transitions of the invoice, from the most recent to
                      the oldest.
                  customer:
                    type: object
                    description: The customer the invoice bills.
                    properties:
                      id:
                        description: The unique identifier of the customer in our system.
                        type: string
                        format: uuid
                      externalId:
                        description: >-
                          The external id of the customer: the key that you give
                          it, which no other customer has. Events and license
                          balances name their customer by it.
                        type: string
                        pattern: ^[a-zA-Z0-9_-]+$
                        example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                      name:
                        description: The name of the customer.
                        type: string
                        example: Acme Inc.
                      invoicePrefix:
                        description: >-
                          The prefix of the numbers of the customer's invoices,
                          which Aira makes from the name of the customer when it
                          creates the customer, and which never changes.
                        type: string
                        example: ACMEI
                      type:
                        description: >-
                          The type of the customer: an `individual`, an
                          `organization`, which groups zero or more
                          subsidiaries, or a `subsidiary`, which belongs to one
                          organization.
                        type: string
                        enum:
                          - individual
                          - organization
                          - subsidiary
                        example: individual
                      parentCustomerId:
                        description: >-
                          The id of the organization that the customer belongs
                          to when it is a subsidiary, or null for an individual
                          or an organization.
                        type:
                          - 'null'
                          - string
                        format: uuid
                      dunningScheduleId:
                        description: >-
                          The id of the dunning schedule that the customer
                          follows, or null when the customer follows none and
                          gets no dunning e-mails.
                        type:
                          - 'null'
                          - string
                        format: uuid
                      archivedAt:
                        description: >-
                          The instant when the customer was archived, or null
                          when it is not archived.
                        type:
                          - 'null'
                          - string
                        format: date-time
                      customFields:
                        type: object
                        description: >-
                          Custom fields that can be associated with the entity.
                          The fields must be previously created in the system
                          before they can be used.
                        additionalProperties:
                          anyOf:
                            - type: string
                            - type: array
                              items:
                                type: string
                        default: {}
                        example:
                          customField1: value1
                          customField2:
                            - value2
                            - value3
                    required:
                      - id
                      - externalId
                      - name
                      - type
                    additionalProperties: false
                  contract:
                    type: object
                    description: >-
                      Summary of the contract that generated the invoice. Null
                      for invoices not generated from a contract.
                    properties:
                      id:
                        description: The unique identifier of the contract in our system.
                        type: string
                        format: uuid
                      contractNumber:
                        type: string
                        description: >-
                          The number of the contract, which Aira gives it on
                          creation from the prefix of its customer and the
                          sequence of the contracts of that customer.
                        example: MERCA-CTR-01
                      customerId:
                        type: string
                        format: uuid
                        description: ID of the customer associated with this contract.
                      legalEntityId:
                        type: string
                        format: uuid
                        nullable: true
                        description: >-
                          ID of the legal entity that issues the invoices of
                          this contract.
                      startDate:
                        description: The start date of the contract.
                        type: string
                        format: date
                      endDate:
                        description: >-
                          The end date of the contract. Null if the contract has
                          no end date.
                        type:
                          - 'null'
                          - string
                        format: date
                      status:
                        description: The current status of the contract.
                        type: string
                        enum:
                          - active
                          - canceled
                          - completed
                          - draft
                      customFields:
                        type: object
                        description: >-
                          Custom fields that can be associated with the entity.
                          The fields must be previously created in the system
                          before they can be used.
                        additionalProperties:
                          anyOf:
                            - type: string
                            - type: array
                              items:
                                type: string
                        default: {}
                        example:
                          customField1: value1
                          customField2:
                            - value2
                            - value3
                    required:
                      - id
                      - contractNumber
                      - customerId
                      - legalEntityId
                      - startDate
                      - endDate
                      - status
                      - customFields
                    additionalProperties: false
                    nullable: true
                  artifacts:
                    type: array
                    items:
                      type: object
                      description: >-
                        A file that Aira generates for an invoice, such as the
                        invoice PDF or a usage statement.
                      properties:
                        id:
                          type: string
                          description: The unique identifier of the artifact in our system.
                          example: 3c90c3cc-0d44-4b50-8888-8dd25736052a
                        artifactType:
                          type: string
                          pattern: '^(default|custom):'
                          description: >-
                            The kind of artifact: `default:*` for an artifact
                            that Aira generates in every setup, such as
                            `default:invoice_pdf`, or `custom:*` for an artifact
                            that Aira writes for you.
                          example: default:invoice_pdf
                        fileExtension:
                          type: string
                          enum:
                            - pdf
                            - csv
                            - xlsx
                            - xlsm
                            - xml
                            - zip
                          description: File extension of the artifact.
                        generatedAt:
                          type: string
                          format: date-time
                          description: When the artifact file was generated.
                      required:
                        - id
                        - artifactType
                        - fileExtension
                        - generatedAt
                      additionalProperties: false
                    description: Files generated for the invoice (e.g. the invoice PDF).
                required:
                  - invoice
                  - payments
                  - statusHistory
                  - customer
                  - contract
                  - artifacts
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/by-provider-id/{providerId}:
    get:
      summary: Fetch invoice by provider ID
      tags:
        - Invoices
      description: >-
        Fetches the invoice whose invoice sync has the `providerId`, the
        identifier of the record that holds the invoice in the ERP, with or
        without a contract, in the shape of `GET /v1/invoices/{id}`.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
          example: '4815162342'
          in: path
          name: providerId
          required: true
          description: >-
            The identifier assigned to the invoice by the external provider it
            was synced to (e.g. the ERP document id).
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_not_found
          when: no invoice has an invoice sync with the `providerId`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: >-
            The invoice, with its payments, its status history, its customer,
            its contract and its invoice artifacts.
          content:
            application/json:
              schema:
                type: object
                properties:
                  invoice:
                    type: object
                    description: >-
                      The invoice, including its line item groups and standalone
                      line items.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the invoice in our system.
                      idempotencyKey:
                        type: string
                        description: >-
                          A unique key that identifies the invoice for
                          idempotent creation. Supplied by the caller for
                          one-off invoices; generated by the billing engine for
                          contract invoices.
                        example: padaria-central-2026-11
                      customerId:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the customer this invoice
                          bills.
                      paymentAccountId:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the customer payment account
                          used as the billing account for this invoice.
                      contractId:
                        type: string
                        nullable: true
                        format: uuid
                        description: >-
                          The unique identifier of the contract that generated
                          this invoice. Null for invoices not generated from a
                          contract (e.g. one-off and imported invoices).
                      contractInvoiceSequence:
                        type: integer
                        minimum: 1
                        nullable: true
                        description: >-
                          The number of the invoice within its contract, in the
                          order that Aira created the contract's invoices: 1 for
                          the first, 2 for the next, and so on. Every invoice
                          gets its own number, including each invoice of a split
                          across payment accounts and the replacement of a
                          reopened invoice, and a number never changes and is
                          never reused. Null for invoices without a contract.
                      issuingAccount:
                        type: object
                        description: >-
                          Snapshot of the legal entity issuing the invoice (the
                          seller), captured at invoice creation.
                        properties:
                          tradeName:
                            type: string
                            nullable: true
                            description: >-
                              Trade name (nome fantasia) of the legal entity.
                              Null when absent.
                            example: Padaria Central
                          businessName:
                            type: string
                            description: >-
                              Registered business name (razão social) of the
                              legal entity.
                            example: Padaria Central Ltda
                          emails:
                            type: array
                            items:
                              type: string
                              format: email
                            description: >-
                              Billing contact email addresses of the legal
                              entity.
                          taxId:
                            type: string
                            description: >-
                              Tax identification number of the legal entity,
                              digits only.
                            example: '01234567000195'
                          taxIdType:
                            type: string
                            enum:
                              - cnpj
                              - cpf
                            description: >-
                              The kind of tax identification number in taxId
                              (e.g. CNPJ for Brazilian companies, CPF for
                              individuals).
                          zipCode:
                            type: string
                            nullable: true
                            description: >-
                              Postal code of the legal entity address. Null when
                              absent.
                            example: '01310100'
                          street:
                            type: string
                            nullable: true
                            description: >-
                              Street of the legal entity address. Null when
                              absent.
                            example: Avenida Paulista
                          number:
                            type: string
                            nullable: true
                            description: >-
                              Street number of the legal entity address. Null
                              when absent.
                            example: '1000'
                          neighborhood:
                            type: string
                            nullable: true
                            description: >-
                              Neighborhood of the legal entity address. Null
                              when absent.
                            example: Bela Vista
                          city:
                            type: string
                            nullable: true
                            description: >-
                              City of the legal entity address. Null when
                              absent.
                            example: São Paulo
                          state:
                            type: string
                            enum:
                              - AC
                              - AL
                              - AP
                              - AM
                              - BA
                              - CE
                              - DF
                              - ES
                              - GO
                              - MA
                              - MT
                              - MS
                              - MG
                              - PA
                              - PB
                              - PR
                              - PE
                              - PI
                              - RJ
                              - RN
                              - RS
                              - RO
                              - RR
                              - SC
                              - SP
                              - SE
                              - TO
                              - null
                            nullable: true
                            description: >-
                              State of the legal entity address, as a two-letter
                              code. Null when absent.
                          country:
                            type: string
                            enum:
                              - Brasil
                              - null
                            nullable: true
                            description: >-
                              Country of the legal entity address. Null when
                              absent.
                          complement:
                            type: string
                            nullable: true
                            description: >-
                              Address complement of the legal entity address.
                              Null when absent.
                            example: Sala 12
                        required:
                          - tradeName
                          - businessName
                          - emails
                          - taxId
                          - taxIdType
                          - zipCode
                          - street
                          - number
                          - neighborhood
                          - city
                          - state
                          - country
                          - complement
                        additionalProperties: false
                      billingAccount:
                        type: object
                        description: >-
                          Snapshot of the billed party (the legal entity behind
                          the customer payment account), captured at invoice
                          creation.
                        properties:
                          tradeName:
                            type: string
                            nullable: true
                            description: >-
                              Trade name (nome fantasia) of the legal entity.
                              Null when absent.
                            example: Padaria Central
                          businessName:
                            type: string
                            description: >-
                              Registered business name (razão social) of the
                              legal entity.
                            example: Padaria Central Ltda
                          emails:
                            type: array
                            items:
                              type: string
                              format: email
                            description: >-
                              Billing contact email addresses of the legal
                              entity.
                          taxId:
                            type: string
                            description: >-
                              Tax identification number of the legal entity,
                              digits only.
                            example: '01234567000195'
                          taxIdType:
                            type: string
                            enum:
                              - cnpj
                              - cpf
                            description: >-
                              The kind of tax identification number in taxId
                              (e.g. CNPJ for Brazilian companies, CPF for
                              individuals).
                          zipCode:
                            type: string
                            nullable: true
                            description: >-
                              Postal code of the legal entity address. Null when
                              absent.
                            example: '01310100'
                          street:
                            type: string
                            nullable: true
                            description: >-
                              Street of the legal entity address. Null when
                              absent.
                            example: Avenida Paulista
                          number:
                            type: string
                            nullable: true
                            description: >-
                              Street number of the legal entity address. Null
                              when absent.
                            example: '1000'
                          neighborhood:
                            type: string
                            nullable: true
                            description: >-
                              Neighborhood of the legal entity address. Null
                              when absent.
                            example: Bela Vista
                          city:
                            type: string
                            nullable: true
                            description: >-
                              City of the legal entity address. Null when
                              absent.
                            example: São Paulo
                          state:
                            type: string
                            enum:
                              - AC
                              - AL
                              - AP
                              - AM
                              - BA
                              - CE
                              - DF
                              - ES
                              - GO
                              - MA
                              - MT
                              - MS
                              - MG
                              - PA
                              - PB
                              - PR
                              - PE
                              - PI
                              - RJ
                              - RN
                              - RS
                              - RO
                              - RR
                              - SC
                              - SP
                              - SE
                              - TO
                              - null
                            nullable: true
                            description: >-
                              State of the legal entity address, as a two-letter
                              code. Null when absent.
                          country:
                            type: string
                            enum:
                              - Brasil
                              - null
                            nullable: true
                            description: >-
                              Country of the legal entity address. Null when
                              absent.
                          complement:
                            type: string
                            nullable: true
                            description: >-
                              Address complement of the legal entity address.
                              Null when absent.
                            example: Sala 12
                        required:
                          - tradeName
                          - businessName
                          - emails
                          - taxId
                          - taxIdType
                          - zipCode
                          - street
                          - number
                          - neighborhood
                          - city
                          - state
                          - country
                          - complement
                        additionalProperties: false
                      invoiceAllocationStrategy:
                        type: string
                        enum:
                          - single
                          - percent_split
                          - subsidiary_usage_split
                        description: >-
                          How the originating contract distributes charges
                          across payment accounts: single bills a single payment
                          account; percent_split divides the total between
                          payment accounts by configured percentages;
                          subsidiary_usage_split divides it according to each
                          subsidiary's usage.
                      lastCalculatedAt:
                        type: string
                        format: date-time
                        nullable: true
                        description: >-
                          When the invoice amounts were last computed by the
                          billing engine. Null when the invoice has never been
                          calculated.
                      invoiceNumber:
                        type: string
                        description: >-
                          Human-readable invoice number, built from the
                          customer's invoice prefix plus a sequential counter.
                        example: ACMEI-0042
                      invoiceDate:
                        type: string
                        format: date
                        description: >-
                          The date of the invoice. On a contract invoice it is
                          the date of its billing act: the first day of the
                          first billing cycle that the contract invoices for an
                          activation invoice, and the last day of the billing
                          cycle for a closing invoice. Its line items state the
                          periods that it bills. On a one-off or imported
                          invoice it is the date given when the invoice was
                          created.
                      memo:
                        type: string
                        nullable: true
                        description: >-
                          Free-form memo attached to the invoice. On contract
                          invoices, it reads "Período <start> a <end>" with the
                          period of the line item that bills most often, such as
                          the month when a monthly fee is billed with an annual
                          fee. When two line items bill equally often, it uses
                          the earlier period. Null when absent.
                        example: Período 01/11/2026 a 30/11/2026
                      subtotalAmount:
                        type: number
                        description: >-
                          Sum of the line item subtotals before adjustments, in
                          cents.
                      adjustmentAmount:
                        type: number
                        description: >-
                          Net amount of all adjustments applied to the invoice
                          line items (discounts and allocation offsets), in
                          cents. Negative when adjustments reduce the amount
                          owed.
                      totalAmount:
                        type: number
                        description: >-
                          Final invoice amount, in cents: subtotalAmount +
                          adjustmentAmount.
                      discountAmount:
                        type: number
                        description: >-
                          The discount portion of adjustmentAmount, in cents
                          (sum of monetary discount adjustments only). Negative
                          when discounts were applied.
                      status:
                        type: string
                        enum:
                          - open
                          - in_review
                          - issued
                          - synced
                          - pending
                          - paid
                          - overdue
                          - canceled
                          - failed
                        description: >-
                          Current status of the invoice lifecycle: open
                          (accumulating charges, editable), in_review (flagged
                          for manual review before issuing), issued (finalized
                          and issued to the customer), synced (registered in the
                          external ERP/payment provider), pending (a payment was
                          initiated and awaits settlement), paid, overdue
                          (unpaid past the due date), canceled, or failed (an
                          issue/sync attempt failed and needs attention).
                      isLocked:
                        type: boolean
                        description: >-
                          Whether the invoice contents are locked against edits.
                          Aira locks an invoice when it issues or cancels it,
                          together with the other invoices of its allocation
                          group, except when it cancels the invoice because its
                          payment account left the allocation of the contract,
                          which locks only that invoice. A locked invoice stays
                          locked, also when its status later moves to failed.
                      failureReason:
                        type: string
                        nullable: true
                        description: >-
                          Reason for the most recent failure on the invoice
                          (e.g. an ERP sync or payment issue). Null when the
                          invoice has no active failure.
                        example: contract_sync_not_found
                      source:
                        type: string
                        enum:
                          - contract
                          - one_off
                          - import
                        description: >-
                          How the invoice originated: contract (generated by a
                          contract billing cycle), one_off (created manually or
                          through the API), or import (ingested from an external
                          system).
                      autoIssue:
                        type: boolean
                        description: >-
                          Whether the invoice is issued automatically when its
                          billing cycle closes, without manual review.
                      amountDue:
                        type: number
                        nullable: true
                        description: >-
                          Outstanding amount due on the invoice, in cents. Null
                          when not tracked.
                      dueDate:
                        type: string
                        format: date
                        nullable: true
                        description: >-
                          Payment due date of the invoice. Null when no due date
                          is set (e.g. before the invoice is issued).
                      lineItemGroups:
                        type: array
                        items:
                          type: object
                          description: >-
                            Schema representing a line item group: a container
                            that gathers the line items generated from one plan
                            instance (or created as a group on one-off
                            invoices). Monetary amounts are integers in cents.
                          properties:
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the line item group in
                                our system.
                            idempotencyKey:
                              type: string
                              description: >-
                                A unique key that identifies the group within
                                the invoice. Supplied by the caller for one-off
                                groups; generated by the billing engine
                                otherwise.
                              example: servicos-novembro
                            customerId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the customer whose
                                consumption this group bills.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product this group
                                belongs to.
                            planId:
                              type: string
                              nullable: true
                              format: uuid
                              description: >-
                                The unique identifier of the plan whose instance
                                generated this group. Null for groups not
                                generated from a plan (e.g. on one-off
                                invoices).
                            planInstanceId:
                              type: string
                              nullable: true
                              format: uuid
                              description: >-
                                The unique identifier of the plan instance that
                                generated this group. Null for groups not
                                generated from a plan instance.
                            name:
                              type: string
                              description: >-
                                Display name of the group as it appears on the
                                invoice, typically the plan or product name.
                              example: Plano Entregas
                            startDate:
                              type: string
                              format: date
                              description: >-
                                Start of the period that the group shows. On
                                contract invoices, it is the period of the
                                group's line item that bills most often, such as
                                the month when a monthly fee is billed with an
                                annual fee. When two line items bill equally
                                often, it is the earlier period.
                            endDate:
                              type: string
                              format: date
                              description: >-
                                End of the period that the group shows, which
                                `startDate` describes.
                            subtotalAmount:
                              type: number
                              description: >-
                                Sum of the group's line item subtotals before
                                adjustments, in cents.
                            adjustmentAmount:
                              type: number
                              description: >-
                                Net amount of the adjustments applied to the
                                group's line items (discounts and allocation
                                offsets), in cents. Negative when adjustments
                                reduce the amount owed.
                            totalAmount:
                              type: number
                              description: >-
                                Final group amount, in cents: subtotalAmount +
                                adjustmentAmount.
                            discountAmount:
                              type: number
                              description: >-
                                The discount portion of adjustmentAmount, in
                                cents (sum of monetary discount adjustments
                                only). Negative when discounts were applied.
                            lineItems:
                              type: array
                              items:
                                type: object
                                description: >-
                                  One amount on an invoice, such as a plan
                                  charge, the contract minimum, a tax gross-up
                                  (the withheld ISS, the municipal service tax,
                                  added on top), a one-off amount or an
                                  additional charge.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the line item in
                                      our system.
                                  idempotencyKey:
                                    type: string
                                    description: >-
                                      A unique key that identifies the line item
                                      within the invoice. Supplied by the caller
                                      for one-off line items; generated by the
                                      billing engine otherwise.
                                    example: entrega-novembro
                                  customerId:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the customer
                                      whose consumption this line item bills. On
                                      split or consolidated invoices it may be a
                                      subsidiary of the invoice's customer.
                                  productId:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the product this
                                      line item belongs to.
                                  itemId:
                                    type: string
                                    nullable: true
                                    format: uuid
                                    description: >-
                                      The unique identifier of the catalog item
                                      this line bills. Null for line items not
                                      backed by a catalog item.
                                  resourceId:
                                    type: string
                                    nullable: true
                                    format: uuid
                                    description: >-
                                      The unique identifier of the metered
                                      resource behind a usage_based line item.
                                      Null for line items not driven by resource
                                      usage.
                                  licenseId:
                                    type: string
                                    nullable: true
                                    format: uuid
                                    description: >-
                                      The unique identifier of the license
                                      behind a license_based line item. Null for
                                      line items not driven by a license count.
                                  lineItemGroupId:
                                    type: string
                                    nullable: true
                                    format: uuid
                                    description: >-
                                      The unique identifier of the line item
                                      group containing this line item. Null for
                                      standalone line items.
                                  name:
                                    type: string
                                    description: >-
                                      Display name of the line item as it
                                      appears on the invoice.
                                    example: Entregas
                                  scope:
                                    type: string
                                    enum:
                                      - credit_purchase
                                      - contract_minimum_commitment
                                      - minimum_commitment
                                      - fixed
                                      - usage_based
                                      - license_based
                                      - custom
                                      - additional_charge
                                      - one_off
                                      - tax_gross_up
                                    description: >-
                                      What the line item charges for:
                                      usage_based (metered resource
                                      consumption), license_based (a license's
                                      reported count billed in full), fixed
                                      (recurring fixed charge of a plan), custom
                                      (custom plan charge, priced by a
                                      calculator that Aira writes for you),
                                      minimum_commitment (plan-level minimum
                                      top-up), contract_minimum_commitment
                                      (contract-level minimum top-up),
                                      credit_purchase (credit pool top-up),
                                      additional_charge (extra charge added
                                      manually), one_off (line item of a one-off
                                      invoice), or tax_gross_up (tax gross-up
                                      charge).
                                  startDate:
                                    type: string
                                    format: date
                                    description: >-
                                      Start of the period covered by this line
                                      item.
                                  endDate:
                                    type: string
                                    format: date
                                    description: >-
                                      End of the period covered by this line
                                      item.
                                  totalUsage:
                                    type: number
                                    nullable: true
                                    description: >-
                                      Total usage billed by the line item, in
                                      the unit given by usageFormat. Null for
                                      line items without a single usage (e.g.
                                      fixed charges without a quantity, and
                                      custom line items whose calculator returns
                                      no total).
                                  usageFormat:
                                    type: string
                                    enum:
                                      - unit
                                      - currency
                                      - null
                                    nullable: true
                                    description: >-
                                      How to read totalUsage, and the usage of
                                      each sub-line item that has no usageFormat
                                      of its own: unit means a count of resource
                                      units or a fixed charge quantity; currency
                                      means a monetary base amount in cents.
                                      Null when the line item has no single
                                      usage, as a custom line item whose
                                      sub-line items bill different kinds of
                                      volume, each with its own usageFormat.
                                  subtotalAmount:
                                    type: number
                                    description: >-
                                      Line item amount before adjustments, in
                                      cents (sum of its sub-line item amounts).
                                  adjustmentAmount:
                                    type: number
                                    description: >-
                                      Net amount of the adjustments applied to
                                      this line item (discounts and allocation
                                      offsets), in cents. Negative when
                                      adjustments reduce the amount owed.
                                  totalAmount:
                                    type: number
                                    description: >-
                                      Final line item amount, in cents:
                                      subtotalAmount + adjustmentAmount.
                                  discountAmount:
                                    type: number
                                    description: >-
                                      The discount portion of adjustmentAmount,
                                      in cents (sum of monetary discount
                                      adjustments only). Negative when discounts
                                      were applied.
                                  metadata:
                                    description: >-
                                      Pricing metadata for the line item, where
                                      the shape is keyed by type. Always
                                      present, but null for line items without
                                      pricing metadata: credit_purchase,
                                      additional_charge, one_off, and
                                      tax_gross_up. It is populated for fixed
                                      (the billing timing), usage_based,
                                      license_based, minimum_commitment,
                                      contract_minimum_commitment, and custom
                                      (the definition and the calculation
                                      memory) line items.
                                    anyOf:
                                      - title: Fixed
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - fixed
                                            description: >-
                                              Discriminator: metadata for a fixed line
                                              item.
                                          billingTiming:
                                            type: string
                                            enum:
                                              - in_advance
                                              - in_arrears
                                            description: >-
                                              Whether the fee was billed in advance of
                                              its service period or after it.
                                        required:
                                          - type
                                          - billingTiming
                                      - title: Usage-based
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - usage_based
                                            description: >-
                                              Discriminator: metadata for a
                                              usage_based line item.
                                          billingModel:
                                            type: string
                                            enum:
                                              - in_full
                                              - proration
                                            description: >-
                                              How the metered resource accrues over
                                              the billing period: in_full bills the
                                              full usage of the period; proration
                                              weighs usage by the fraction of the
                                              period each amount was held.
                                          priceTierDivision:
                                            type: string
                                            enum:
                                              - unique_tier
                                              - progressive
                                            description: >-
                                              For tier-based pricing models only: how
                                              usage was divided across tiers.
                                              unique_tier prices all usage at the
                                              single tier that contains the total;
                                              progressive prices each tier's band
                                              separately. Absent for non-tiered
                                              models.
                                          pricingModel:
                                            type: string
                                            enum:
                                              - fixed
                                              - per_unit
                                              - per_package
                                              - percentage
                                              - tiered_per_unit
                                              - tiered_percentage
                                              - tiered_fixed
                                              - advanced
                                              - custom
                                            description: >-
                                              The pricing model of the plan charge
                                              that produced this line item. Charges
                                              priced before pricing models existed are
                                              reported as advanced.
                                        required:
                                          - type
                                          - billingModel
                                          - pricingModel
                                      - title: License-based
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - license_based
                                            description: >-
                                              Discriminator: metadata for a
                                              license_based line item.
                                          billingModel:
                                            type: string
                                            enum:
                                              - in_full
                                              - proration
                                            description: >-
                                              How the license count accrues over the
                                              billing period. Always in_full: the
                                              latest reported count is billed in full.
                                          priceTierDivision:
                                            type: string
                                            enum:
                                              - unique_tier
                                              - progressive
                                            description: >-
                                              For tier-based pricing models only: how
                                              the license count was divided across
                                              tiers. unique_tier prices the whole
                                              count at the single tier that contains
                                              the total; progressive prices each
                                              tier's band separately. Absent for
                                              non-tiered models.
                                          pricingModel:
                                            type: string
                                            enum:
                                              - fixed
                                              - per_unit
                                              - per_package
                                              - percentage
                                              - tiered_per_unit
                                              - tiered_percentage
                                              - tiered_fixed
                                              - advanced
                                              - custom
                                            description: >-
                                              The pricing model of the plan charge
                                              that produced this line item.
                                        required:
                                          - type
                                          - billingModel
                                          - pricingModel
                                      - title: Contract minimum commitment
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - contract_minimum_commitment
                                            description: >-
                                              Discriminator: metadata for a
                                              contract_minimum_commitment line item.
                                          minimumAmount:
                                            type: number
                                            description: >-
                                              The minimum amount committed for the
                                              whole contract in the billing period, in
                                              cents.
                                          minimumAmountApplied:
                                            type: number
                                            description: >-
                                              The top-up charged by this line item to
                                              reach the committed minimum, in cents:
                                              the difference between minimumAmount and
                                              what the contract's consumption amounted
                                              to.
                                        required:
                                          - type
                                          - minimumAmount
                                          - minimumAmountApplied
                                      - title: Minimum commitment
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - minimum_commitment
                                            description: >-
                                              Discriminator: metadata for a plan-level
                                              minimum_commitment line item.
                                          minimumAmount:
                                            type: number
                                            description: >-
                                              The minimum amount committed for the
                                              plan in the billing period, in cents.
                                          minimumAmountApplied:
                                            type: number
                                            description: >-
                                              The top-up charged by this line item to
                                              reach the committed minimum, in cents:
                                              the difference between minimumAmount and
                                              what the plan's consumption amounted to.
                                        required:
                                          - type
                                          - minimumAmount
                                          - minimumAmountApplied
                                      - title: Custom
                                        type: object
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - custom
                                            description: >-
                                              Discriminator: metadata for a custom
                                              line item.
                                          definitionKey:
                                            type: string
                                            description: >-
                                              The key of the custom charge definition
                                              whose calculator priced the charge,
                                              following the
                                              custom:charge:<slug>:<name> convention.
                                            examples:
                                              - custom:charge:padaria-central:entregas
                                          memory:
                                            type: object
                                            additionalProperties: true
                                            description: >-
                                              The full calculation memory that the
                                              calculator returned, such as every tier
                                              it evaluated and the one it billed. Its
                                              shape belongs to the definition.
                                        required:
                                          - type
                                          - definitionKey
                                          - memory
                                      - title: No metadata
                                        type: 'null'
                                  subLineItems:
                                    type: array
                                    items:
                                      type: object
                                      description: >-
                                        Schema representing a sub-line item: one
                                        priced row of a line item's breakdown.
                                        The row type dictates the shape of
                                        metadata.
                                      properties:
                                        id:
                                          type: string
                                          format: uuid
                                          description: >-
                                            The unique identifier of the sub-line
                                            item in our system.
                                        type:
                                          type: string
                                          enum:
                                            - fixed_price
                                            - minimum_amount
                                            - price_tier_flat
                                            - price_tier_unit
                                            - price_tier_package
                                            - price_tier_percentage
                                            - proration
                                            - license_proration
                                            - license_proration_tier
                                            - unit_price
                                            - included_quantity
                                            - package_price
                                            - percentage
                                            - overage
                                            - original_amount
                                            - fixed_unit_price
                                            - custom
                                          description: >-
                                            The kind of priced row: fixed_price and
                                            minimum_amount are companions of
                                            usage-based charges; unit_price,
                                            package_price, percentage, and
                                            included_quantity break down
                                            single-model pricing; price_tier_* rows
                                            break down tiered pricing; overage bills
                                            usage beyond the last tier; proration
                                            bills per prorated interval;
                                            license_proration bills license deltas
                                            (removals are negative); original_amount
                                            surfaces the pre-adjustment amount of an
                                            adjusted line; fixed_unit_price breaks
                                            down a fixed charge billed as a quantity
                                            times a unit amount; custom bills one
                                            component of a custom plan charge.
                                        name:
                                          type: string
                                          description: >-
                                            Display name of the sub-line item as it
                                            appears on the invoice breakdown.
                                          example: '[A partir de 1] Unidades'
                                        description:
                                          type: string
                                          nullable: true
                                          description: >-
                                            Optional descriptive text for the row.
                                            Null when absent.
                                          example: 120 x 2,50
                                        usage:
                                          type: number
                                          nullable: true
                                          description: >-
                                            The usage billed by this row: a count of
                                            resource units (the quantity for a
                                            fixed_unit_price row), or a monetary
                                            base amount in cents for
                                            percentage-priced rows (see the row's
                                            usageFormat, or the line item
                                            usageFormat when the row has none). Null
                                            for rows without usage (e.g.
                                            companions).
                                        usageFormat:
                                          type: string
                                          enum:
                                            - unit
                                            - currency
                                            - null
                                          nullable: true
                                          description: >-
                                            How to read the usage of this row when
                                            the row has a format of its own, as the
                                            custom rows of a custom line item do:
                                            unit means a count, currency means an
                                            amount in cents. Null when the row reads
                                            its usage in the line item usageFormat.
                                        amount:
                                          type: number
                                          description: >-
                                            Amount billed by this row, in cents. The
                                            sum of a line item's sub-line amounts
                                            equals its subtotalAmount.
                                        metadata:
                                          description: >-
                                            Pricing details of the row, keyed by the
                                            row type (and pricingType for overage
                                            rows).
                                          anyOf:
                                            - type: object
                                              description: >-
                                                Fixed-price companion row: the charge's
                                                configured fixed amount, billed
                                                alongside the usage rows. Only rendered
                                                when configured greater than zero.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - fixed_price
                                                  description: >-
                                                    Discriminator: fixed-price companion
                                                    row.
                                                fixedPrice:
                                                  type: number
                                                  description: >-
                                                    The fixed amount configured on the
                                                    charge, in cents.
                                              required:
                                                - type
                                                - fixedPrice
                                            - type: object
                                              description: >-
                                                Minimum-amount companion row: tops the
                                                charge up to its configured minimum when
                                                usage alone stays below it. Only
                                                rendered when the top-up is greater than
                                                zero.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - minimum_amount
                                                  description: >-
                                                    Discriminator: minimum-amount companion
                                                    row.
                                                minimumAmount:
                                                  type: number
                                                  description: >-
                                                    The minimum amount configured on the
                                                    charge, in cents.
                                                minimumAmountApplied:
                                                  type: number
                                                  description: >-
                                                    The top-up billed by this row to reach
                                                    the configured minimum, in cents.
                                              required:
                                                - type
                                                - minimumAmount
                                                - minimumAmountApplied
                                            - type: object
                                              description: >-
                                                Flat-priced tier row: usage falling in
                                                this tier band is billed at a flat
                                                amount, regardless of the exact
                                                quantity.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - price_tier_flat
                                                  description: 'Discriminator: flat-priced tier row.'
                                                from:
                                                  type: number
                                                  description: >-
                                                    Lower bound of the tier band, in
                                                    resource units (inclusive).
                                                to:
                                                  type: number
                                                  nullable: true
                                                  description: >-
                                                    Upper bound of the tier band, in
                                                    resource units (inclusive). Null for an
                                                    unbounded final tier.
                                                fixedPrice:
                                                  type: string
                                                  description: >-
                                                    The flat amount billed for the tier, as
                                                    a decimal currency-unit string.
                                                  examples:
                                                    - '150.00'
                                              required:
                                                - type
                                                - from
                                                - to
                                                - fixedPrice
                                            - type: object
                                              description: >-
                                                Per-unit priced tier row: units
                                                attributed to this tier band are billed
                                                at the tier's unit price.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - price_tier_unit
                                                  description: 'Discriminator: per-unit priced tier row.'
                                                from:
                                                  type: number
                                                  description: >-
                                                    Lower bound of the tier band, in
                                                    resource units (inclusive).
                                                to:
                                                  type: number
                                                  nullable: true
                                                  description: >-
                                                    Upper bound of the tier band, in
                                                    resource units (inclusive). Null for an
                                                    unbounded final tier.
                                                price:
                                                  type: string
                                                  description: >-
                                                    Price per unit within the tier, as a
                                                    decimal currency-unit string.
                                                  examples:
                                                    - '0.25'
                                                fixedPrice:
                                                  type: string
                                                  nullable: true
                                                  description: >-
                                                    Optional flat fee billed on top when the
                                                    tier applies, as a decimal currency-unit
                                                    string. Null when the tier has no flat
                                                    fee.
                                                  examples:
                                                    - '10.00'
                                              required:
                                                - type
                                                - from
                                                - to
                                                - price
                                                - fixedPrice
                                            - type: object
                                              description: >-
                                                Package-priced tier row: units
                                                attributed to this tier band are billed
                                                per started package of packageSize
                                                units.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - price_tier_package
                                                  description: 'Discriminator: package-priced tier row.'
                                                from:
                                                  type: number
                                                  description: >-
                                                    Lower bound of the tier band, in
                                                    resource units (inclusive).
                                                to:
                                                  type: number
                                                  nullable: true
                                                  description: >-
                                                    Upper bound of the tier band, in
                                                    resource units (inclusive). Null for an
                                                    unbounded final tier.
                                                packageSize:
                                                  type: number
                                                  description: Number of resource units per package.
                                                price:
                                                  type: string
                                                  description: >-
                                                    Price per package, as a decimal
                                                    currency-unit string.
                                                  examples:
                                                    - '45.00'
                                              required:
                                                - type
                                                - from
                                                - to
                                                - packageSize
                                                - price
                                            - type: object
                                              description: >-
                                                Percentage-priced tier row: the monetary
                                                base amount attributed to this tier band
                                                is billed at a percentage.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - price_tier_percentage
                                                  description: >-
                                                    Discriminator: percentage-priced tier
                                                    row.
                                                from:
                                                  type: number
                                                  description: >-
                                                    Lower bound of the tier band, in cents
                                                    of the monetary base amount (inclusive).
                                                to:
                                                  type: number
                                                  nullable: true
                                                  description: >-
                                                    Upper bound of the tier band, in cents
                                                    of the monetary base amount (inclusive).
                                                    Null for an unbounded final tier.
                                                percentage:
                                                  type: string
                                                  pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                  description: >-
                                                    Percentage applied to the base amount
                                                    within the tier, as a decimal string
                                                    from 0 to 100 (up to 6 decimal places).
                                                  examples:
                                                    - '2.5'
                                              required:
                                                - type
                                                - from
                                                - to
                                                - percentage
                                            - type: object
                                              description: >-
                                                Proration interval row: for charges on
                                                prorated resources, each interval bills
                                                the usage held during it, priced as if
                                                held for the whole cycle and scaled by
                                                the interval's share of the cycle.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - proration
                                                  description: 'Discriminator: proration interval row.'
                                                intervalSize:
                                                  type: number
                                                  description: >-
                                                    Length of the interval, in days of the
                                                    billing cycle.
                                                amount:
                                                  type: string
                                                  description: >-
                                                    The prorated amount of the interval, as
                                                    a decimal currency-unit string: the
                                                    interval usage priced as if held for the
                                                    whole cycle, scaled by intervalSize over
                                                    the cycle length.
                                                  examples:
                                                    - '29.0322580645'
                                                usage:
                                                  type: number
                                                  description: The usage held during the interval.
                                                intervalStart:
                                                  type: string
                                                  format: date
                                                  description: First day of the interval.
                                                intervalEnd:
                                                  type: string
                                                  format: date
                                                  description: Last day of the interval.
                                              required:
                                                - type
                                                - intervalSize
                                                - amount
                                                - usage
                                                - intervalStart
                                                - intervalEnd
                                            - type: object
                                              description: >-
                                                License proration delta row: for
                                                per_unit license charges billing under
                                                the proration model, the cycle-start row
                                                bills the starting licenses beyond the
                                                included quantity at their full-cycle
                                                price, and each change row bills the
                                                change in those licenses prorated over
                                                the days remaining in the cycle. A
                                                change that stays inside the included
                                                quantity has no row. Tiered charges use
                                                license_proration_tier instead.
                                                quantityDelta and the row's amount are
                                                signed — removals are negative.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - license_proration
                                                  description: >-
                                                    Discriminator: license proration delta
                                                    row.
                                                changeDate:
                                                  type: string
                                                  format: date
                                                  nullable: true
                                                  description: >-
                                                    The day the combined license quantity
                                                    changed. Null on the cycle-start row.
                                                quantityDelta:
                                                  type: number
                                                  description: >-
                                                    Signed change in the licenses beyond the
                                                    included quantity (the starting licenses
                                                    beyond it on the cycle-start row).
                                                    Negative for removals.
                                                quantity:
                                                  type: number
                                                  description: >-
                                                    The combined license quantity after this
                                                    change.
                                                remainingDays:
                                                  type: number
                                                  description: >-
                                                    Days from the change (inclusive) to the
                                                    end of the cycle. Equals cycleDays on
                                                    the cycle-start row.
                                                cycleDays:
                                                  type: number
                                                  description: Length of the billing cycle, in days.
                                                proratedUnitRate:
                                                  type: string
                                                  description: >-
                                                    Absolute effective per-unit rate of the
                                                    row over the remaining window, as a
                                                    decimal currency-unit string: |amount| /
                                                    |quantityDelta|. On a cycle-start row
                                                    that bills no license, the unit price of
                                                    the charge.
                                                  examples:
                                                    - '16.1290322581'
                                                amount:
                                                  type: string
                                                  description: >-
                                                    The signed prorated amount of the row,
                                                    as a decimal currency-unit string.
                                                  examples:
                                                    - '48.3870967742'
                                              required:
                                                - type
                                                - changeDate
                                                - quantityDelta
                                                - quantity
                                                - remainingDays
                                                - cycleDays
                                                - proratedUnitRate
                                                - amount
                                            - type: object
                                              description: >-
                                                Tiered license proration delta row: one
                                                price band of a license charge billing
                                                under the proration model with
                                                tiered_per_unit pricing. The cycle-start
                                                rows bill each band's opening occupancy
                                                at its full-cycle unit price, and each
                                                change row bills that band's occupancy
                                                delta prorated over the days remaining
                                                in the cycle. quantityDelta and the
                                                row's amount are signed — removals are
                                                negative.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - license_proration_tier
                                                  description: >-
                                                    Discriminator: tiered license proration
                                                    delta row.
                                                changeDate:
                                                  type: string
                                                  format: date
                                                  nullable: true
                                                  description: >-
                                                    The day the combined license quantity
                                                    changed. Null on a cycle-start row.
                                                quantityDelta:
                                                  type: number
                                                  description: >-
                                                    Signed change in the units this band
                                                    holds (the band's opening occupancy on a
                                                    cycle-start row). Negative for removals.
                                                quantity:
                                                  type: number
                                                  description: >-
                                                    The combined license quantity across
                                                    every band after this change.
                                                remainingDays:
                                                  type: number
                                                  description: >-
                                                    Days from the change (inclusive) to the
                                                    end of the cycle. Equals cycleDays on a
                                                    cycle-start row.
                                                cycleDays:
                                                  type: number
                                                  description: Length of the billing cycle, in days.
                                                proratedUnitRate:
                                                  type: string
                                                  description: >-
                                                    Absolute effective per-unit rate of the
                                                    row over the remaining window, as a
                                                    decimal currency-unit string: |amount| /
                                                    |quantityDelta|.
                                                  examples:
                                                    - '16.1290322581'
                                                amount:
                                                  type: string
                                                  description: >-
                                                    The signed prorated amount of the row,
                                                    as a decimal currency-unit string.
                                                  examples:
                                                    - '48.3870967742'
                                                planChargeTierId:
                                                  type: string
                                                  description: >-
                                                    The unique identifier of the plan charge
                                                    tier this row moved through.
                                                  examples:
                                                    - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                                from:
                                                  type: number
                                                  description: >-
                                                    Inclusive lower bound of the band, in
                                                    licenses.
                                                to:
                                                  type: number
                                                  nullable: true
                                                  description: >-
                                                    Inclusive upper bound of the band, in
                                                    licenses. Null on the last, open-ended
                                                    band.
                                                unitPrice:
                                                  type: string
                                                  description: >-
                                                    The band's full-cycle price per unit, as
                                                    a decimal currency-unit string.
                                                    proratedUnitRate is this scaled by
                                                    remainingDays over cycleDays.
                                                  examples:
                                                    - '25.00'
                                              required:
                                                - type
                                                - changeDate
                                                - quantityDelta
                                                - quantity
                                                - remainingDays
                                                - cycleDays
                                                - proratedUnitRate
                                                - amount
                                                - planChargeTierId
                                                - from
                                                - to
                                                - unitPrice
                                            - type: object
                                              description: >-
                                                Unit-price row: billable units
                                                multiplied by a single price per unit.
                                                The row's usage holds the billable
                                                units.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - unit_price
                                                  description: 'Discriminator: unit-price row.'
                                                price:
                                                  type: string
                                                  pattern: ^\d+(\.\d{1,6})?$
                                                  description: >-
                                                    Price per unit, as a decimal
                                                    currency-unit string (up to 6 decimal
                                                    places).
                                                  examples:
                                                    - '0.25'
                                              required:
                                                - type
                                                - price
                                            - type: object
                                              description: >-
                                                Included-quantity row: the free
                                                allotment of the charge. The row's usage
                                                holds the units consumed within the
                                                allotment and its amount is always zero.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - included_quantity
                                                  description: 'Discriminator: included-quantity row.'
                                                includedQuantity:
                                                  type: number
                                                  description: >-
                                                    Number of resource units included at no
                                                    charge before billing starts.
                                              required:
                                                - type
                                                - includedQuantity
                                            - type: object
                                              description: >-
                                                Package-price row: billable units
                                                charged per started package of
                                                packageSize units. The row's usage holds
                                                the billable units.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - package_price
                                                  description: 'Discriminator: package-price row.'
                                                packageSize:
                                                  type: number
                                                  description: Number of resource units per package.
                                                price:
                                                  type: string
                                                  pattern: ^\d+(\.\d{1,6})?$
                                                  description: >-
                                                    Price per package, as a decimal
                                                    currency-unit string (up to 6 decimal
                                                    places).
                                                  examples:
                                                    - '45.00'
                                                packagesBilled:
                                                  type: number
                                                  description: >-
                                                    Number of packages billed: the billable
                                                    units divided by packageSize, rounded
                                                    up.
                                              required:
                                                - type
                                                - packageSize
                                                - price
                                                - packagesBilled
                                            - type: object
                                              description: >-
                                                Percentage row: a percentage applied
                                                over a monetary base amount. The row's
                                                usage holds the base amount, in cents.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - percentage
                                                  description: 'Discriminator: percentage row.'
                                                percentage:
                                                  type: string
                                                  pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                  description: >-
                                                    Percentage applied to the base amount,
                                                    as a decimal string from 0 to 100 (up to
                                                    6 decimal places).
                                                  examples:
                                                    - '2.5'
                                              required:
                                                - type
                                                - percentage
                                            - type: object
                                              description: >-
                                                Per-unit overage row: units beyond the
                                                last tier boundary, billed at the
                                                configured excess unit price. The row's
                                                usage holds the units over the boundary.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - overage
                                                  description: 'Discriminator: overage row.'
                                                pricingType:
                                                  type: string
                                                  enum:
                                                    - per_unit
                                                  description: 'Discriminator: overage billed per unit.'
                                                from:
                                                  type: number
                                                  description: >-
                                                    The boundary the overage starts from:
                                                    the upper bound of the last tier, in
                                                    resource units.
                                                price:
                                                  type: string
                                                  pattern: ^\d+(\.\d{1,6})?$
                                                  description: >-
                                                    Price per excess unit, as a decimal
                                                    currency-unit string (up to 6 decimal
                                                    places).
                                                  examples:
                                                    - '0.30'
                                              required:
                                                - type
                                                - pricingType
                                                - from
                                                - price
                                            - type: object
                                              description: >-
                                                Percentage overage row: the monetary
                                                base amount beyond the last tier
                                                boundary, billed at the configured
                                                excess percentage. The row's usage holds
                                                the base amount over the boundary, in
                                                cents.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - overage
                                                  description: 'Discriminator: overage row.'
                                                pricingType:
                                                  type: string
                                                  enum:
                                                    - percentage
                                                  description: >-
                                                    Discriminator: overage billed as a
                                                    percentage.
                                                from:
                                                  type: number
                                                  description: >-
                                                    The boundary the overage starts from:
                                                    the upper bound of the last tier, in
                                                    cents of the monetary base amount.
                                                percentage:
                                                  type: string
                                                  pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                  description: >-
                                                    Percentage applied to the excess base
                                                    amount, as a decimal string from 0 to
                                                    100 (up to 6 decimal places).
                                                  examples:
                                                    - '1.5'
                                              required:
                                                - type
                                                - pricingType
                                                - from
                                                - percentage
                                            - type: object
                                              description: >-
                                                Original-amount row: surfaces the line
                                                item's pre-adjustment amount when the
                                                line has adjustments (e.g. a discount)
                                                but no price-component rows of its own.
                                                The row's amount equals the line item's
                                                subtotalAmount.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - original_amount
                                                  description: 'Discriminator: original-amount row.'
                                              required:
                                                - type
                                            - type: object
                                              description: >-
                                                Fixed unit price row: the quantity of a
                                                fixed charge multiplied by its unit
                                                amount. The row's usage holds the
                                                quantity.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - fixed_unit_price
                                                  description: 'Discriminator: fixed unit price row.'
                                                amount:
                                                  type: integer
                                                  minimum: 0
                                                  description: Amount of one unit, in cents.
                                              required:
                                                - type
                                                - amount
                                            - type: object
                                              description: >-
                                                Custom row: one component of a custom
                                                plan charge, as its calculator billed
                                                it. The row's name, description, usage,
                                                usageFormat and amount hold the rest of
                                                the component.
                                              properties:
                                                type:
                                                  type: string
                                                  enum:
                                                    - custom
                                                  description: 'Discriminator: custom row.'
                                                key:
                                                  type: string
                                                  description: >-
                                                    The key of the component in the sub-line
                                                    schema of the charge's custom charge
                                                    definition, such as documents_overage.
                                                  examples:
                                                    - documents_overage
                                              required:
                                                - type
                                                - key
                                      required:
                                        - id
                                        - type
                                        - name
                                        - description
                                        - usage
                                        - usageFormat
                                        - amount
                                        - metadata
                                      additionalProperties: false
                                    description: >-
                                      Breakdown of the line item amount into
                                      priced rows (included quantities,
                                      unit/package/tier prices, prorations,
                                      companions). Empty for line items without
                                      a breakdown.
                                  adjustments:
                                    type: array
                                    items:
                                      type: object
                                      description: >-
                                        Schema representing an adjustment
                                        applied on top of a line item subtotal,
                                        such as a discount or an allocation
                                        offset.
                                      properties:
                                        id:
                                          type: string
                                          format: uuid
                                          description: >-
                                            The unique identifier of the adjustment
                                            in our system.
                                        name:
                                          type: string
                                          description: >-
                                            Display name of the adjustment as it
                                            appears on the invoice.
                                          example: Desconto de boas-vindas
                                        type:
                                          type: string
                                          enum:
                                            - monetary_discount
                                            - allocation_offset
                                          description: >-
                                            The kind of adjustment:
                                            monetary_discount (a discount applied to
                                            the line item) or allocation_offset (the
                                            share of the amount moved to another
                                            payment account's invoice under a split
                                            allocation strategy).
                                        amount:
                                          type: number
                                          description: >-
                                            Amount of the adjustment, in cents.
                                            Negative when the adjustment reduces the
                                            line item total.
                                      required:
                                        - id
                                        - name
                                        - type
                                        - amount
                                      additionalProperties: false
                                    description: >-
                                      Adjustments applied on top of the line
                                      item subtotal, such as discounts and
                                      allocation offsets.
                                required:
                                  - id
                                  - idempotencyKey
                                  - customerId
                                  - productId
                                  - resourceId
                                  - licenseId
                                  - lineItemGroupId
                                  - name
                                  - scope
                                  - startDate
                                  - endDate
                                  - totalUsage
                                  - usageFormat
                                  - subtotalAmount
                                  - adjustmentAmount
                                  - totalAmount
                                  - discountAmount
                                  - metadata
                                  - subLineItems
                                  - adjustments
                                additionalProperties: false
                              description: The line items contained in this group.
                          required:
                            - id
                            - idempotencyKey
                            - customerId
                            - productId
                            - planId
                            - planInstanceId
                            - name
                            - startDate
                            - endDate
                            - subtotalAmount
                            - adjustmentAmount
                            - totalAmount
                            - discountAmount
                            - lineItems
                          additionalProperties: false
                        description: >-
                          Line item groups on the invoice. Each group gathers
                          the line items generated from one plan instance (or
                          created as a group on one-off invoices).
                      standaloneLineItems:
                        type: array
                        items:
                          type: object
                          description: >-
                            One amount on an invoice, such as a plan charge, the
                            contract minimum, a tax gross-up (the withheld ISS,
                            the municipal service tax, added on top), a one-off
                            amount or an additional charge.
                          properties:
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the line item in our
                                system.
                            idempotencyKey:
                              type: string
                              description: >-
                                A unique key that identifies the line item
                                within the invoice. Supplied by the caller for
                                one-off line items; generated by the billing
                                engine otherwise.
                              example: entrega-novembro
                            customerId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the customer whose
                                consumption this line item bills. On split or
                                consolidated invoices it may be a subsidiary of
                                the invoice's customer.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product this line
                                item belongs to.
                            itemId:
                              type: string
                              nullable: true
                              format: uuid
                              description: >-
                                The unique identifier of the catalog item this
                                line bills. Null for line items not backed by a
                                catalog item.
                            resourceId:
                              type: string
                              nullable: true
                              format: uuid
                              description: >-
                                The unique identifier of the metered resource
                                behind a usage_based line item. Null for line
                                items not driven by resource usage.
                            licenseId:
                              type: string
                              nullable: true
                              format: uuid
                              description: >-
                                The unique identifier of the license behind a
                                license_based line item. Null for line items not
                                driven by a license count.
                            lineItemGroupId:
                              type: string
                              nullable: true
                              format: uuid
                              description: >-
                                The unique identifier of the line item group
                                containing this line item. Null for standalone
                                line items.
                            name:
                              type: string
                              description: >-
                                Display name of the line item as it appears on
                                the invoice.
                              example: Entregas
                            scope:
                              type: string
                              enum:
                                - credit_purchase
                                - contract_minimum_commitment
                                - minimum_commitment
                                - fixed
                                - usage_based
                                - license_based
                                - custom
                                - additional_charge
                                - one_off
                                - tax_gross_up
                              description: >-
                                What the line item charges for: usage_based
                                (metered resource consumption), license_based (a
                                license's reported count billed in full), fixed
                                (recurring fixed charge of a plan), custom
                                (custom plan charge, priced by a calculator that
                                Aira writes for you), minimum_commitment
                                (plan-level minimum top-up),
                                contract_minimum_commitment (contract-level
                                minimum top-up), credit_purchase (credit pool
                                top-up), additional_charge (extra charge added
                                manually), one_off (line item of a one-off
                                invoice), or tax_gross_up (tax gross-up charge).
                            startDate:
                              type: string
                              format: date
                              description: Start of the period covered by this line item.
                            endDate:
                              type: string
                              format: date
                              description: End of the period covered by this line item.
                            totalUsage:
                              type: number
                              nullable: true
                              description: >-
                                Total usage billed by the line item, in the unit
                                given by usageFormat. Null for line items
                                without a single usage (e.g. fixed charges
                                without a quantity, and custom line items whose
                                calculator returns no total).
                            usageFormat:
                              type: string
                              enum:
                                - unit
                                - currency
                                - null
                              nullable: true
                              description: >-
                                How to read totalUsage, and the usage of each
                                sub-line item that has no usageFormat of its
                                own: unit means a count of resource units or a
                                fixed charge quantity; currency means a monetary
                                base amount in cents. Null when the line item
                                has no single usage, as a custom line item whose
                                sub-line items bill different kinds of volume,
                                each with its own usageFormat.
                            subtotalAmount:
                              type: number
                              description: >-
                                Line item amount before adjustments, in cents
                                (sum of its sub-line item amounts).
                            adjustmentAmount:
                              type: number
                              description: >-
                                Net amount of the adjustments applied to this
                                line item (discounts and allocation offsets), in
                                cents. Negative when adjustments reduce the
                                amount owed.
                            totalAmount:
                              type: number
                              description: >-
                                Final line item amount, in cents: subtotalAmount
                                + adjustmentAmount.
                            discountAmount:
                              type: number
                              description: >-
                                The discount portion of adjustmentAmount, in
                                cents (sum of monetary discount adjustments
                                only). Negative when discounts were applied.
                            metadata:
                              description: >-
                                Pricing metadata for the line item, where the
                                shape is keyed by type. Always present, but null
                                for line items without pricing metadata:
                                credit_purchase, additional_charge, one_off, and
                                tax_gross_up. It is populated for fixed (the
                                billing timing), usage_based, license_based,
                                minimum_commitment, contract_minimum_commitment,
                                and custom (the definition and the calculation
                                memory) line items.
                              anyOf:
                                - title: Fixed
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - fixed
                                      description: >-
                                        Discriminator: metadata for a fixed line
                                        item.
                                    billingTiming:
                                      type: string
                                      enum:
                                        - in_advance
                                        - in_arrears
                                      description: >-
                                        Whether the fee was billed in advance of
                                        its service period or after it.
                                  required:
                                    - type
                                    - billingTiming
                                - title: Usage-based
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - usage_based
                                      description: >-
                                        Discriminator: metadata for a
                                        usage_based line item.
                                    billingModel:
                                      type: string
                                      enum:
                                        - in_full
                                        - proration
                                      description: >-
                                        How the metered resource accrues over
                                        the billing period: in_full bills the
                                        full usage of the period; proration
                                        weighs usage by the fraction of the
                                        period each amount was held.
                                    priceTierDivision:
                                      type: string
                                      enum:
                                        - unique_tier
                                        - progressive
                                      description: >-
                                        For tier-based pricing models only: how
                                        usage was divided across tiers.
                                        unique_tier prices all usage at the
                                        single tier that contains the total;
                                        progressive prices each tier's band
                                        separately. Absent for non-tiered
                                        models.
                                    pricingModel:
                                      type: string
                                      enum:
                                        - fixed
                                        - per_unit
                                        - per_package
                                        - percentage
                                        - tiered_per_unit
                                        - tiered_percentage
                                        - tiered_fixed
                                        - advanced
                                        - custom
                                      description: >-
                                        The pricing model of the plan charge
                                        that produced this line item. Charges
                                        priced before pricing models existed are
                                        reported as advanced.
                                  required:
                                    - type
                                    - billingModel
                                    - pricingModel
                                - title: License-based
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - license_based
                                      description: >-
                                        Discriminator: metadata for a
                                        license_based line item.
                                    billingModel:
                                      type: string
                                      enum:
                                        - in_full
                                        - proration
                                      description: >-
                                        How the license count accrues over the
                                        billing period. Always in_full: the
                                        latest reported count is billed in full.
                                    priceTierDivision:
                                      type: string
                                      enum:
                                        - unique_tier
                                        - progressive
                                      description: >-
                                        For tier-based pricing models only: how
                                        the license count was divided across
                                        tiers. unique_tier prices the whole
                                        count at the single tier that contains
                                        the total; progressive prices each
                                        tier's band separately. Absent for
                                        non-tiered models.
                                    pricingModel:
                                      type: string
                                      enum:
                                        - fixed
                                        - per_unit
                                        - per_package
                                        - percentage
                                        - tiered_per_unit
                                        - tiered_percentage
                                        - tiered_fixed
                                        - advanced
                                        - custom
                                      description: >-
                                        The pricing model of the plan charge
                                        that produced this line item.
                                  required:
                                    - type
                                    - billingModel
                                    - pricingModel
                                - title: Contract minimum commitment
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - contract_minimum_commitment
                                      description: >-
                                        Discriminator: metadata for a
                                        contract_minimum_commitment line item.
                                    minimumAmount:
                                      type: number
                                      description: >-
                                        The minimum amount committed for the
                                        whole contract in the billing period, in
                                        cents.
                                    minimumAmountApplied:
                                      type: number
                                      description: >-
                                        The top-up charged by this line item to
                                        reach the committed minimum, in cents:
                                        the difference between minimumAmount and
                                        what the contract's consumption amounted
                                        to.
                                  required:
                                    - type
                                    - minimumAmount
                                    - minimumAmountApplied
                                - title: Minimum commitment
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - minimum_commitment
                                      description: >-
                                        Discriminator: metadata for a plan-level
                                        minimum_commitment line item.
                                    minimumAmount:
                                      type: number
                                      description: >-
                                        The minimum amount committed for the
                                        plan in the billing period, in cents.
                                    minimumAmountApplied:
                                      type: number
                                      description: >-
                                        The top-up charged by this line item to
                                        reach the committed minimum, in cents:
                                        the difference between minimumAmount and
                                        what the plan's consumption amounted to.
                                  required:
                                    - type
                                    - minimumAmount
                                    - minimumAmountApplied
                                - title: Custom
                                  type: object
                                  properties:
                                    type:
                                      type: string
                                      enum:
                                        - custom
                                      description: >-
                                        Discriminator: metadata for a custom
                                        line item.
                                    definitionKey:
                                      type: string
                                      description: >-
                                        The key of the custom charge definition
                                        whose calculator priced the charge,
                                        following the
                                        custom:charge:<slug>:<name> convention.
                                      examples:
                                        - custom:charge:padaria-central:entregas
                                    memory:
                                      type: object
                                      additionalProperties: true
                                      description: >-
                                        The full calculation memory that the
                                        calculator returned, such as every tier
                                        it evaluated and the one it billed. Its
                                        shape belongs to the definition.
                                  required:
                                    - type
                                    - definitionKey
                                    - memory
                                - title: No metadata
                                  type: 'null'
                            subLineItems:
                              type: array
                              items:
                                type: object
                                description: >-
                                  Schema representing a sub-line item: one
                                  priced row of a line item's breakdown. The row
                                  type dictates the shape of metadata.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the sub-line item
                                      in our system.
                                  type:
                                    type: string
                                    enum:
                                      - fixed_price
                                      - minimum_amount
                                      - price_tier_flat
                                      - price_tier_unit
                                      - price_tier_package
                                      - price_tier_percentage
                                      - proration
                                      - license_proration
                                      - license_proration_tier
                                      - unit_price
                                      - included_quantity
                                      - package_price
                                      - percentage
                                      - overage
                                      - original_amount
                                      - fixed_unit_price
                                      - custom
                                    description: >-
                                      The kind of priced row: fixed_price and
                                      minimum_amount are companions of
                                      usage-based charges; unit_price,
                                      package_price, percentage, and
                                      included_quantity break down single-model
                                      pricing; price_tier_* rows break down
                                      tiered pricing; overage bills usage beyond
                                      the last tier; proration bills per
                                      prorated interval; license_proration bills
                                      license deltas (removals are negative);
                                      original_amount surfaces the
                                      pre-adjustment amount of an adjusted line;
                                      fixed_unit_price breaks down a fixed
                                      charge billed as a quantity times a unit
                                      amount; custom bills one component of a
                                      custom plan charge.
                                  name:
                                    type: string
                                    description: >-
                                      Display name of the sub-line item as it
                                      appears on the invoice breakdown.
                                    example: '[A partir de 1] Unidades'
                                  description:
                                    type: string
                                    nullable: true
                                    description: >-
                                      Optional descriptive text for the row.
                                      Null when absent.
                                    example: 120 x 2,50
                                  usage:
                                    type: number
                                    nullable: true
                                    description: >-
                                      The usage billed by this row: a count of
                                      resource units (the quantity for a
                                      fixed_unit_price row), or a monetary base
                                      amount in cents for percentage-priced rows
                                      (see the row's usageFormat, or the line
                                      item usageFormat when the row has none).
                                      Null for rows without usage (e.g.
                                      companions).
                                  usageFormat:
                                    type: string
                                    enum:
                                      - unit
                                      - currency
                                      - null
                                    nullable: true
                                    description: >-
                                      How to read the usage of this row when the
                                      row has a format of its own, as the custom
                                      rows of a custom line item do: unit means
                                      a count, currency means an amount in
                                      cents. Null when the row reads its usage
                                      in the line item usageFormat.
                                  amount:
                                    type: number
                                    description: >-
                                      Amount billed by this row, in cents. The
                                      sum of a line item's sub-line amounts
                                      equals its subtotalAmount.
                                  metadata:
                                    description: >-
                                      Pricing details of the row, keyed by the
                                      row type (and pricingType for overage
                                      rows).
                                    anyOf:
                                      - type: object
                                        description: >-
                                          Fixed-price companion row: the charge's
                                          configured fixed amount, billed
                                          alongside the usage rows. Only rendered
                                          when configured greater than zero.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - fixed_price
                                            description: >-
                                              Discriminator: fixed-price companion
                                              row.
                                          fixedPrice:
                                            type: number
                                            description: >-
                                              The fixed amount configured on the
                                              charge, in cents.
                                        required:
                                          - type
                                          - fixedPrice
                                      - type: object
                                        description: >-
                                          Minimum-amount companion row: tops the
                                          charge up to its configured minimum when
                                          usage alone stays below it. Only
                                          rendered when the top-up is greater than
                                          zero.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - minimum_amount
                                            description: >-
                                              Discriminator: minimum-amount companion
                                              row.
                                          minimumAmount:
                                            type: number
                                            description: >-
                                              The minimum amount configured on the
                                              charge, in cents.
                                          minimumAmountApplied:
                                            type: number
                                            description: >-
                                              The top-up billed by this row to reach
                                              the configured minimum, in cents.
                                        required:
                                          - type
                                          - minimumAmount
                                          - minimumAmountApplied
                                      - type: object
                                        description: >-
                                          Flat-priced tier row: usage falling in
                                          this tier band is billed at a flat
                                          amount, regardless of the exact
                                          quantity.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - price_tier_flat
                                            description: 'Discriminator: flat-priced tier row.'
                                          from:
                                            type: number
                                            description: >-
                                              Lower bound of the tier band, in
                                              resource units (inclusive).
                                          to:
                                            type: number
                                            nullable: true
                                            description: >-
                                              Upper bound of the tier band, in
                                              resource units (inclusive). Null for an
                                              unbounded final tier.
                                          fixedPrice:
                                            type: string
                                            description: >-
                                              The flat amount billed for the tier, as
                                              a decimal currency-unit string.
                                            examples:
                                              - '150.00'
                                        required:
                                          - type
                                          - from
                                          - to
                                          - fixedPrice
                                      - type: object
                                        description: >-
                                          Per-unit priced tier row: units
                                          attributed to this tier band are billed
                                          at the tier's unit price.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - price_tier_unit
                                            description: 'Discriminator: per-unit priced tier row.'
                                          from:
                                            type: number
                                            description: >-
                                              Lower bound of the tier band, in
                                              resource units (inclusive).
                                          to:
                                            type: number
                                            nullable: true
                                            description: >-
                                              Upper bound of the tier band, in
                                              resource units (inclusive). Null for an
                                              unbounded final tier.
                                          price:
                                            type: string
                                            description: >-
                                              Price per unit within the tier, as a
                                              decimal currency-unit string.
                                            examples:
                                              - '0.25'
                                          fixedPrice:
                                            type: string
                                            nullable: true
                                            description: >-
                                              Optional flat fee billed on top when the
                                              tier applies, as a decimal currency-unit
                                              string. Null when the tier has no flat
                                              fee.
                                            examples:
                                              - '10.00'
                                        required:
                                          - type
                                          - from
                                          - to
                                          - price
                                          - fixedPrice
                                      - type: object
                                        description: >-
                                          Package-priced tier row: units
                                          attributed to this tier band are billed
                                          per started package of packageSize
                                          units.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - price_tier_package
                                            description: 'Discriminator: package-priced tier row.'
                                          from:
                                            type: number
                                            description: >-
                                              Lower bound of the tier band, in
                                              resource units (inclusive).
                                          to:
                                            type: number
                                            nullable: true
                                            description: >-
                                              Upper bound of the tier band, in
                                              resource units (inclusive). Null for an
                                              unbounded final tier.
                                          packageSize:
                                            type: number
                                            description: Number of resource units per package.
                                          price:
                                            type: string
                                            description: >-
                                              Price per package, as a decimal
                                              currency-unit string.
                                            examples:
                                              - '45.00'
                                        required:
                                          - type
                                          - from
                                          - to
                                          - packageSize
                                          - price
                                      - type: object
                                        description: >-
                                          Percentage-priced tier row: the monetary
                                          base amount attributed to this tier band
                                          is billed at a percentage.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - price_tier_percentage
                                            description: >-
                                              Discriminator: percentage-priced tier
                                              row.
                                          from:
                                            type: number
                                            description: >-
                                              Lower bound of the tier band, in cents
                                              of the monetary base amount (inclusive).
                                          to:
                                            type: number
                                            nullable: true
                                            description: >-
                                              Upper bound of the tier band, in cents
                                              of the monetary base amount (inclusive).
                                              Null for an unbounded final tier.
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              Percentage applied to the base amount
                                              within the tier, as a decimal string
                                              from 0 to 100 (up to 6 decimal places).
                                            examples:
                                              - '2.5'
                                        required:
                                          - type
                                          - from
                                          - to
                                          - percentage
                                      - type: object
                                        description: >-
                                          Proration interval row: for charges on
                                          prorated resources, each interval bills
                                          the usage held during it, priced as if
                                          held for the whole cycle and scaled by
                                          the interval's share of the cycle.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - proration
                                            description: 'Discriminator: proration interval row.'
                                          intervalSize:
                                            type: number
                                            description: >-
                                              Length of the interval, in days of the
                                              billing cycle.
                                          amount:
                                            type: string
                                            description: >-
                                              The prorated amount of the interval, as
                                              a decimal currency-unit string: the
                                              interval usage priced as if held for the
                                              whole cycle, scaled by intervalSize over
                                              the cycle length.
                                            examples:
                                              - '29.0322580645'
                                          usage:
                                            type: number
                                            description: The usage held during the interval.
                                          intervalStart:
                                            type: string
                                            format: date
                                            description: First day of the interval.
                                          intervalEnd:
                                            type: string
                                            format: date
                                            description: Last day of the interval.
                                        required:
                                          - type
                                          - intervalSize
                                          - amount
                                          - usage
                                          - intervalStart
                                          - intervalEnd
                                      - type: object
                                        description: >-
                                          License proration delta row: for
                                          per_unit license charges billing under
                                          the proration model, the cycle-start row
                                          bills the starting licenses beyond the
                                          included quantity at their full-cycle
                                          price, and each change row bills the
                                          change in those licenses prorated over
                                          the days remaining in the cycle. A
                                          change that stays inside the included
                                          quantity has no row. Tiered charges use
                                          license_proration_tier instead.
                                          quantityDelta and the row's amount are
                                          signed — removals are negative.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - license_proration
                                            description: >-
                                              Discriminator: license proration delta
                                              row.
                                          changeDate:
                                            type: string
                                            format: date
                                            nullable: true
                                            description: >-
                                              The day the combined license quantity
                                              changed. Null on the cycle-start row.
                                          quantityDelta:
                                            type: number
                                            description: >-
                                              Signed change in the licenses beyond the
                                              included quantity (the starting licenses
                                              beyond it on the cycle-start row).
                                              Negative for removals.
                                          quantity:
                                            type: number
                                            description: >-
                                              The combined license quantity after this
                                              change.
                                          remainingDays:
                                            type: number
                                            description: >-
                                              Days from the change (inclusive) to the
                                              end of the cycle. Equals cycleDays on
                                              the cycle-start row.
                                          cycleDays:
                                            type: number
                                            description: Length of the billing cycle, in days.
                                          proratedUnitRate:
                                            type: string
                                            description: >-
                                              Absolute effective per-unit rate of the
                                              row over the remaining window, as a
                                              decimal currency-unit string: |amount| /
                                              |quantityDelta|. On a cycle-start row
                                              that bills no license, the unit price of
                                              the charge.
                                            examples:
                                              - '16.1290322581'
                                          amount:
                                            type: string
                                            description: >-
                                              The signed prorated amount of the row,
                                              as a decimal currency-unit string.
                                            examples:
                                              - '48.3870967742'
                                        required:
                                          - type
                                          - changeDate
                                          - quantityDelta
                                          - quantity
                                          - remainingDays
                                          - cycleDays
                                          - proratedUnitRate
                                          - amount
                                      - type: object
                                        description: >-
                                          Tiered license proration delta row: one
                                          price band of a license charge billing
                                          under the proration model with
                                          tiered_per_unit pricing. The cycle-start
                                          rows bill each band's opening occupancy
                                          at its full-cycle unit price, and each
                                          change row bills that band's occupancy
                                          delta prorated over the days remaining
                                          in the cycle. quantityDelta and the
                                          row's amount are signed — removals are
                                          negative.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - license_proration_tier
                                            description: >-
                                              Discriminator: tiered license proration
                                              delta row.
                                          changeDate:
                                            type: string
                                            format: date
                                            nullable: true
                                            description: >-
                                              The day the combined license quantity
                                              changed. Null on a cycle-start row.
                                          quantityDelta:
                                            type: number
                                            description: >-
                                              Signed change in the units this band
                                              holds (the band's opening occupancy on a
                                              cycle-start row). Negative for removals.
                                          quantity:
                                            type: number
                                            description: >-
                                              The combined license quantity across
                                              every band after this change.
                                          remainingDays:
                                            type: number
                                            description: >-
                                              Days from the change (inclusive) to the
                                              end of the cycle. Equals cycleDays on a
                                              cycle-start row.
                                          cycleDays:
                                            type: number
                                            description: Length of the billing cycle, in days.
                                          proratedUnitRate:
                                            type: string
                                            description: >-
                                              Absolute effective per-unit rate of the
                                              row over the remaining window, as a
                                              decimal currency-unit string: |amount| /
                                              |quantityDelta|.
                                            examples:
                                              - '16.1290322581'
                                          amount:
                                            type: string
                                            description: >-
                                              The signed prorated amount of the row,
                                              as a decimal currency-unit string.
                                            examples:
                                              - '48.3870967742'
                                          planChargeTierId:
                                            type: string
                                            description: >-
                                              The unique identifier of the plan charge
                                              tier this row moved through.
                                            examples:
                                              - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                          from:
                                            type: number
                                            description: >-
                                              Inclusive lower bound of the band, in
                                              licenses.
                                          to:
                                            type: number
                                            nullable: true
                                            description: >-
                                              Inclusive upper bound of the band, in
                                              licenses. Null on the last, open-ended
                                              band.
                                          unitPrice:
                                            type: string
                                            description: >-
                                              The band's full-cycle price per unit, as
                                              a decimal currency-unit string.
                                              proratedUnitRate is this scaled by
                                              remainingDays over cycleDays.
                                            examples:
                                              - '25.00'
                                        required:
                                          - type
                                          - changeDate
                                          - quantityDelta
                                          - quantity
                                          - remainingDays
                                          - cycleDays
                                          - proratedUnitRate
                                          - amount
                                          - planChargeTierId
                                          - from
                                          - to
                                          - unitPrice
                                      - type: object
                                        description: >-
                                          Unit-price row: billable units
                                          multiplied by a single price per unit.
                                          The row's usage holds the billable
                                          units.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - unit_price
                                            description: 'Discriminator: unit-price row.'
                                          price:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              Price per unit, as a decimal
                                              currency-unit string (up to 6 decimal
                                              places).
                                            examples:
                                              - '0.25'
                                        required:
                                          - type
                                          - price
                                      - type: object
                                        description: >-
                                          Included-quantity row: the free
                                          allotment of the charge. The row's usage
                                          holds the units consumed within the
                                          allotment and its amount is always zero.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - included_quantity
                                            description: 'Discriminator: included-quantity row.'
                                          includedQuantity:
                                            type: number
                                            description: >-
                                              Number of resource units included at no
                                              charge before billing starts.
                                        required:
                                          - type
                                          - includedQuantity
                                      - type: object
                                        description: >-
                                          Package-price row: billable units
                                          charged per started package of
                                          packageSize units. The row's usage holds
                                          the billable units.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - package_price
                                            description: 'Discriminator: package-price row.'
                                          packageSize:
                                            type: number
                                            description: Number of resource units per package.
                                          price:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              Price per package, as a decimal
                                              currency-unit string (up to 6 decimal
                                              places).
                                            examples:
                                              - '45.00'
                                          packagesBilled:
                                            type: number
                                            description: >-
                                              Number of packages billed: the billable
                                              units divided by packageSize, rounded
                                              up.
                                        required:
                                          - type
                                          - packageSize
                                          - price
                                          - packagesBilled
                                      - type: object
                                        description: >-
                                          Percentage row: a percentage applied
                                          over a monetary base amount. The row's
                                          usage holds the base amount, in cents.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - percentage
                                            description: 'Discriminator: percentage row.'
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              Percentage applied to the base amount,
                                              as a decimal string from 0 to 100 (up to
                                              6 decimal places).
                                            examples:
                                              - '2.5'
                                        required:
                                          - type
                                          - percentage
                                      - type: object
                                        description: >-
                                          Per-unit overage row: units beyond the
                                          last tier boundary, billed at the
                                          configured excess unit price. The row's
                                          usage holds the units over the boundary.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - overage
                                            description: 'Discriminator: overage row.'
                                          pricingType:
                                            type: string
                                            enum:
                                              - per_unit
                                            description: 'Discriminator: overage billed per unit.'
                                          from:
                                            type: number
                                            description: >-
                                              The boundary the overage starts from:
                                              the upper bound of the last tier, in
                                              resource units.
                                          price:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              Price per excess unit, as a decimal
                                              currency-unit string (up to 6 decimal
                                              places).
                                            examples:
                                              - '0.30'
                                        required:
                                          - type
                                          - pricingType
                                          - from
                                          - price
                                      - type: object
                                        description: >-
                                          Percentage overage row: the monetary
                                          base amount beyond the last tier
                                          boundary, billed at the configured
                                          excess percentage. The row's usage holds
                                          the base amount over the boundary, in
                                          cents.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - overage
                                            description: 'Discriminator: overage row.'
                                          pricingType:
                                            type: string
                                            enum:
                                              - percentage
                                            description: >-
                                              Discriminator: overage billed as a
                                              percentage.
                                          from:
                                            type: number
                                            description: >-
                                              The boundary the overage starts from:
                                              the upper bound of the last tier, in
                                              cents of the monetary base amount.
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              Percentage applied to the excess base
                                              amount, as a decimal string from 0 to
                                              100 (up to 6 decimal places).
                                            examples:
                                              - '1.5'
                                        required:
                                          - type
                                          - pricingType
                                          - from
                                          - percentage
                                      - type: object
                                        description: >-
                                          Original-amount row: surfaces the line
                                          item's pre-adjustment amount when the
                                          line has adjustments (e.g. a discount)
                                          but no price-component rows of its own.
                                          The row's amount equals the line item's
                                          subtotalAmount.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - original_amount
                                            description: 'Discriminator: original-amount row.'
                                        required:
                                          - type
                                      - type: object
                                        description: >-
                                          Fixed unit price row: the quantity of a
                                          fixed charge multiplied by its unit
                                          amount. The row's usage holds the
                                          quantity.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - fixed_unit_price
                                            description: 'Discriminator: fixed unit price row.'
                                          amount:
                                            type: integer
                                            minimum: 0
                                            description: Amount of one unit, in cents.
                                        required:
                                          - type
                                          - amount
                                      - type: object
                                        description: >-
                                          Custom row: one component of a custom
                                          plan charge, as its calculator billed
                                          it. The row's name, description, usage,
                                          usageFormat and amount hold the rest of
                                          the component.
                                        properties:
                                          type:
                                            type: string
                                            enum:
                                              - custom
                                            description: 'Discriminator: custom row.'
                                          key:
                                            type: string
                                            description: >-
                                              The key of the component in the sub-line
                                              schema of the charge's custom charge
                                              definition, such as documents_overage.
                                            examples:
                                              - documents_overage
                                        required:
                                          - type
                                          - key
                                required:
                                  - id
                                  - type
                                  - name
                                  - description
                                  - usage
                                  - usageFormat
                                  - amount
                                  - metadata
                                additionalProperties: false
                              description: >-
                                Breakdown of the line item amount into priced
                                rows (included quantities, unit/package/tier
                                prices, prorations, companions). Empty for line
                                items without a breakdown.
                            adjustments:
                              type: array
                              items:
                                type: object
                                description: >-
                                  Schema representing an adjustment applied on
                                  top of a line item subtotal, such as a
                                  discount or an allocation offset.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the adjustment in
                                      our system.
                                  name:
                                    type: string
                                    description: >-
                                      Display name of the adjustment as it
                                      appears on the invoice.
                                    example: Desconto de boas-vindas
                                  type:
                                    type: string
                                    enum:
                                      - monetary_discount
                                      - allocation_offset
                                    description: >-
                                      The kind of adjustment: monetary_discount
                                      (a discount applied to the line item) or
                                      allocation_offset (the share of the amount
                                      moved to another payment account's invoice
                                      under a split allocation strategy).
                                  amount:
                                    type: number
                                    description: >-
                                      Amount of the adjustment, in cents.
                                      Negative when the adjustment reduces the
                                      line item total.
                                required:
                                  - id
                                  - name
                                  - type
                                  - amount
                                additionalProperties: false
                              description: >-
                                Adjustments applied on top of the line item
                                subtotal, such as discounts and allocation
                                offsets.
                          required:
                            - id
                            - idempotencyKey
                            - customerId
                            - productId
                            - resourceId
                            - licenseId
                            - lineItemGroupId
                            - name
                            - scope
                            - startDate
                            - endDate
                            - totalUsage
                            - usageFormat
                            - subtotalAmount
                            - adjustmentAmount
                            - totalAmount
                            - discountAmount
                            - metadata
                            - subLineItems
                            - adjustments
                          additionalProperties: false
                        description: >-
                          Line items that do not belong to any line item group
                          (e.g. contract-level minimum commitments, additional
                          charges, and ungrouped one-off items).
                      customFields:
                        type: object
                        description: >-
                          The values of the custom fields of invoices, keyed by
                          the key of each custom field. The object is empty when
                          the invoice holds no value. A user edits them in the
                          billing app, and `PUT /v1/invoices/{id}/custom-fields`
                          replaces the whole set, in any status of the invoice.
                        additionalProperties:
                          anyOf:
                            - type: string
                            - type: array
                              items:
                                type: string
                        default: {}
                        example:
                          customField1: value1
                          customField2:
                            - value2
                            - value3
                      sentAt:
                        type: string
                        format: date-time
                        nullable: true
                        description: >-
                          When Aira last sent the invoice by e-mail to its
                          invoice recipients, in an invoice delivery. Null when
                          Aira has not sent it.
                      replaceReason:
                        type: string
                        enum:
                          - contract_allocation_changed
                          - manually_reopened
                          - null
                        nullable: true
                        description: >-
                          Why one invoice of the same invoice slot replaced
                          another, on both invoices of the replacement:
                          manually_reopened for a reopening, and
                          contract_allocation_changed when a change to the
                          contract allocation canceled the invoice and a later
                          billing of its billing act replaced it. Null when the
                          invoice replaces no invoice and no invoice replaces
                          it.
                      replacesInvoiceId:
                        type: string
                        format: uuid
                        nullable: true
                        description: >-
                          The unique identifier of the canceled invoice that
                          this invoice replaces in its invoice slot. Null when
                          the invoice replaces no invoice.
                      replacedByInvoiceId:
                        type: string
                        format: uuid
                        nullable: true
                        description: >-
                          The unique identifier of the invoice that replaces
                          this canceled invoice in its invoice slot. Null when
                          no invoice replaces it.
                    required:
                      - id
                      - idempotencyKey
                      - customerId
                      - paymentAccountId
                      - contractId
                      - contractInvoiceSequence
                      - issuingAccount
                      - billingAccount
                      - invoiceAllocationStrategy
                      - lastCalculatedAt
                      - invoiceNumber
                      - invoiceDate
                      - memo
                      - subtotalAmount
                      - adjustmentAmount
                      - totalAmount
                      - discountAmount
                      - status
                      - isLocked
                      - failureReason
                      - source
                      - autoIssue
                      - amountDue
                      - dueDate
                      - lineItemGroups
                      - standaloneLineItems
                      - customFields
                      - sentAt
                      - replaceReason
                      - replacesInvoiceId
                      - replacedByInvoiceId
                    additionalProperties: false
                  payments:
                    type: array
                    items:
                      type: object
                      description: >-
                        A payment: one request to collect the amount of an
                        invoice through a payment provider, with its method, due
                        date and status. An invoice can have several. A payment
                        that the ERP issues and holds is an external payment.
                      properties:
                        id:
                          type: string
                          description: The unique identifier of the payment in our system.
                          example: 3c90c3cc-0d44-4b50-8888-8dd25736052a
                        amount:
                          type: number
                          multipleOf: 1
                          description: Amount charged by the payment, in cents.
                        dueDate:
                          type: string
                          format: date
                          nullable: true
                          description: >-
                            Due date of the payment charge. Null when the
                            payment has no due date.
                        paymentMethod:
                          type: string
                          enum:
                            - bolepix
                            - bank_slip
                            - pix
                            - credit_card
                            - bank_transfer
                          description: >-
                            How the payment is collected: pix, bank_slip
                            (boleto), bolepix (boleto payable via Pix),
                            credit_card, or bank_transfer.
                        status:
                          type: string
                          enum:
                            - created
                            - pending
                            - paid
                            - failed
                            - canceled
                            - expired
                          description: >-
                            Current status of the payment: created (registered
                            at the provider), pending (awaiting settlement),
                            paid, failed, canceled, or expired.
                        provider:
                          type: string
                          enum:
                            - celcash
                            - omie
                            - asaas
                            - contaazul
                          description: The payment provider that collects the payment.
                        paymentLinkUrl:
                          type: string
                          nullable: true
                          description: >-
                            The payment link: the page at the payment provider
                            where the customer pays. Null when the payment
                            provider gave none.
                          example: https://www.asaas.com/i/abc123def456
                      required:
                        - id
                        - amount
                        - dueDate
                        - paymentMethod
                        - status
                        - provider
                        - paymentLinkUrl
                      additionalProperties: false
                    description: >-
                      Payment charges registered for the invoice at the payment
                      provider, when any.
                  statusHistory:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing one status transition in the invoice
                        history, from the most recent to the oldest.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the status transition in
                            our system.
                        previousStatus:
                          type: string
                          enum:
                            - open
                            - in_review
                            - issued
                            - synced
                            - pending
                            - paid
                            - overdue
                            - canceled
                            - failed
                            - null
                          nullable: true
                          description: >-
                            The invoice status before the transition. Null on
                            the first entry (invoice creation).
                        newStatus:
                          type: string
                          enum:
                            - open
                            - in_review
                            - issued
                            - synced
                            - pending
                            - paid
                            - overdue
                            - canceled
                            - failed
                          description: The invoice status after the transition.
                        reason:
                          type: string
                          enum:
                            - invoice_created
                            - billing_cycle_closed
                            - billing_cycle_opened
                            - billing_cycle_canceled
                            - invoice_auto_issued
                            - retroactive_invoice_issued
                            - manually_issued
                            - contract_canceled
                            - manually_canceled
                            - manually_paid
                            - manually_unmarked_as_paid
                            - contract_allocation_removed
                            - erp_sync_failed
                            - payment_initiated
                            - erp_sync_success
                            - payment_failed
                            - payment_paid
                            - due_date_passed
                            - invoice_reopened
                            - invoice_created_after_reopening
                            - manually_canceled_via_api
                            - manually_marked_as_in_review_via_api
                          description: >-
                            What triggered the transition. Values name the
                            trigger event: billing cycle lifecycle (e.g.
                            billing_cycle_closed), issuing (invoice_auto_issued,
                            manually_issued), ERP sync outcomes
                            (erp_sync_success, erp_sync_failed), payment
                            lifecycle (payment_initiated, payment_paid,
                            payment_failed), due date passing (due_date_passed),
                            reopening (invoice_reopened), and manual or
                            API-driven actions (manually_canceled_via_api,
                            manually_marked_as_in_review_via_api).
                        occurredAt:
                          type: string
                          format: date-time
                          description: When the transition happened.
                        metadata:
                          type: object
                          nullable: true
                          additionalProperties: true
                          description: >-
                            Additional context recorded with the transition
                            (e.g. failure details), when available. Null
                            otherwise.
                      required:
                        - id
                        - previousStatus
                        - newStatus
                        - reason
                        - occurredAt
                        - metadata
                      additionalProperties: false
                    description: >-
                      Status transitions of the invoice, from the most recent to
                      the oldest.
                  customer:
                    type: object
                    description: The customer the invoice bills.
                    properties:
                      id:
                        description: The unique identifier of the customer in our system.
                        type: string
                        format: uuid
                      externalId:
                        description: >-
                          The external id of the customer: the key that you give
                          it, which no other customer has. Events and license
                          balances name their customer by it.
                        type: string
                        pattern: ^[a-zA-Z0-9_-]+$
                        example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                      name:
                        description: The name of the customer.
                        type: string
                        example: Acme Inc.
                      invoicePrefix:
                        description: >-
                          The prefix of the numbers of the customer's invoices,
                          which Aira makes from the name of the customer when it
                          creates the customer, and which never changes.
                        type: string
                        example: ACMEI
                      type:
                        description: >-
                          The type of the customer: an `individual`, an
                          `organization`, which groups zero or more
                          subsidiaries, or a `subsidiary`, which belongs to one
                          organization.
                        type: string
                        enum:
                          - individual
                          - organization
                          - subsidiary
                        example: individual
                      parentCustomerId:
                        description: >-
                          The id of the organization that the customer belongs
                          to when it is a subsidiary, or null for an individual
                          or an organization.
                        type:
                          - 'null'
                          - string
                        format: uuid
                      dunningScheduleId:
                        description: >-
                          The id of the dunning schedule that the customer
                          follows, or null when the customer follows none and
                          gets no dunning e-mails.
                        type:
                          - 'null'
                          - string
                        format: uuid
                      archivedAt:
                        description: >-
                          The instant when the customer was archived, or null
                          when it is not archived.
                        type:
                          - 'null'
                          - string
                        format: date-time
                      customFields:
                        type: object
                        description: >-
                          Custom fields that can be associated with the entity.
                          The fields must be previously created in the system
                          before they can be used.
                        additionalProperties:
                          anyOf:
                            - type: string
                            - type: array
                              items:
                                type: string
                        default: {}
                        example:
                          customField1: value1
                          customField2:
                            - value2
                            - value3
                    required:
                      - id
                      - externalId
                      - name
                      - type
                    additionalProperties: false
                  contract:
                    type: object
                    description: >-
                      Summary of the contract that generated the invoice. Null
                      for invoices not generated from a contract.
                    properties:
                      id:
                        description: The unique identifier of the contract in our system.
                        type: string
                        format: uuid
                      contractNumber:
                        type: string
                        description: >-
                          The number of the contract, which Aira gives it on
                          creation from the prefix of its customer and the
                          sequence of the contracts of that customer.
                        example: MERCA-CTR-01
                      customerId:
                        type: string
                        format: uuid
                        description: ID of the customer associated with this contract.
                      legalEntityId:
                        type: string
                        format: uuid
                        nullable: true
                        description: >-
                          ID of the legal entity that issues the invoices of
                          this contract.
                      startDate:
                        description: The start date of the contract.
                        type: string
                        format: date
                      endDate:
                        description: >-
                          The end date of the contract. Null if the contract has
                          no end date.
                        type:
                          - 'null'
                          - string
                        format: date
                      status:
                        description: The current status of the contract.
                        type: string
                        enum:
                          - active
                          - canceled
                          - completed
                          - draft
                      customFields:
                        type: object
                        description: >-
                          Custom fields that can be associated with the entity.
                          The fields must be previously created in the system
                          before they can be used.
                        additionalProperties:
                          anyOf:
                            - type: string
                            - type: array
                              items:
                                type: string
                        default: {}
                        example:
                          customField1: value1
                          customField2:
                            - value2
                            - value3
                    required:
                      - id
                      - contractNumber
                      - customerId
                      - legalEntityId
                      - startDate
                      - endDate
                      - status
                      - customFields
                    additionalProperties: false
                    nullable: true
                  artifacts:
                    type: array
                    items:
                      type: object
                      description: >-
                        A file that Aira generates for an invoice, such as the
                        invoice PDF or a usage statement.
                      properties:
                        id:
                          type: string
                          description: The unique identifier of the artifact in our system.
                          example: 3c90c3cc-0d44-4b50-8888-8dd25736052a
                        artifactType:
                          type: string
                          pattern: '^(default|custom):'
                          description: >-
                            The kind of artifact: `default:*` for an artifact
                            that Aira generates in every setup, such as
                            `default:invoice_pdf`, or `custom:*` for an artifact
                            that Aira writes for you.
                          example: default:invoice_pdf
                        fileExtension:
                          type: string
                          enum:
                            - pdf
                            - csv
                            - xlsx
                            - xlsm
                            - xml
                            - zip
                          description: File extension of the artifact.
                        generatedAt:
                          type: string
                          format: date-time
                          description: When the artifact file was generated.
                      required:
                        - id
                        - artifactType
                        - fileExtension
                        - generatedAt
                      additionalProperties: false
                    description: Files generated for the invoice (e.g. the invoice PDF).
                required:
                  - invoice
                  - payments
                  - statusHistory
                  - customer
                  - contract
                  - artifacts
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''providerId'' must be string'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has an invoice sync with the
            `providerId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/:
    get:
      summary: List invoices
      tags:
        - Invoices
      description: >-
        Lists the invoices that match the filters, in a compact shape, newest
        first by creation time.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
          example: Mercado Bom Preço
          in: query
          name: search
          required: false
          description: >-
            Free-text search over the invoice number, the customer name and the
            names of the customers whose usage the invoice bills, such as the
            subsidiaries of an organization.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: customerIds[]
          required: false
          description: Only return invoices billing these customers.
        - schema:
            type: array
            items:
              type: string
              enum:
                - open
                - in_review
                - issued
                - synced
                - pending
                - paid
                - overdue
                - canceled
                - failed
          in: query
          name: status[]
          required: false
          description: >-
            Only return invoices in these statuses. Canceled invoices are
            controlled by includeCanceled, not by this filter.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeCanceled
          required: false
          description: >-
            When false, canceled invoices are excluded. When true, canceled
            invoices are added to the statuses selected in status[]; if no
            status[] is provided, only canceled invoices are returned.
        - schema:
            type: boolean
            default: false
          in: query
          name: hideZeroAmount
          required: false
          description: When true, invoices with a zero total amount are excluded.
        - schema:
            type: string
            format: date
          in: query
          name: invoiceDate.gte
          required: false
          description: Only return invoices whose invoice date is on or after this date.
        - schema:
            type: string
            format: date
          in: query
          name: invoiceDate.lte
          required: false
          description: Only return invoices whose invoice date is on or before this date.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: contractIds[]
          required: false
          description: Only return the invoices of these contracts.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: productIds[]
          required: false
          description: >-
            Only return the invoices with at least one line item of these
            products.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: paymentAccountIds[]
          required: false
          description: Only return the invoices that bill these payment accounts.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: legalEntityIds[]
          required: false
          description: >-
            Only return the invoices of these legal entities: an invoice of a
            contract when its contract names one of them, and an invoice without
            a contract, such as a one-off invoice, when one of them is the
            default legal entity.
        - schema:
            type: object
            properties:
              contract:
                type: object
                description: >-
                  The custom field values of the contract of the invoice. An
                  invoice without a contract never matches.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
              customer:
                type: object
                description: The custom field values of the customer of the invoice.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
              product:
                type: object
                description: >-
                  The custom field values of a product. An invoice matches when
                  at least one of its line items bills a product that holds
                  them.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
              item:
                type: object
                description: >-
                  The custom field values of an item. An invoice matches when at
                  least one of its line items bills an item that holds them.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
            additionalProperties: false
          in: query
          name: customField
          required: false
          description: >-
            Only return the invoices whose records hold these custom field
            values, keyed by the record and then by the key of the custom field,
            as in `customField[contract][region][]=south`. An invoice matches a
            key when the record holds one of its values, and it matches the
            filter when it matches every key.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_custom_fields
          when: >-
            a key of the `customField` filter names no custom field of its
            record
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: The invoices that match the filters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        Compact invoice representation returned by list
                        endpoints. Fetch the full invoice by id for line items
                        and amounts breakdown.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: The unique identifier of the invoice in our system.
                        customer:
                          type: object
                          description: Summary of the customer the invoice bills.
                          properties:
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the customer in our
                                system.
                            name:
                              type: string
                              description: The name of the customer.
                              example: Mercado Bom Preço
                            externalId:
                              type: string
                              description: >-
                                The external identifier of the customer from the
                                external system.
                              example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                          required:
                            - id
                            - name
                            - externalId
                          additionalProperties: false
                        contractInvoiceSequence:
                          type: integer
                          minimum: 1
                          nullable: true
                          description: >-
                            The number of the invoice within its contract, in
                            the order that Aira created the contract's invoices:
                            1 for the first, 2 for the next, and so on. Every
                            invoice gets its own number, including each invoice
                            of a split across payment accounts and the
                            replacement of a reopened invoice, and a number
                            never changes and is never reused. Null for invoices
                            without a contract.
                        billingAccount:
                          type: object
                          description: >-
                            Summary of the billed party (the legal entity behind
                            the customer payment account).
                          properties:
                            businessName:
                              type: string
                              description: >-
                                Registered business name (razão social) of the
                                billed legal entity.
                              example: Mercado Bom Preço Ltda
                            taxId:
                              type: string
                              description: >-
                                Tax identification number of the billed legal
                                entity, digits only.
                              example: '01234567000195'
                            taxIdType:
                              type: string
                              enum:
                                - cnpj
                                - cpf
                              description: >-
                                The kind of tax identification number in taxId
                                (e.g. CNPJ for Brazilian companies, CPF for
                                individuals).
                          required:
                            - businessName
                            - taxId
                            - taxIdType
                          additionalProperties: false
                        invoiceNumber:
                          type: string
                          description: >-
                            Human-readable invoice number, built from the
                            customer's invoice prefix plus a sequential counter.
                          example: ACMEI-0042
                        invoiceDate:
                          type: string
                          format: date
                          description: >-
                            The date of the invoice. On a contract invoice it is
                            the date of its billing act: the first day of the
                            first billing cycle that the contract invoices for
                            an activation invoice, and the last day of the
                            billing cycle for a closing invoice. Its line items
                            state the periods that it bills. On a one-off or
                            imported invoice it is the date given when the
                            invoice was created.
                        dueDate:
                          type: string
                          format: date
                          nullable: true
                          description: >-
                            Payment due date of the invoice. Null when no due
                            date is set (e.g. before the invoice is issued).
                        totalAmount:
                          type: number
                          description: Final invoice amount, in cents.
                        status:
                          type: string
                          enum:
                            - open
                            - in_review
                            - issued
                            - synced
                            - pending
                            - paid
                            - overdue
                            - canceled
                            - failed
                          description: >-
                            Current status of the invoice lifecycle: open
                            (accumulating charges, editable), in_review (flagged
                            for manual review before issuing), issued (finalized
                            and issued to the customer), synced (registered in
                            the external ERP/payment provider), pending (a
                            payment was initiated and awaits settlement), paid,
                            overdue (unpaid past the due date), canceled, or
                            failed (an issue/sync attempt failed and needs
                            attention).
                        contractId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the contract that generated
                            this invoice. Null for invoices not generated from a
                            contract (e.g. one-off and imported invoices).
                        isLocked:
                          type: boolean
                          description: >-
                            Whether the invoice contents are locked against
                            edits. Aira locks an invoice when it issues or
                            cancels it, together with the other invoices of its
                            allocation group, except when it cancels the invoice
                            because its payment account left the allocation of
                            the contract, which locks only that invoice. A
                            locked invoice stays locked, also when its status
                            later moves to failed.
                        sentAt:
                          type: string
                          format: date-time
                          nullable: true
                          description: >-
                            When Aira last sent the invoice by e-mail to its
                            invoice recipients, in an invoice delivery. Null
                            when Aira has not sent it.
                        customFields:
                          type: object
                          description: >-
                            The values of the custom fields of invoices, keyed
                            by the key of each custom field. The object is empty
                            when the invoice holds no value. A user edits them
                            in the billing app, and `PUT
                            /v1/invoices/{id}/custom-fields` replaces the whole
                            set, in any status of the invoice.
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          default: {}
                          example:
                            customField1: value1
                            customField2:
                              - value2
                              - value3
                      required:
                        - id
                        - customer
                        - contractInvoiceSequence
                        - billingAccount
                        - invoiceNumber
                        - invoiceDate
                        - dueDate
                        - totalAmount
                        - status
                        - contractId
                        - isLocked
                        - sentAt
                        - customFields
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.

            - `invalid_custom_fields`: a key of the `customField` filter names
            no custom field of its record.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''search'' must be string'
                    code: json_schema_validation_error
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
    post:
      summary: Create invoice
      tags:
        - Invoices
      description: >-
        Creates a one-off invoice in `open` status. Provide exactly one of
        `customerId` or `externalCustomerId`. When `paymentAccountId` is omitted
        or null, the invoice bills the customer's default payment account.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                idempotencyKey:
                  type: string
                  minLength: 1
                  pattern: ^[a-zA-Z0-9_-]+$
                  description: A unique idempotency key associated with the invoice.
                  example: padaria-central-2026-11
                customerId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    The unique identifier of the customer in our system that
                    this invoice will be associated with.
                externalCustomerId:
                  type: string
                  pattern: ^[a-zA-Z0-9_-]+$
                  nullable: true
                  description: >-
                    The external identifier of the customer that this invoice
                    will be associated with.
                  example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                paymentAccountId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    The unique identifier of the payment account that will be
                    used as the billing account. When omitted or null, the
                    invoice bills the customer's default payment account, and
                    the request fails if the customer has no default payment
                    account.
                invoiceDate:
                  type: string
                  format: date
                  description: >-
                    The closing date of the invoice. It represents the end date
                    of the period covered by the invoice.
                memo:
                  type: string
                  description: The memo to attach to the invoice.
                  example: Entregas de novembro
              required:
                - idempotencyKey
                - invoiceDate
                - memo
              additionalProperties: false
        required: true
        description: >-
          Schema for creating a one-off invoice. Exactly one of customerId or
          externalCustomerId must be provided. When paymentAccountId is omitted
          or null, the invoice bills the customer's default payment account, and
          the request fails if the customer has no default payment account.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_customer_reference
          when: the body has neither a `customerId` nor an `externalCustomerId`
        - status: 404
          code: customer_not_found
          when: no customer has the `externalCustomerId`
        - status: 404
          code: customer_payment_account_not_found
          when: >-
            the customer has no payment account with the `paymentAccountId`, or
            no default payment account when the body leaves `paymentAccountId`
            out or null, as for a `customerId` that names no customer
        - status: 409
          code: invoice_idempotency_key_conflict
          when: an invoice already has the `idempotencyKey`
      x-required-roles: &ref_8
        - invoices:write
      responses:
        '200':
          description: >-
            The document that bills one payment account of a customer: from a
            billing act of a contract, as a one-off invoice or from an import.
            It locks when it is issued or canceled, and Aira never recalculates
            a locked invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the invoice in our system.
                  idempotencyKey:
                    type: string
                    description: >-
                      A unique key that identifies the invoice for idempotent
                      creation. Supplied by the caller for one-off invoices;
                      generated by the billing engine for contract invoices.
                    example: padaria-central-2026-11
                  customerId:
                    type: string
                    format: uuid
                    description: The unique identifier of the customer this invoice bills.
                  paymentAccountId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the customer payment account used
                      as the billing account for this invoice.
                  contractId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the contract that generated this
                      invoice. Null for invoices not generated from a contract
                      (e.g. one-off and imported invoices).
                  contractInvoiceSequence:
                    type: integer
                    minimum: 1
                    nullable: true
                    description: >-
                      The number of the invoice within its contract, in the
                      order that Aira created the contract's invoices: 1 for the
                      first, 2 for the next, and so on. Every invoice gets its
                      own number, including each invoice of a split across
                      payment accounts and the replacement of a reopened
                      invoice, and a number never changes and is never reused.
                      Null for invoices without a contract.
                  issuingAccount:
                    type: object
                    description: >-
                      Snapshot of the legal entity issuing the invoice (the
                      seller), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  billingAccount:
                    type: object
                    description: >-
                      Snapshot of the billed party (the legal entity behind the
                      customer payment account), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How the originating contract distributes charges across
                      payment accounts: single bills a single payment account;
                      percent_split divides the total between payment accounts
                      by configured percentages; subsidiary_usage_split divides
                      it according to each subsidiary's usage.
                  lastCalculatedAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When the invoice amounts were last computed by the billing
                      engine. Null when the invoice has never been calculated.
                  invoiceNumber:
                    type: string
                    description: >-
                      Human-readable invoice number, built from the customer's
                      invoice prefix plus a sequential counter.
                    example: ACMEI-0042
                  invoiceDate:
                    type: string
                    format: date
                    description: >-
                      The date of the invoice. On a contract invoice it is the
                      date of its billing act: the first day of the first
                      billing cycle that the contract invoices for an activation
                      invoice, and the last day of the billing cycle for a
                      closing invoice. Its line items state the periods that it
                      bills. On a one-off or imported invoice it is the date
                      given when the invoice was created.
                  memo:
                    type: string
                    nullable: true
                    description: >-
                      Free-form memo attached to the invoice. On contract
                      invoices, it reads "Período <start> a <end>" with the
                      period of the line item that bills most often, such as the
                      month when a monthly fee is billed with an annual fee.
                      When two line items bill equally often, it uses the
                      earlier period. Null when absent.
                    example: Período 01/11/2026 a 30/11/2026
                  subtotalAmount:
                    type: number
                    description: >-
                      Sum of the line item subtotals before adjustments, in
                      cents.
                  adjustmentAmount:
                    type: number
                    description: >-
                      Net amount of all adjustments applied to the invoice line
                      items (discounts and allocation offsets), in cents.
                      Negative when adjustments reduce the amount owed.
                  totalAmount:
                    type: number
                    description: >-
                      Final invoice amount, in cents: subtotalAmount +
                      adjustmentAmount.
                  discountAmount:
                    type: number
                    description: >-
                      The discount portion of adjustmentAmount, in cents (sum of
                      monetary discount adjustments only). Negative when
                      discounts were applied.
                  status:
                    type: string
                    enum:
                      - open
                      - in_review
                      - issued
                      - synced
                      - pending
                      - paid
                      - overdue
                      - canceled
                      - failed
                    description: >-
                      Current status of the invoice lifecycle: open
                      (accumulating charges, editable), in_review (flagged for
                      manual review before issuing), issued (finalized and
                      issued to the customer), synced (registered in the
                      external ERP/payment provider), pending (a payment was
                      initiated and awaits settlement), paid, overdue (unpaid
                      past the due date), canceled, or failed (an issue/sync
                      attempt failed and needs attention).
                  isLocked:
                    type: boolean
                    description: >-
                      Whether the invoice contents are locked against edits.
                      Aira locks an invoice when it issues or cancels it,
                      together with the other invoices of its allocation group,
                      except when it cancels the invoice because its payment
                      account left the allocation of the contract, which locks
                      only that invoice. A locked invoice stays locked, also
                      when its status later moves to failed.
                  failureReason:
                    type: string
                    nullable: true
                    description: >-
                      Reason for the most recent failure on the invoice (e.g. an
                      ERP sync or payment issue). Null when the invoice has no
                      active failure.
                    example: contract_sync_not_found
                  source:
                    type: string
                    enum:
                      - contract
                      - one_off
                      - import
                    description: >-
                      How the invoice originated: contract (generated by a
                      contract billing cycle), one_off (created manually or
                      through the API), or import (ingested from an external
                      system).
                  autoIssue:
                    type: boolean
                    description: >-
                      Whether the invoice is issued automatically when its
                      billing cycle closes, without manual review.
                  amountDue:
                    type: number
                    nullable: true
                    description: >-
                      Outstanding amount due on the invoice, in cents. Null when
                      not tracked.
                  dueDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Payment due date of the invoice. Null when no due date is
                      set (e.g. before the invoice is issued).
                  lineItemGroups:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a line item group: a container that
                        gathers the line items generated from one plan instance
                        (or created as a group on one-off invoices). Monetary
                        amounts are integers in cents.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item group in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the group within the
                            invoice. Supplied by the caller for one-off groups;
                            generated by the billing engine otherwise.
                          example: servicos-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this group bills.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this group
                            belongs to.
                        planId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan whose instance
                            generated this group. Null for groups not generated
                            from a plan (e.g. on one-off invoices).
                        planInstanceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan instance that
                            generated this group. Null for groups not generated
                            from a plan instance.
                        name:
                          type: string
                          description: >-
                            Display name of the group as it appears on the
                            invoice, typically the plan or product name.
                          example: Plano Entregas
                        startDate:
                          type: string
                          format: date
                          description: >-
                            Start of the period that the group shows. On
                            contract invoices, it is the period of the group's
                            line item that bills most often, such as the month
                            when a monthly fee is billed with an annual fee.
                            When two line items bill equally often, it is the
                            earlier period.
                        endDate:
                          type: string
                          format: date
                          description: >-
                            End of the period that the group shows, which
                            `startDate` describes.
                        subtotalAmount:
                          type: number
                          description: >-
                            Sum of the group's line item subtotals before
                            adjustments, in cents.
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to the group's
                            line items (discounts and allocation offsets), in
                            cents. Negative when adjustments reduce the amount
                            owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final group amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        lineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              One amount on an invoice, such as a plan charge,
                              the contract minimum, a tax gross-up (the withheld
                              ISS, the municipal service tax, added on top), a
                              one-off amount or an additional charge.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the line item in our
                                  system.
                              idempotencyKey:
                                type: string
                                description: >-
                                  A unique key that identifies the line item
                                  within the invoice. Supplied by the caller for
                                  one-off line items; generated by the billing
                                  engine otherwise.
                                example: entrega-novembro
                              customerId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the customer whose
                                  consumption this line item bills. On split or
                                  consolidated invoices it may be a subsidiary
                                  of the invoice's customer.
                              productId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the product this line
                                  item belongs to.
                              itemId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the catalog item this
                                  line bills. Null for line items not backed by
                                  a catalog item.
                              resourceId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the metered resource
                                  behind a usage_based line item. Null for line
                                  items not driven by resource usage.
                              licenseId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the license behind a
                                  license_based line item. Null for line items
                                  not driven by a license count.
                              lineItemGroupId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the line item group
                                  containing this line item. Null for standalone
                                  line items.
                              name:
                                type: string
                                description: >-
                                  Display name of the line item as it appears on
                                  the invoice.
                                example: Entregas
                              scope:
                                type: string
                                enum:
                                  - credit_purchase
                                  - contract_minimum_commitment
                                  - minimum_commitment
                                  - fixed
                                  - usage_based
                                  - license_based
                                  - custom
                                  - additional_charge
                                  - one_off
                                  - tax_gross_up
                                description: >-
                                  What the line item charges for: usage_based
                                  (metered resource consumption), license_based
                                  (a license's reported count billed in full),
                                  fixed (recurring fixed charge of a plan),
                                  custom (custom plan charge, priced by a
                                  calculator that Aira writes for you),
                                  minimum_commitment (plan-level minimum
                                  top-up), contract_minimum_commitment
                                  (contract-level minimum top-up),
                                  credit_purchase (credit pool top-up),
                                  additional_charge (extra charge added
                                  manually), one_off (line item of a one-off
                                  invoice), or tax_gross_up (tax gross-up
                                  charge).
                              startDate:
                                type: string
                                format: date
                                description: Start of the period covered by this line item.
                              endDate:
                                type: string
                                format: date
                                description: End of the period covered by this line item.
                              totalUsage:
                                type: number
                                nullable: true
                                description: >-
                                  Total usage billed by the line item, in the
                                  unit given by usageFormat. Null for line items
                                  without a single usage (e.g. fixed charges
                                  without a quantity, and custom line items
                                  whose calculator returns no total).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read totalUsage, and the usage of each
                                  sub-line item that has no usageFormat of its
                                  own: unit means a count of resource units or a
                                  fixed charge quantity; currency means a
                                  monetary base amount in cents. Null when the
                                  line item has no single usage, as a custom
                                  line item whose sub-line items bill different
                                  kinds of volume, each with its own
                                  usageFormat.
                              subtotalAmount:
                                type: number
                                description: >-
                                  Line item amount before adjustments, in cents
                                  (sum of its sub-line item amounts).
                              adjustmentAmount:
                                type: number
                                description: >-
                                  Net amount of the adjustments applied to this
                                  line item (discounts and allocation offsets),
                                  in cents. Negative when adjustments reduce the
                                  amount owed.
                              totalAmount:
                                type: number
                                description: >-
                                  Final line item amount, in cents:
                                  subtotalAmount + adjustmentAmount.
                              discountAmount:
                                type: number
                                description: >-
                                  The discount portion of adjustmentAmount, in
                                  cents (sum of monetary discount adjustments
                                  only). Negative when discounts were applied.
                              metadata:
                                description: >-
                                  Pricing metadata for the line item, where the
                                  shape is keyed by type. Always present, but
                                  null for line items without pricing metadata:
                                  credit_purchase, additional_charge, one_off,
                                  and tax_gross_up. It is populated for fixed
                                  (the billing timing), usage_based,
                                  license_based, minimum_commitment,
                                  contract_minimum_commitment, and custom (the
                                  definition and the calculation memory) line
                                  items.
                                anyOf:
                                  - title: Fixed
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed
                                        description: >-
                                          Discriminator: metadata for a fixed line
                                          item.
                                      billingTiming:
                                        type: string
                                        enum:
                                          - in_advance
                                          - in_arrears
                                        description: >-
                                          Whether the fee was billed in advance of
                                          its service period or after it.
                                    required:
                                      - type
                                      - billingTiming
                                  - title: Usage-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - usage_based
                                        description: >-
                                          Discriminator: metadata for a
                                          usage_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the metered resource accrues over
                                          the billing period: in_full bills the
                                          full usage of the period; proration
                                          weighs usage by the fraction of the
                                          period each amount was held.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          usage was divided across tiers.
                                          unique_tier prices all usage at the
                                          single tier that contains the total;
                                          progressive prices each tier's band
                                          separately. Absent for non-tiered
                                          models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item. Charges
                                          priced before pricing models existed are
                                          reported as advanced.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: License-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_based
                                        description: >-
                                          Discriminator: metadata for a
                                          license_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the license count accrues over the
                                          billing period. Always in_full: the
                                          latest reported count is billed in full.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          the license count was divided across
                                          tiers. unique_tier prices the whole
                                          count at the single tier that contains
                                          the total; progressive prices each
                                          tier's band separately. Absent for
                                          non-tiered models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: Contract minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - contract_minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a
                                          contract_minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          whole contract in the billing period, in
                                          cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the contract's consumption amounted
                                          to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a plan-level
                                          minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          plan in the billing period, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the plan's consumption amounted to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Custom
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: >-
                                          Discriminator: metadata for a custom
                                          line item.
                                      definitionKey:
                                        type: string
                                        description: >-
                                          The key of the custom charge definition
                                          whose calculator priced the charge,
                                          following the
                                          custom:charge:<slug>:<name> convention.
                                        examples:
                                          - custom:charge:padaria-central:entregas
                                      memory:
                                        type: object
                                        additionalProperties: true
                                        description: >-
                                          The full calculation memory that the
                                          calculator returned, such as every tier
                                          it evaluated and the one it billed. Its
                                          shape belongs to the definition.
                                    required:
                                      - type
                                      - definitionKey
                                      - memory
                                  - title: No metadata
                                    type: 'null'
                              subLineItems:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing a sub-line item: one
                                    priced row of a line item's breakdown. The
                                    row type dictates the shape of metadata.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the sub-line
                                        item in our system.
                                    type:
                                      type: string
                                      enum:
                                        - fixed_price
                                        - minimum_amount
                                        - price_tier_flat
                                        - price_tier_unit
                                        - price_tier_package
                                        - price_tier_percentage
                                        - proration
                                        - license_proration
                                        - license_proration_tier
                                        - unit_price
                                        - included_quantity
                                        - package_price
                                        - percentage
                                        - overage
                                        - original_amount
                                        - fixed_unit_price
                                        - custom
                                      description: >-
                                        The kind of priced row: fixed_price and
                                        minimum_amount are companions of
                                        usage-based charges; unit_price,
                                        package_price, percentage, and
                                        included_quantity break down
                                        single-model pricing; price_tier_* rows
                                        break down tiered pricing; overage bills
                                        usage beyond the last tier; proration
                                        bills per prorated interval;
                                        license_proration bills license deltas
                                        (removals are negative); original_amount
                                        surfaces the pre-adjustment amount of an
                                        adjusted line; fixed_unit_price breaks
                                        down a fixed charge billed as a quantity
                                        times a unit amount; custom bills one
                                        component of a custom plan charge.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the sub-line item as it
                                        appears on the invoice breakdown.
                                      example: '[A partir de 1] Unidades'
                                    description:
                                      type: string
                                      nullable: true
                                      description: >-
                                        Optional descriptive text for the row.
                                        Null when absent.
                                      example: 120 x 2,50
                                    usage:
                                      type: number
                                      nullable: true
                                      description: >-
                                        The usage billed by this row: a count of
                                        resource units (the quantity for a
                                        fixed_unit_price row), or a monetary
                                        base amount in cents for
                                        percentage-priced rows (see the row's
                                        usageFormat, or the line item
                                        usageFormat when the row has none). Null
                                        for rows without usage (e.g.
                                        companions).
                                    usageFormat:
                                      type: string
                                      enum:
                                        - unit
                                        - currency
                                        - null
                                      nullable: true
                                      description: >-
                                        How to read the usage of this row when
                                        the row has a format of its own, as the
                                        custom rows of a custom line item do:
                                        unit means a count, currency means an
                                        amount in cents. Null when the row reads
                                        its usage in the line item usageFormat.
                                    amount:
                                      type: number
                                      description: >-
                                        Amount billed by this row, in cents. The
                                        sum of a line item's sub-line amounts
                                        equals its subtotalAmount.
                                    metadata:
                                      description: >-
                                        Pricing details of the row, keyed by the
                                        row type (and pricingType for overage
                                        rows).
                                      anyOf:
                                        - type: object
                                          description: >-
                                            Fixed-price companion row: the charge's
                                            configured fixed amount, billed
                                            alongside the usage rows. Only rendered
                                            when configured greater than zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_price
                                              description: >-
                                                Discriminator: fixed-price companion
                                                row.
                                            fixedPrice:
                                              type: number
                                              description: >-
                                                The fixed amount configured on the
                                                charge, in cents.
                                          required:
                                            - type
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Minimum-amount companion row: tops the
                                            charge up to its configured minimum when
                                            usage alone stays below it. Only
                                            rendered when the top-up is greater than
                                            zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - minimum_amount
                                              description: >-
                                                Discriminator: minimum-amount companion
                                                row.
                                            minimumAmount:
                                              type: number
                                              description: >-
                                                The minimum amount configured on the
                                                charge, in cents.
                                            minimumAmountApplied:
                                              type: number
                                              description: >-
                                                The top-up billed by this row to reach
                                                the configured minimum, in cents.
                                          required:
                                            - type
                                            - minimumAmount
                                            - minimumAmountApplied
                                        - type: object
                                          description: >-
                                            Flat-priced tier row: usage falling in
                                            this tier band is billed at a flat
                                            amount, regardless of the exact
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_flat
                                              description: 'Discriminator: flat-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            fixedPrice:
                                              type: string
                                              description: >-
                                                The flat amount billed for the tier, as
                                                a decimal currency-unit string.
                                              examples:
                                                - '150.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Per-unit priced tier row: units
                                            attributed to this tier band are billed
                                            at the tier's unit price.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_unit
                                              description: 'Discriminator: per-unit priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            price:
                                              type: string
                                              description: >-
                                                Price per unit within the tier, as a
                                                decimal currency-unit string.
                                              examples:
                                                - '0.25'
                                            fixedPrice:
                                              type: string
                                              nullable: true
                                              description: >-
                                                Optional flat fee billed on top when the
                                                tier applies, as a decimal currency-unit
                                                string. Null when the tier has no flat
                                                fee.
                                              examples:
                                                - '10.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - price
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Package-priced tier row: units
                                            attributed to this tier band are billed
                                            per started package of packageSize
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_package
                                              description: 'Discriminator: package-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string.
                                              examples:
                                                - '45.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - packageSize
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage-priced tier row: the monetary
                                            base amount attributed to this tier band
                                            is billed at a percentage.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_percentage
                                              description: >-
                                                Discriminator: percentage-priced tier
                                                row.
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                                Null for an unbounded final tier.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount
                                                within the tier, as a decimal string
                                                from 0 to 100 (up to 6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - percentage
                                        - type: object
                                          description: >-
                                            Proration interval row: for charges on
                                            prorated resources, each interval bills
                                            the usage held during it, priced as if
                                            held for the whole cycle and scaled by
                                            the interval's share of the cycle.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - proration
                                              description: 'Discriminator: proration interval row.'
                                            intervalSize:
                                              type: number
                                              description: >-
                                                Length of the interval, in days of the
                                                billing cycle.
                                            amount:
                                              type: string
                                              description: >-
                                                The prorated amount of the interval, as
                                                a decimal currency-unit string: the
                                                interval usage priced as if held for the
                                                whole cycle, scaled by intervalSize over
                                                the cycle length.
                                              examples:
                                                - '29.0322580645'
                                            usage:
                                              type: number
                                              description: The usage held during the interval.
                                            intervalStart:
                                              type: string
                                              format: date
                                              description: First day of the interval.
                                            intervalEnd:
                                              type: string
                                              format: date
                                              description: Last day of the interval.
                                          required:
                                            - type
                                            - intervalSize
                                            - amount
                                            - usage
                                            - intervalStart
                                            - intervalEnd
                                        - type: object
                                          description: >-
                                            License proration delta row: for
                                            per_unit license charges billing under
                                            the proration model, the cycle-start row
                                            bills the starting licenses beyond the
                                            included quantity at their full-cycle
                                            price, and each change row bills the
                                            change in those licenses prorated over
                                            the days remaining in the cycle. A
                                            change that stays inside the included
                                            quantity has no row. Tiered charges use
                                            license_proration_tier instead.
                                            quantityDelta and the row's amount are
                                            signed — removals are negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration
                                              description: >-
                                                Discriminator: license proration delta
                                                row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on the cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the licenses beyond the
                                                included quantity (the starting licenses
                                                beyond it on the cycle-start row).
                                                Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity after this
                                                change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on
                                                the cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|. On a cycle-start row
                                                that bills no license, the unit price of
                                                the charge.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                        - type: object
                                          description: >-
                                            Tiered license proration delta row: one
                                            price band of a license charge billing
                                            under the proration model with
                                            tiered_per_unit pricing. The cycle-start
                                            rows bill each band's opening occupancy
                                            at its full-cycle unit price, and each
                                            change row bills that band's occupancy
                                            delta prorated over the days remaining
                                            in the cycle. quantityDelta and the
                                            row's amount are signed — removals are
                                            negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration_tier
                                              description: >-
                                                Discriminator: tiered license proration
                                                delta row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on a cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the units this band
                                                holds (the band's opening occupancy on a
                                                cycle-start row). Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity across
                                                every band after this change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on a
                                                cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                            planChargeTierId:
                                              type: string
                                              description: >-
                                                The unique identifier of the plan charge
                                                tier this row moved through.
                                              examples:
                                                - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                            from:
                                              type: number
                                              description: >-
                                                Inclusive lower bound of the band, in
                                                licenses.
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Inclusive upper bound of the band, in
                                                licenses. Null on the last, open-ended
                                                band.
                                            unitPrice:
                                              type: string
                                              description: >-
                                                The band's full-cycle price per unit, as
                                                a decimal currency-unit string.
                                                proratedUnitRate is this scaled by
                                                remainingDays over cycleDays.
                                              examples:
                                                - '25.00'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                            - planChargeTierId
                                            - from
                                            - to
                                            - unitPrice
                                        - type: object
                                          description: >-
                                            Unit-price row: billable units
                                            multiplied by a single price per unit.
                                            The row's usage holds the billable
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - unit_price
                                              description: 'Discriminator: unit-price row.'
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.25'
                                          required:
                                            - type
                                            - price
                                        - type: object
                                          description: >-
                                            Included-quantity row: the free
                                            allotment of the charge. The row's usage
                                            holds the units consumed within the
                                            allotment and its amount is always zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - included_quantity
                                              description: 'Discriminator: included-quantity row.'
                                            includedQuantity:
                                              type: number
                                              description: >-
                                                Number of resource units included at no
                                                charge before billing starts.
                                          required:
                                            - type
                                            - includedQuantity
                                        - type: object
                                          description: >-
                                            Package-price row: billable units
                                            charged per started package of
                                            packageSize units. The row's usage holds
                                            the billable units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - package_price
                                              description: 'Discriminator: package-price row.'
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '45.00'
                                            packagesBilled:
                                              type: number
                                              description: >-
                                                Number of packages billed: the billable
                                                units divided by packageSize, rounded
                                                up.
                                          required:
                                            - type
                                            - packageSize
                                            - price
                                            - packagesBilled
                                        - type: object
                                          description: >-
                                            Percentage row: a percentage applied
                                            over a monetary base amount. The row's
                                            usage holds the base amount, in cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - percentage
                                              description: 'Discriminator: percentage row.'
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount,
                                                as a decimal string from 0 to 100 (up to
                                                6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - percentage
                                        - type: object
                                          description: >-
                                            Per-unit overage row: units beyond the
                                            last tier boundary, billed at the
                                            configured excess unit price. The row's
                                            usage holds the units over the boundary.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - per_unit
                                              description: 'Discriminator: overage billed per unit.'
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                resource units.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per excess unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.30'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage overage row: the monetary
                                            base amount beyond the last tier
                                            boundary, billed at the configured
                                            excess percentage. The row's usage holds
                                            the base amount over the boundary, in
                                            cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - percentage
                                              description: >-
                                                Discriminator: overage billed as a
                                                percentage.
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                cents of the monetary base amount.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the excess base
                                                amount, as a decimal string from 0 to
                                                100 (up to 6 decimal places).
                                              examples:
                                                - '1.5'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - percentage
                                        - type: object
                                          description: >-
                                            Original-amount row: surfaces the line
                                            item's pre-adjustment amount when the
                                            line has adjustments (e.g. a discount)
                                            but no price-component rows of its own.
                                            The row's amount equals the line item's
                                            subtotalAmount.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - original_amount
                                              description: 'Discriminator: original-amount row.'
                                          required:
                                            - type
                                        - type: object
                                          description: >-
                                            Fixed unit price row: the quantity of a
                                            fixed charge multiplied by its unit
                                            amount. The row's usage holds the
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_unit_price
                                              description: 'Discriminator: fixed unit price row.'
                                            amount:
                                              type: integer
                                              minimum: 0
                                              description: Amount of one unit, in cents.
                                          required:
                                            - type
                                            - amount
                                        - type: object
                                          description: >-
                                            Custom row: one component of a custom
                                            plan charge, as its calculator billed
                                            it. The row's name, description, usage,
                                            usageFormat and amount hold the rest of
                                            the component.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - custom
                                              description: 'Discriminator: custom row.'
                                            key:
                                              type: string
                                              description: >-
                                                The key of the component in the sub-line
                                                schema of the charge's custom charge
                                                definition, such as documents_overage.
                                              examples:
                                                - documents_overage
                                          required:
                                            - type
                                            - key
                                  required:
                                    - id
                                    - type
                                    - name
                                    - description
                                    - usage
                                    - usageFormat
                                    - amount
                                    - metadata
                                  additionalProperties: false
                                description: >-
                                  Breakdown of the line item amount into priced
                                  rows (included quantities, unit/package/tier
                                  prices, prorations, companions). Empty for
                                  line items without a breakdown.
                              adjustments:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing an adjustment applied on
                                    top of a line item subtotal, such as a
                                    discount or an allocation offset.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the adjustment
                                        in our system.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the adjustment as it
                                        appears on the invoice.
                                      example: Desconto de boas-vindas
                                    type:
                                      type: string
                                      enum:
                                        - monetary_discount
                                        - allocation_offset
                                      description: >-
                                        The kind of adjustment:
                                        monetary_discount (a discount applied to
                                        the line item) or allocation_offset (the
                                        share of the amount moved to another
                                        payment account's invoice under a split
                                        allocation strategy).
                                    amount:
                                      type: number
                                      description: >-
                                        Amount of the adjustment, in cents.
                                        Negative when the adjustment reduces the
                                        line item total.
                                  required:
                                    - id
                                    - name
                                    - type
                                    - amount
                                  additionalProperties: false
                                description: >-
                                  Adjustments applied on top of the line item
                                  subtotal, such as discounts and allocation
                                  offsets.
                            required:
                              - id
                              - idempotencyKey
                              - customerId
                              - productId
                              - resourceId
                              - licenseId
                              - lineItemGroupId
                              - name
                              - scope
                              - startDate
                              - endDate
                              - totalUsage
                              - usageFormat
                              - subtotalAmount
                              - adjustmentAmount
                              - totalAmount
                              - discountAmount
                              - metadata
                              - subLineItems
                              - adjustments
                            additionalProperties: false
                          description: The line items contained in this group.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - planId
                        - planInstanceId
                        - name
                        - startDate
                        - endDate
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - lineItems
                      additionalProperties: false
                    description: >-
                      Line item groups on the invoice. Each group gathers the
                      line items generated from one plan instance (or created as
                      a group on one-off invoices).
                  standaloneLineItems:
                    type: array
                    items:
                      type: object
                      description: >-
                        One amount on an invoice, such as a plan charge, the
                        contract minimum, a tax gross-up (the withheld ISS, the
                        municipal service tax, added on top), a one-off amount
                        or an additional charge.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the line item within
                            the invoice. Supplied by the caller for one-off line
                            items; generated by the billing engine otherwise.
                          example: entrega-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this line item bills. On split or
                            consolidated invoices it may be a subsidiary of the
                            invoice's customer.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this line item
                            belongs to.
                        itemId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the catalog item this line
                            bills. Null for line items not backed by a catalog
                            item.
                        resourceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the metered resource behind
                            a usage_based line item. Null for line items not
                            driven by resource usage.
                        licenseId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the license behind a
                            license_based line item. Null for line items not
                            driven by a license count.
                        lineItemGroupId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the line item group
                            containing this line item. Null for standalone line
                            items.
                        name:
                          type: string
                          description: >-
                            Display name of the line item as it appears on the
                            invoice.
                          example: Entregas
                        scope:
                          type: string
                          enum:
                            - credit_purchase
                            - contract_minimum_commitment
                            - minimum_commitment
                            - fixed
                            - usage_based
                            - license_based
                            - custom
                            - additional_charge
                            - one_off
                            - tax_gross_up
                          description: >-
                            What the line item charges for: usage_based (metered
                            resource consumption), license_based (a license's
                            reported count billed in full), fixed (recurring
                            fixed charge of a plan), custom (custom plan charge,
                            priced by a calculator that Aira writes for you),
                            minimum_commitment (plan-level minimum top-up),
                            contract_minimum_commitment (contract-level minimum
                            top-up), credit_purchase (credit pool top-up),
                            additional_charge (extra charge added manually),
                            one_off (line item of a one-off invoice), or
                            tax_gross_up (tax gross-up charge).
                        startDate:
                          type: string
                          format: date
                          description: Start of the period covered by this line item.
                        endDate:
                          type: string
                          format: date
                          description: End of the period covered by this line item.
                        totalUsage:
                          type: number
                          nullable: true
                          description: >-
                            Total usage billed by the line item, in the unit
                            given by usageFormat. Null for line items without a
                            single usage (e.g. fixed charges without a quantity,
                            and custom line items whose calculator returns no
                            total).
                        usageFormat:
                          type: string
                          enum:
                            - unit
                            - currency
                            - null
                          nullable: true
                          description: >-
                            How to read totalUsage, and the usage of each
                            sub-line item that has no usageFormat of its own:
                            unit means a count of resource units or a fixed
                            charge quantity; currency means a monetary base
                            amount in cents. Null when the line item has no
                            single usage, as a custom line item whose sub-line
                            items bill different kinds of volume, each with its
                            own usageFormat.
                        subtotalAmount:
                          type: number
                          description: >-
                            Line item amount before adjustments, in cents (sum
                            of its sub-line item amounts).
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to this line
                            item (discounts and allocation offsets), in cents.
                            Negative when adjustments reduce the amount owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final line item amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        metadata:
                          description: >-
                            Pricing metadata for the line item, where the shape
                            is keyed by type. Always present, but null for line
                            items without pricing metadata: credit_purchase,
                            additional_charge, one_off, and tax_gross_up. It is
                            populated for fixed (the billing timing),
                            usage_based, license_based, minimum_commitment,
                            contract_minimum_commitment, and custom (the
                            definition and the calculation memory) line items.
                          anyOf:
                            - title: Fixed
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed
                                  description: >-
                                    Discriminator: metadata for a fixed line
                                    item.
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    Whether the fee was billed in advance of its
                                    service period or after it.
                              required:
                                - type
                                - billingTiming
                            - title: Usage-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - usage_based
                                  description: >-
                                    Discriminator: metadata for a usage_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the metered resource accrues over the
                                    billing period: in_full bills the full usage
                                    of the period; proration weighs usage by the
                                    fraction of the period each amount was held.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how
                                    usage was divided across tiers. unique_tier
                                    prices all usage at the single tier that
                                    contains the total; progressive prices each
                                    tier's band separately. Absent for
                                    non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item. Charges priced
                                    before pricing models existed are reported
                                    as advanced.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: License-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_based
                                  description: >-
                                    Discriminator: metadata for a license_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the license count accrues over the
                                    billing period. Always in_full: the latest
                                    reported count is billed in full.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how the
                                    license count was divided across tiers.
                                    unique_tier prices the whole count at the
                                    single tier that contains the total;
                                    progressive prices each tier's band
                                    separately. Absent for non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: Contract minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - contract_minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a
                                    contract_minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the whole
                                    contract in the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the contract's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a plan-level
                                    minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the plan in
                                    the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the plan's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Custom
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - custom
                                  description: >-
                                    Discriminator: metadata for a custom line
                                    item.
                                definitionKey:
                                  type: string
                                  description: >-
                                    The key of the custom charge definition
                                    whose calculator priced the charge,
                                    following the custom:charge:<slug>:<name>
                                    convention.
                                  examples:
                                    - custom:charge:padaria-central:entregas
                                memory:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The full calculation memory that the
                                    calculator returned, such as every tier it
                                    evaluated and the one it billed. Its shape
                                    belongs to the definition.
                              required:
                                - type
                                - definitionKey
                                - memory
                            - title: No metadata
                              type: 'null'
                        subLineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing a sub-line item: one priced
                              row of a line item's breakdown. The row type
                              dictates the shape of metadata.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the sub-line item in
                                  our system.
                              type:
                                type: string
                                enum:
                                  - fixed_price
                                  - minimum_amount
                                  - price_tier_flat
                                  - price_tier_unit
                                  - price_tier_package
                                  - price_tier_percentage
                                  - proration
                                  - license_proration
                                  - license_proration_tier
                                  - unit_price
                                  - included_quantity
                                  - package_price
                                  - percentage
                                  - overage
                                  - original_amount
                                  - fixed_unit_price
                                  - custom
                                description: >-
                                  The kind of priced row: fixed_price and
                                  minimum_amount are companions of usage-based
                                  charges; unit_price, package_price,
                                  percentage, and included_quantity break down
                                  single-model pricing; price_tier_* rows break
                                  down tiered pricing; overage bills usage
                                  beyond the last tier; proration bills per
                                  prorated interval; license_proration bills
                                  license deltas (removals are negative);
                                  original_amount surfaces the pre-adjustment
                                  amount of an adjusted line; fixed_unit_price
                                  breaks down a fixed charge billed as a
                                  quantity times a unit amount; custom bills one
                                  component of a custom plan charge.
                              name:
                                type: string
                                description: >-
                                  Display name of the sub-line item as it
                                  appears on the invoice breakdown.
                                example: '[A partir de 1] Unidades'
                              description:
                                type: string
                                nullable: true
                                description: >-
                                  Optional descriptive text for the row. Null
                                  when absent.
                                example: 120 x 2,50
                              usage:
                                type: number
                                nullable: true
                                description: >-
                                  The usage billed by this row: a count of
                                  resource units (the quantity for a
                                  fixed_unit_price row), or a monetary base
                                  amount in cents for percentage-priced rows
                                  (see the row's usageFormat, or the line item
                                  usageFormat when the row has none). Null for
                                  rows without usage (e.g. companions).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read the usage of this row when the row
                                  has a format of its own, as the custom rows of
                                  a custom line item do: unit means a count,
                                  currency means an amount in cents. Null when
                                  the row reads its usage in the line item
                                  usageFormat.
                              amount:
                                type: number
                                description: >-
                                  Amount billed by this row, in cents. The sum
                                  of a line item's sub-line amounts equals its
                                  subtotalAmount.
                              metadata:
                                description: >-
                                  Pricing details of the row, keyed by the row
                                  type (and pricingType for overage rows).
                                anyOf:
                                  - type: object
                                    description: >-
                                      Fixed-price companion row: the charge's
                                      configured fixed amount, billed alongside
                                      the usage rows. Only rendered when
                                      configured greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_price
                                        description: >-
                                          Discriminator: fixed-price companion
                                          row.
                                      fixedPrice:
                                        type: number
                                        description: >-
                                          The fixed amount configured on the
                                          charge, in cents.
                                    required:
                                      - type
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Minimum-amount companion row: tops the
                                      charge up to its configured minimum when
                                      usage alone stays below it. Only rendered
                                      when the top-up is greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_amount
                                        description: >-
                                          Discriminator: minimum-amount companion
                                          row.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount configured on the
                                          charge, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up billed by this row to reach
                                          the configured minimum, in cents.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - type: object
                                    description: >-
                                      Flat-priced tier row: usage falling in
                                      this tier band is billed at a flat amount,
                                      regardless of the exact quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_flat
                                        description: 'Discriminator: flat-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      fixedPrice:
                                        type: string
                                        description: >-
                                          The flat amount billed for the tier, as
                                          a decimal currency-unit string.
                                        examples:
                                          - '150.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Per-unit priced tier row: units attributed
                                      to this tier band are billed at the tier's
                                      unit price.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_unit
                                        description: 'Discriminator: per-unit priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      price:
                                        type: string
                                        description: >-
                                          Price per unit within the tier, as a
                                          decimal currency-unit string.
                                        examples:
                                          - '0.25'
                                      fixedPrice:
                                        type: string
                                        nullable: true
                                        description: >-
                                          Optional flat fee billed on top when the
                                          tier applies, as a decimal currency-unit
                                          string. Null when the tier has no flat
                                          fee.
                                        examples:
                                          - '10.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - price
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Package-priced tier row: units attributed
                                      to this tier band are billed per started
                                      package of packageSize units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_package
                                        description: 'Discriminator: package-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string.
                                        examples:
                                          - '45.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - packageSize
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage-priced tier row: the monetary
                                      base amount attributed to this tier band
                                      is billed at a percentage.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_percentage
                                        description: >-
                                          Discriminator: percentage-priced tier
                                          row.
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                          Null for an unbounded final tier.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          within the tier, as a decimal string
                                          from 0 to 100 (up to 6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - percentage
                                  - type: object
                                    description: >-
                                      Proration interval row: for charges on
                                      prorated resources, each interval bills
                                      the usage held during it, priced as if
                                      held for the whole cycle and scaled by the
                                      interval's share of the cycle.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - proration
                                        description: 'Discriminator: proration interval row.'
                                      intervalSize:
                                        type: number
                                        description: >-
                                          Length of the interval, in days of the
                                          billing cycle.
                                      amount:
                                        type: string
                                        description: >-
                                          The prorated amount of the interval, as
                                          a decimal currency-unit string: the
                                          interval usage priced as if held for the
                                          whole cycle, scaled by intervalSize over
                                          the cycle length.
                                        examples:
                                          - '29.0322580645'
                                      usage:
                                        type: number
                                        description: The usage held during the interval.
                                      intervalStart:
                                        type: string
                                        format: date
                                        description: First day of the interval.
                                      intervalEnd:
                                        type: string
                                        format: date
                                        description: Last day of the interval.
                                    required:
                                      - type
                                      - intervalSize
                                      - amount
                                      - usage
                                      - intervalStart
                                      - intervalEnd
                                  - type: object
                                    description: >-
                                      License proration delta row: for per_unit
                                      license charges billing under the
                                      proration model, the cycle-start row bills
                                      the starting licenses beyond the included
                                      quantity at their full-cycle price, and
                                      each change row bills the change in those
                                      licenses prorated over the days remaining
                                      in the cycle. A change that stays inside
                                      the included quantity has no row. Tiered
                                      charges use license_proration_tier
                                      instead. quantityDelta and the row's
                                      amount are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration
                                        description: >-
                                          Discriminator: license proration delta
                                          row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on the cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the licenses beyond the
                                          included quantity (the starting licenses
                                          beyond it on the cycle-start row).
                                          Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity after this
                                          change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on
                                          the cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|. On a cycle-start row
                                          that bills no license, the unit price of
                                          the charge.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                  - type: object
                                    description: >-
                                      Tiered license proration delta row: one
                                      price band of a license charge billing
                                      under the proration model with
                                      tiered_per_unit pricing. The cycle-start
                                      rows bill each band's opening occupancy at
                                      its full-cycle unit price, and each change
                                      row bills that band's occupancy delta
                                      prorated over the days remaining in the
                                      cycle. quantityDelta and the row's amount
                                      are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration_tier
                                        description: >-
                                          Discriminator: tiered license proration
                                          delta row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on a cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the units this band
                                          holds (the band's opening occupancy on a
                                          cycle-start row). Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity across
                                          every band after this change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on a
                                          cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                      planChargeTierId:
                                        type: string
                                        description: >-
                                          The unique identifier of the plan charge
                                          tier this row moved through.
                                        examples:
                                          - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                      from:
                                        type: number
                                        description: >-
                                          Inclusive lower bound of the band, in
                                          licenses.
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Inclusive upper bound of the band, in
                                          licenses. Null on the last, open-ended
                                          band.
                                      unitPrice:
                                        type: string
                                        description: >-
                                          The band's full-cycle price per unit, as
                                          a decimal currency-unit string.
                                          proratedUnitRate is this scaled by
                                          remainingDays over cycleDays.
                                        examples:
                                          - '25.00'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                      - planChargeTierId
                                      - from
                                      - to
                                      - unitPrice
                                  - type: object
                                    description: >-
                                      Unit-price row: billable units multiplied
                                      by a single price per unit. The row's
                                      usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - unit_price
                                        description: 'Discriminator: unit-price row.'
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.25'
                                    required:
                                      - type
                                      - price
                                  - type: object
                                    description: >-
                                      Included-quantity row: the free allotment
                                      of the charge. The row's usage holds the
                                      units consumed within the allotment and
                                      its amount is always zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - included_quantity
                                        description: 'Discriminator: included-quantity row.'
                                      includedQuantity:
                                        type: number
                                        description: >-
                                          Number of resource units included at no
                                          charge before billing starts.
                                    required:
                                      - type
                                      - includedQuantity
                                  - type: object
                                    description: >-
                                      Package-price row: billable units charged
                                      per started package of packageSize units.
                                      The row's usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - package_price
                                        description: 'Discriminator: package-price row.'
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '45.00'
                                      packagesBilled:
                                        type: number
                                        description: >-
                                          Number of packages billed: the billable
                                          units divided by packageSize, rounded
                                          up.
                                    required:
                                      - type
                                      - packageSize
                                      - price
                                      - packagesBilled
                                  - type: object
                                    description: >-
                                      Percentage row: a percentage applied over
                                      a monetary base amount. The row's usage
                                      holds the base amount, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - percentage
                                        description: 'Discriminator: percentage row.'
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount,
                                          as a decimal string from 0 to 100 (up to
                                          6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - percentage
                                  - type: object
                                    description: >-
                                      Per-unit overage row: units beyond the
                                      last tier boundary, billed at the
                                      configured excess unit price. The row's
                                      usage holds the units over the boundary.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - per_unit
                                        description: 'Discriminator: overage billed per unit.'
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          resource units.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per excess unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage overage row: the monetary base
                                      amount beyond the last tier boundary,
                                      billed at the configured excess
                                      percentage. The row's usage holds the base
                                      amount over the boundary, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - percentage
                                        description: >-
                                          Discriminator: overage billed as a
                                          percentage.
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          cents of the monetary base amount.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the excess base
                                          amount, as a decimal string from 0 to
                                          100 (up to 6 decimal places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - percentage
                                  - type: object
                                    description: >-
                                      Original-amount row: surfaces the line
                                      item's pre-adjustment amount when the line
                                      has adjustments (e.g. a discount) but no
                                      price-component rows of its own. The row's
                                      amount equals the line item's
                                      subtotalAmount.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - original_amount
                                        description: 'Discriminator: original-amount row.'
                                    required:
                                      - type
                                  - type: object
                                    description: >-
                                      Fixed unit price row: the quantity of a
                                      fixed charge multiplied by its unit
                                      amount. The row's usage holds the
                                      quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_unit_price
                                        description: 'Discriminator: fixed unit price row.'
                                      amount:
                                        type: integer
                                        minimum: 0
                                        description: Amount of one unit, in cents.
                                    required:
                                      - type
                                      - amount
                                  - type: object
                                    description: >-
                                      Custom row: one component of a custom plan
                                      charge, as its calculator billed it. The
                                      row's name, description, usage,
                                      usageFormat and amount hold the rest of
                                      the component.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: 'Discriminator: custom row.'
                                      key:
                                        type: string
                                        description: >-
                                          The key of the component in the sub-line
                                          schema of the charge's custom charge
                                          definition, such as documents_overage.
                                        examples:
                                          - documents_overage
                                    required:
                                      - type
                                      - key
                            required:
                              - id
                              - type
                              - name
                              - description
                              - usage
                              - usageFormat
                              - amount
                              - metadata
                            additionalProperties: false
                          description: >-
                            Breakdown of the line item amount into priced rows
                            (included quantities, unit/package/tier prices,
                            prorations, companions). Empty for line items
                            without a breakdown.
                        adjustments:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing an adjustment applied on top
                              of a line item subtotal, such as a discount or an
                              allocation offset.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the adjustment in our
                                  system.
                              name:
                                type: string
                                description: >-
                                  Display name of the adjustment as it appears
                                  on the invoice.
                                example: Desconto de boas-vindas
                              type:
                                type: string
                                enum:
                                  - monetary_discount
                                  - allocation_offset
                                description: >-
                                  The kind of adjustment: monetary_discount (a
                                  discount applied to the line item) or
                                  allocation_offset (the share of the amount
                                  moved to another payment account's invoice
                                  under a split allocation strategy).
                              amount:
                                type: number
                                description: >-
                                  Amount of the adjustment, in cents. Negative
                                  when the adjustment reduces the line item
                                  total.
                            required:
                              - id
                              - name
                              - type
                              - amount
                            additionalProperties: false
                          description: >-
                            Adjustments applied on top of the line item
                            subtotal, such as discounts and allocation offsets.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - resourceId
                        - licenseId
                        - lineItemGroupId
                        - name
                        - scope
                        - startDate
                        - endDate
                        - totalUsage
                        - usageFormat
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - metadata
                        - subLineItems
                        - adjustments
                      additionalProperties: false
                    description: >-
                      Line items that do not belong to any line item group (e.g.
                      contract-level minimum commitments, additional charges,
                      and ungrouped one-off items).
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of invoices, keyed by the
                      key of each custom field. The object is empty when the
                      invoice holds no value. A user edits them in the billing
                      app, and `PUT /v1/invoices/{id}/custom-fields` replaces
                      the whole set, in any status of the invoice.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  sentAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When Aira last sent the invoice by e-mail to its invoice
                      recipients, in an invoice delivery. Null when Aira has not
                      sent it.
                  replaceReason:
                    type: string
                    enum:
                      - contract_allocation_changed
                      - manually_reopened
                      - null
                    nullable: true
                    description: >-
                      Why one invoice of the same invoice slot replaced another,
                      on both invoices of the replacement: manually_reopened for
                      a reopening, and contract_allocation_changed when a change
                      to the contract allocation canceled the invoice and a
                      later billing of its billing act replaced it. Null when
                      the invoice replaces no invoice and no invoice replaces
                      it.
                  replacesInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the canceled invoice that this
                      invoice replaces in its invoice slot. Null when the
                      invoice replaces no invoice.
                  replacedByInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the invoice that replaces this
                      canceled invoice in its invoice slot. Null when no invoice
                      replaces it.
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - paymentAccountId
                  - contractId
                  - contractInvoiceSequence
                  - issuingAccount
                  - billingAccount
                  - invoiceAllocationStrategy
                  - lastCalculatedAt
                  - invoiceNumber
                  - invoiceDate
                  - memo
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - status
                  - isLocked
                  - failureReason
                  - source
                  - autoIssue
                  - amountDue
                  - dueDate
                  - lineItemGroups
                  - standaloneLineItems
                  - customFields
                  - sentAt
                  - replaceReason
                  - replacesInvoiceId
                  - replacedByInvoiceId
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `invalid_customer_reference`: the body has neither a `customerId`
            nor an `externalCustomerId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_customer_reference
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''idempotencyKey'' is required'
                    code: json_schema_validation_error
                invalid_customer_reference:
                  value:
                    message: one of customerId or externalCustomerId must be provided
                    code: invalid_customer_reference
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `customer_not_found`: no customer has the `externalCustomerId`.

            - `customer_payment_account_not_found`: the customer has no payment
            account with the `paymentAccountId`, or no default payment account
            when the body leaves `paymentAccountId` out or null, as for a
            `customerId` that names no customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - customer_not_found
                      - customer_payment_account_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
                customer_payment_account_not_found:
                  value:
                    message: >-
                      the customer has no payment account with the
                      `paymentAccountId`, or no default payment account when the
                      body leaves `paymentAccountId` out or null, as for a
                      `customerId` that names no customer
                    code: customer_payment_account_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `invoice_idempotency_key_conflict`: an invoice already has the
            `idempotencyKey`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_idempotency_key_conflict
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_idempotency_key_conflict:
                  value:
                    message: invoice with this idempotency key already exists
                    code: invoice_idempotency_key_conflict
  /v1/invoices/{id}/pdf:
    get:
      summary: Download invoice PDF
      tags:
        - Invoices
      description: >-
        Downloads the invoice PDF of an invoice, the invoice artifact
        `default:invoice_pdf`, with a file name of the invoice number in the
        Content-Disposition header.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the invoice in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_not_found
          when: no invoice has the `id`
        - status: 404
          code: invoice_pdf_not_found
          when: >-
            the invoice has no invoice PDF, or the storage of Aira holds no file
            for it
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: The invoice PDF file contents.
          content:
            application/json:
              schema:
                type: string
                format: binary
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `id`.

            - `invoice_pdf_not_found`: the invoice has no invoice PDF, or the
            storage of Aira holds no file for it.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - invoice_pdf_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                invoice_pdf_not_found:
                  value:
                    message: invoice pdf not found
                    code: invoice_pdf_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/{invoiceId}/discounts:
    get:
      summary: List invoice discounts
      tags:
        - Invoices
      description: >-
        Lists the discounts applied to an invoice, including system-generated
        ones (the "reason" field shows the origin).


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: boolean
            default: false
          in: query
          name: includeInactive
          required: false
          description: >-
            When true, discounts that were deactivated are included in the
            response.
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice of the invoice discount.
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: >-
            The invoice discounts of the invoice, without the inactive ones
            unless `includeInactive` is true.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        An invoice discount: an amount that an invoice takes
                        off, from the whole invoice, from one of its line item
                        groups or from one of its line items. It is a manual
                        discount, a recurring discount or the contract
                        proration, which takes off the part of the first cycle
                        that a late contract start skips. Only an active invoice
                        discount counts in the totals of the invoice.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: The unique identifier of the invoice discount.
                        target:
                          type: string
                          enum:
                            - invoice
                            - line_item_group
                            - line_item
                          description: >-
                            What the invoice discount takes off from: `invoice`
                            for the whole invoice, `line_item_group` for one
                            line item group, or `line_item` for one line item.
                        targetIdempotencyKey:
                          type: string
                          description: >-
                            The idempotency key of the invoice, the line item
                            group or the line item that `target` names.
                          example: plan:3c90c3cc-0d44-4b50-8888-8dd25736052a
                        method:
                          type: string
                          enum:
                            - fixed
                            - percentage
                          description: >-
                            How to read `amount`: `fixed` takes off an amount in
                            cents, and `percentage` takes off a percentage of
                            the target.
                        reason:
                          type: string
                          enum:
                            - manual_discount
                            - contract_proration
                            - contract_recurring
                          description: >-
                            Why the invoice discount exists: `manual_discount`
                            for a discount that a user or a system created,
                            `contract_proration` for the contract proration, or
                            `contract_recurring` for a recurring discount of the
                            contract.
                        description:
                          type: string
                          minLength: 1
                          description: The text of the invoice discount on the invoice.
                          example: Desconto de boas-vindas
                        amount:
                          type: number
                          multipleOf: 1
                          minimum: 1
                          description: >-
                            The value of the invoice discount, as a positive
                            integer: cents when `method` is `fixed`, or basis
                            points when `method` is `percentage`, where 100
                            basis points are 1% and 10000 are 100%.
                        isActive:
                          type: boolean
                          description: >-
                            Whether the invoice discount counts in the totals of
                            the invoice. Aira keeps an inactive invoice discount
                            for its history, with no effect on the amounts.
                        customFields:
                          type: object
                          description: >-
                            The values of the custom fields of invoice discounts
                            on the invoice discount, keyed by the key of each
                            custom field.
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          default: {}
                          example:
                            customField1: value1
                            customField2:
                              - value2
                              - value3
                      required:
                        - id
                        - target
                        - targetIdempotencyKey
                        - method
                        - reason
                        - description
                        - amount
                        - isActive
                      additionalProperties: false
                    description: A list of items.
                required:
                  - items
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or a query
            parameter breaks the schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `invoiceId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
    post:
      summary: Create invoice discount
      tags:
        - Invoices
      description: >-
        Creates a manual discount on an invoice. The discount can target the
        whole invoice, a line item group, or a single line item (via
        targetIdempotencyKey).


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                target:
                  type: string
                  enum:
                    - invoice
                    - line_item_group
                    - line_item
                  description: >-
                    What the invoice discount takes off from: `invoice` for the
                    whole invoice, `line_item_group` for one line item group, or
                    `line_item` for one line item.
                targetIdempotencyKey:
                  type: string
                  description: >-
                    The idempotency key of the invoice, the line item group or
                    the line item that `target` names.
                  example: plan:3c90c3cc-0d44-4b50-8888-8dd25736052a
                method:
                  type: string
                  enum:
                    - fixed
                    - percentage
                  description: >-
                    How to read `amount`: `fixed` takes off an amount in cents,
                    and `percentage` takes off a percentage of the target.
                description:
                  type: string
                  minLength: 1
                  description: The text of the invoice discount on the invoice.
                  example: Desconto de boas-vindas
                amount:
                  type: number
                  multipleOf: 1
                  minimum: 1
                  description: >-
                    The value of the invoice discount, as a positive integer:
                    cents when `method` is `fixed`, or basis points when
                    `method` is `percentage`, where 100 basis points are 1% and
                    10000 are 100%.
                customFields:
                  type: object
                  description: >-
                    The values of the custom fields of invoice discounts on the
                    invoice discount, keyed by the key of each custom field.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
              required:
                - target
                - targetIdempotencyKey
                - method
                - description
                - amount
              additionalProperties: false
        required: true
        description: >-
          An invoice discount: an amount that an invoice takes off, from the
          whole invoice, from one of its line item groups or from one of its
          line items. It is a manual discount, a recurring discount or the
          contract proration, which takes off the part of the first cycle that a
          late contract start skips. Only an active invoice discount counts in
          the totals of the invoice.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice of the invoice discount.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: the invoice is locked, because it was issued or canceled
        - status: 400
          code: invalid_invoice_discount_amount
          when: the `method` is `percentage` and the `amount` is over 10000
        - status: 400
          code: invoice_not_found
          when: >-
            the `target` is `invoice`, and the `targetIdempotencyKey` is not the
            idempotency key of the invoice
        - status: 400
          code: line_item_group_not_found_for_invoice
          when: >-
            the `target` is `line_item_group`, and no line item group of the
            invoice has the `targetIdempotencyKey`
        - status: 400
          code: line_item_not_found_for_invoice
          when: >-
            the `target` is `line_item`, and no line item of the invoice has the
            `targetIdempotencyKey`
        - status: 400
          code: invalid_custom_fields
          when: >-
            the `customFields` leave out a required custom field of invoice
            discounts, name a key that is not one, or hold a value that its
            custom field does not take
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
      x-required-roles: *ref_8
      responses:
        '201':
          description: >-
            An invoice discount: an amount that an invoice takes off, from the
            whole invoice, from one of its line item groups or from one of its
            line items. It is a manual discount, a recurring discount or the
            contract proration, which takes off the part of the first cycle that
            a late contract start skips. Only an active invoice discount counts
            in the totals of the invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the invoice discount.
                  target:
                    type: string
                    enum:
                      - invoice
                      - line_item_group
                      - line_item
                    description: >-
                      What the invoice discount takes off from: `invoice` for
                      the whole invoice, `line_item_group` for one line item
                      group, or `line_item` for one line item.
                  targetIdempotencyKey:
                    type: string
                    description: >-
                      The idempotency key of the invoice, the line item group or
                      the line item that `target` names.
                    example: plan:3c90c3cc-0d44-4b50-8888-8dd25736052a
                  method:
                    type: string
                    enum:
                      - fixed
                      - percentage
                    description: >-
                      How to read `amount`: `fixed` takes off an amount in
                      cents, and `percentage` takes off a percentage of the
                      target.
                  reason:
                    type: string
                    enum:
                      - manual_discount
                      - contract_proration
                      - contract_recurring
                    description: >-
                      Why the invoice discount exists: `manual_discount` for a
                      discount that a user or a system created,
                      `contract_proration` for the contract proration, or
                      `contract_recurring` for a recurring discount of the
                      contract.
                  description:
                    type: string
                    minLength: 1
                    description: The text of the invoice discount on the invoice.
                    example: Desconto de boas-vindas
                  amount:
                    type: number
                    multipleOf: 1
                    minimum: 1
                    description: >-
                      The value of the invoice discount, as a positive integer:
                      cents when `method` is `fixed`, or basis points when
                      `method` is `percentage`, where 100 basis points are 1%
                      and 10000 are 100%.
                  isActive:
                    type: boolean
                    description: >-
                      Whether the invoice discount counts in the totals of the
                      invoice. Aira keeps an inactive invoice discount for its
                      history, with no effect on the amounts.
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of invoice discounts on
                      the invoice discount, keyed by the key of each custom
                      field.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                required:
                  - id
                  - target
                  - targetIdempotencyKey
                  - method
                  - reason
                  - description
                  - amount
                  - isActive
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is locked, because it was
            issued or canceled.

            - `invalid_invoice_discount_amount`: the `method` is `percentage`
            and the `amount` is over 10000.

            - `invoice_not_found`: the `target` is `invoice`, and the
            `targetIdempotencyKey` is not the idempotency key of the invoice.

            - `line_item_group_not_found_for_invoice`: the `target` is
            `line_item_group`, and no line item group of the invoice has the
            `targetIdempotencyKey`.

            - `line_item_not_found_for_invoice`: the `target` is `line_item`,
            and no line item of the invoice has the `targetIdempotencyKey`.

            - `invalid_custom_fields`: the `customFields` leave out a required
            custom field of invoice discounts, name a key that is not one, or
            hold a value that its custom field does not take.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                      - invalid_invoice_discount_amount
                      - invoice_not_found
                      - line_item_group_not_found_for_invoice
                      - line_item_not_found_for_invoice
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''target'' is required'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
                invalid_invoice_discount_amount:
                  value:
                    message: invoice discount amount must be a positive integer
                    code: invalid_invoice_discount_amount
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                line_item_group_not_found_for_invoice:
                  value:
                    message: line item group not found for the given invoice
                    code: line_item_group_not_found_for_invoice
                line_item_not_found_for_invoice:
                  value:
                    message: line item not found for the given invoice
                    code: line_item_not_found_for_invoice
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `invoiceId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
  /v1/invoices/{id}/fiscal-invoice/download:
    get:
      summary: Download the fiscal document of an invoice
      tags:
        - Invoices
      description: >-
        Downloads the PDF or the XML of the issued fiscal document (NFS-e) of an
        invoice.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
            enum:
              - pdf
              - xml
          in: query
          name: documentType
          required: true
          description: >-
            The file of the fiscal document to download: pdf for its PDF, or xml
            for its XML.
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the invoice in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: fiscal_invoices_module_not_enabled
          when: the fiscal invoices module is off
        - status: 404
          code: invoice_fiscal_document_not_found
          when: >-
            no invoice has the `id`, or the invoice has no issued fiscal
            document
        - status: 404
          code: file_not_found
          when: the issued fiscal document has no file of the `documentType`
        - status: 404
          code: invoice_not_found
          when: >-
            the invoice of the `id` was deleted with its customer, while its
            fiscal document stays issued
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: The contents of the PDF or the XML of the fiscal document.
          content:
            application/json:
              schema:
                type: string
                format: binary
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or a query
            parameter breaks the schema of the endpoint.

            - `fiscal_invoices_module_not_enabled`: the fiscal invoices module
            is off.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - fiscal_invoices_module_not_enabled
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                fiscal_invoices_module_not_enabled:
                  value:
                    message: fiscal invoices module not enabled
                    code: fiscal_invoices_module_not_enabled
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_fiscal_document_not_found`: no invoice has the `id`, or
            the invoice has no issued fiscal document.

            - `file_not_found`: the issued fiscal document has no file of the
            `documentType`.

            - `invoice_not_found`: the invoice of the `id` was deleted with its
            customer, while its fiscal document stays issued.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_fiscal_document_not_found
                      - file_not_found
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_fiscal_document_not_found:
                  value:
                    message: invoice fiscal document not found
                    code: invoice_fiscal_document_not_found
                file_not_found:
                  value:
                    message: email attachment file not found in storage
                    code: file_not_found
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/{invoiceId}/additional-charges:
    get:
      summary: List the additional charges of an invoice
      tags:
        - Invoices
      description: >-
        Lists the additional charges of an invoice, oldest first: the line
        items, not plan charges, that a user or a system added to it by hand.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: The additional charges of the invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A line item, not a plan charge, that a user adds by hand
                        to an invoice.
                      properties:
                        lineItemId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item of the
                            additional charge in our system.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product that the
                            additional charge belongs to.
                        itemId:
                          type: string
                          format: uuid
                          nullable: true
                          description: >-
                            The unique identifier of the catalog item that the
                            additional charge bills. Null when the additional
                            charge names no item.
                        name:
                          type: string
                          description: >-
                            The name of the additional charge, as the invoice
                            shows it.
                          example: Taxa de entrega extra
                        amount:
                          type: integer
                          minimum: 1
                          description: >-
                            The amount that the additional charge bills, in
                            cents.
                        startDate:
                          type: string
                          format: date
                          description: >-
                            The first day of the period that the additional
                            charge bills.
                        endDate:
                          type: string
                          format: date
                          description: >-
                            The last day of the period that the additional
                            charge bills.
                      required:
                        - lineItemId
                        - productId
                        - itemId
                        - name
                        - amount
                        - startDate
                        - endDate
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or a query
            parameter breaks the schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `invoiceId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
    post:
      summary: Add an additional charge to an invoice
      tags:
        - Invoices
      description: >-
        Adds an additional charge to an invoice and updates the amounts of the
        invoice.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                productId:
                  type: string
                  format: uuid
                  description: >-
                    The unique identifier of the product that the additional
                    charge belongs to.
                itemId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    The unique identifier of the catalog item that the
                    additional charge bills. Null when the additional charge
                    names no item.
                name:
                  type: string
                  description: The name of the additional charge, as the invoice shows it.
                  example: Taxa de entrega extra
                amount:
                  type: integer
                  minimum: 1
                  description: The amount that the additional charge bills, in cents.
                startDate:
                  type: string
                  format: date
                  description: >-
                    The first day of the period that the additional charge
                    bills.
                endDate:
                  type: string
                  format: date
                  description: The last day of the period that the additional charge bills.
              required:
                - productId
                - name
                - amount
                - startDate
                - endDate
              additionalProperties: false
        required: true
        description: >-
          The additional charge to add to the invoice. Leave itemId out, or send
          null, when the additional charge names no catalog item.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: the invoice is locked, because it was issued or canceled
        - status: 404
          code: product_not_found
          when: no product has the `productId`
        - status: 404
          code: item_not_found
          when: no item has the `itemId`
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
      x-required-roles: *ref_8
      responses:
        '201':
          description: >-
            A line item, not a plan charge, that a user adds by hand to an
            invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  lineItemId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the line item of the additional
                      charge in our system.
                  productId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the product that the additional
                      charge belongs to.
                  itemId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the catalog item that the
                      additional charge bills. Null when the additional charge
                      names no item.
                  name:
                    type: string
                    description: >-
                      The name of the additional charge, as the invoice shows
                      it.
                    example: Taxa de entrega extra
                  amount:
                    type: integer
                    minimum: 1
                    description: The amount that the additional charge bills, in cents.
                  startDate:
                    type: string
                    format: date
                    description: >-
                      The first day of the period that the additional charge
                      bills.
                  endDate:
                    type: string
                    format: date
                    description: >-
                      The last day of the period that the additional charge
                      bills.
                required:
                  - lineItemId
                  - productId
                  - itemId
                  - name
                  - amount
                  - startDate
                  - endDate
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is locked, because it was
            issued or canceled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''productId'' is required'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `product_not_found`: no product has the `productId`.
            - `item_not_found`: no item has the `itemId`.
            - `invoice_not_found`: no invoice has the `invoiceId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - product_not_found
                      - item_not_found
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                product_not_found:
                  value:
                    message: default product not found
                    code: product_not_found
                item_not_found:
                  value:
                    message: item not found
                    code: item_not_found
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
  /v1/invoices/{invoiceId}/attachments:
    get:
      summary: List the attachments of an invoice
      tags:
        - Invoices
      description: >-
        Lists the invoice attachments of an invoice, oldest first: the files
        that a user or a system uploaded to it.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice that the attachment belongs to.
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: The invoice attachments of the invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: A file that a user uploads to an invoice.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the invoice attachment in
                            our system.
                        invoiceId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the invoice that the
                            attachment belongs to.
                        filename:
                          type: string
                          description: The name of the file, which its download carries.
                          example: pedido-de-compra-novembro.pdf
                        fileExtension:
                          type: string
                          enum:
                            - pdf
                            - csv
                            - xlsx
                            - xlsm
                            - xml
                            - zip
                          description: >-
                            The extension of the file, taken from the name of
                            the uploaded file. A file whose name has another
                            extension, or none, is recorded as pdf.
                        includeInDelivery:
                          type: boolean
                          description: >-
                            Whether an invoice delivery attaches the file, when
                            the dunning step of the delivery carries the invoice
                            attachments. An uploaded file starts with false.
                      required:
                        - id
                        - invoiceId
                        - filename
                        - fileExtension
                        - includeInDelivery
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or a query
            parameter breaks the schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `invoiceId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
    post:
      summary: Upload attachments to an invoice
      tags:
        - Invoices
      description: >-
        Uploads files to an invoice and creates an invoice attachment for each,
        which no invoice delivery attaches until includeInDelivery is true. Send
        a multipart/form-data form with one file part for each file, of up to 5
        MB. A file whose name has an extension outside pdf, csv, xlsx, xlsm, xml
        and zip is recorded as pdf.


        Requires the role `invoices:write`.
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              nullable: true
              properties:
                file:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: >-
                    The files to attach, each up to 5 MB. Repeat the field once
                    for each file. Each file part needs a file name, from which
                    Aira takes the extension of the file.
              required:
                - file
        required: true
        description: A multipart/form-data form with one file part for each file to attach.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice that the attachment belongs to.
      x-public-api: true
      x-errors:
        - status: 400
          code: file_not_provided
          when: the form carries no file part with a file name
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
      x-required-roles: *ref_8
      responses:
        '201':
          description: >-
            The invoice attachments that the upload created, in the order of the
            files in the form.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: A file that a user uploads to an invoice.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the invoice attachment in
                            our system.
                        invoiceId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the invoice that the
                            attachment belongs to.
                        filename:
                          type: string
                          description: The name of the file, which its download carries.
                          example: pedido-de-compra-novembro.pdf
                        fileExtension:
                          type: string
                          enum:
                            - pdf
                            - csv
                            - xlsx
                            - xlsm
                            - xml
                            - zip
                          description: >-
                            The extension of the file, taken from the name of
                            the uploaded file. A file whose name has another
                            extension, or none, is recorded as pdf.
                        includeInDelivery:
                          type: boolean
                          description: >-
                            Whether an invoice delivery attaches the file, when
                            the dunning step of the delivery carries the invoice
                            attachments. An uploaded file starts with false.
                      required:
                        - id
                        - invoiceId
                        - filename
                        - fileExtension
                        - includeInDelivery
                      additionalProperties: false
                    description: A list of items.
                required:
                  - items
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `file_not_provided`: the form carries no file part with a file
            name.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - file_not_provided
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''file'' is required'
                    code: json_schema_validation_error
                file_not_provided:
                  value:
                    message: file not provided
                    code: file_not_provided
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `invoiceId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
        '413':
          description: >-
            A file or the body of the request is larger than its limit.


            - `file_too_large`: a file of the form is larger than the limit of
            the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - file_too_large
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                file_too_large:
                  value:
                    message: a file of the request is larger than the limit
                    code: file_too_large
  /v1/invoices/{invoiceId}/attachments/{attachmentId}/download:
    get:
      summary: Download an attachment of an invoice
      tags:
        - Invoices
      description: >-
        Downloads the file of an invoice attachment, as
        application/octet-stream, with the filename of the attachment in the
        Content-Disposition header: in `filename*`, encoded in UTF-8, and in
        `filename`, with an underscore in place of each character outside
        Latin-1, of a double quote and of a backslash.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice that the attachment belongs to.
        - schema:
            type: string
            format: uuid
          in: path
          name: attachmentId
          required: true
          description: The unique identifier of the invoice attachment in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - status: 404
          code: invoice_attachment_not_found
          when: >-
            no invoice attachment of the invoice has the `attachmentId`, or the
            storage of Aira holds no file for it
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: The contents of the file of the invoice attachment.
          headers:
            Content-Disposition:
              schema:
                type: string
              description: >-
                attachment; filename="<filename>", with the filename of the
                invoice attachment.
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `invoiceId`.

            - `invoice_attachment_not_found`: no invoice attachment of the
            invoice has the `attachmentId`, or the storage of Aira holds no file
            for it.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - invoice_attachment_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                invoice_attachment_not_found:
                  value:
                    message: invoice attachment not found
                    code: invoice_attachment_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/{id}/artifacts/{invoiceArtifactId}:
    get:
      summary: Download an invoice artifact
      tags:
        - Invoices
      description: >-
        Downloads the file of an invoice artifact, any one of the artifacts that
        the invoice lists, such as the invoice PDF, with the content type of its
        file extension and a file name of the invoice number and the file
        extension in the Content-Disposition header.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the invoice in our system.
        - schema:
            type: string
            format: uuid
          example: 3c90c3cc-0d44-4b50-8888-8dd25736052a
          in: path
          name: invoiceArtifactId
          required: true
          description: >-
            The unique identifier of the invoice artifact, as the artifacts of
            the invoice list it.
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_not_found
          when: no invoice has the `id`
        - status: 404
          code: invoice_artifact_not_found
          when: >-
            no invoice artifact has the `invoiceArtifactId`, or Aira skipped
            that invoice artifact and made no file
        - status: 404
          code: invoice_artifact_from_other_invoice
          when: the invoice artifact belongs to another invoice
        - status: 404
          code: invoice_artifact_file_not_found
          when: the storage of Aira holds no file for the invoice artifact
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: >-
            The contents of the file of the invoice artifact, with the content
            type of its file extension.
          headers:
            Content-Disposition:
              schema:
                type: string
              description: >-
                attachment; filename="<invoiceNumber>.<fileExtension>", with the
                number of the invoice and the file extension of the invoice
                artifact.
          content:
            application/pdf:
              schema:
                type: string
                format: binary
            text/csv:
              schema:
                type: string
                format: binary
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: binary
            application/vnd.ms-excel.sheet.macroEnabled.12:
              schema:
                type: string
                format: binary
            application/xml:
              schema:
                type: string
                format: binary
            application/zip:
              schema:
                type: string
                format: binary
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `id`.

            - `invoice_artifact_not_found`: no invoice artifact has the
            `invoiceArtifactId`, or Aira skipped that invoice artifact and made
            no file.

            - `invoice_artifact_from_other_invoice`: the invoice artifact
            belongs to another invoice.

            - `invoice_artifact_file_not_found`: the storage of Aira holds no
            file for the invoice artifact.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - invoice_artifact_not_found
                      - invoice_artifact_from_other_invoice
                      - invoice_artifact_file_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                invoice_artifact_not_found:
                  value:
                    message: invoice artifact not found
                    code: invoice_artifact_not_found
                invoice_artifact_from_other_invoice:
                  value:
                    message: invoice artifact from other invoice
                    code: invoice_artifact_from_other_invoice
                invoice_artifact_file_not_found:
                  value:
                    message: invoice artifact file not found in storage
                    code: invoice_artifact_file_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/sync:
    get:
      summary: List invoice syncs
      tags:
        - Invoices
      description: >-
        Lists the invoice syncs: the sends of the issued invoices to the ERP,
        with their results. The list orders them by the end of their last
        attempt, newest first, and places an invoice sync with no attempt yet by
        the time that Aira created it. An invoice has at most one invoice sync
        in the list, because a retry replaces the failed invoice sync of the
        invoice.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: array
            items:
              type: string
              enum:
                - pending
                - success
                - failed
              description: >-
                The result of the invoice sync: pending (Aira has not finished
                sending the invoice), success (the ERP received the invoice) or
                failed (the last attempt failed, and message tells why).
          in: query
          name: status[]
          required: false
          description: Only return the invoice syncs in these statuses.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: The invoice syncs that match the filters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        One send of an issued invoice to the ERP, with its
                        result.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the invoice sync in our
                            system.
                        invoiceId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the invoice that Aira sends
                            to the ERP.
                        invoiceNumber:
                          type: string
                          description: >-
                            The number of the invoice that Aira sends to the
                            ERP.
                          example: ACMEI-0042
                        provider:
                          type: string
                          enum:
                            - omie
                            - netsuite
                            - senior
                            - contaazul
                          description: The ERP that receives the invoice.
                        providerId:
                          type: string
                          nullable: true
                          description: >-
                            The identifier of the record that holds the invoice
                            in the ERP, such as the contract in Senior or the
                            sale in Conta Azul. Null while the ERP holds no
                            record of the invoice.
                          example: '4815162342'
                        status:
                          type: string
                          enum:
                            - pending
                            - success
                            - failed
                          description: >-
                            The result of the invoice sync: pending (Aira has
                            not finished sending the invoice), success (the ERP
                            received the invoice) or failed (the last attempt
                            failed, and message tells why).
                        message:
                          type: string
                          nullable: true
                          description: >-
                            The code of the reason why the last attempt failed,
                            such as `invoice_billing_account_missing_tax_id`, or
                            `unknown` for a reason that Aira does not name. Null
                            unless the last attempt failed.
                          example: invoice_billing_account_missing_tax_id
                        lastProcessedAt:
                          type: string
                          format: date-time
                          nullable: true
                          description: >-
                            When the last attempt to send the invoice to the ERP
                            ended, with success or failure. Null before the
                            first attempt ends.
                        retriesCount:
                          type: integer
                          minimum: 0
                          description: >-
                            The number of attempts that Aira made to send the
                            invoice to the ERP.
                      required:
                        - id
                        - invoiceId
                        - invoiceNumber
                        - provider
                        - providerId
                        - status
                        - message
                        - lastProcessedAt
                        - retriesCount
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''status[]'' must be array'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/status-summary:
    get:
      summary: Fetch invoice status summary
      tags:
        - Invoices
      description: >-
        Counts the invoices that the filters of `GET /v1/invoices` select and
        sums their total amounts, for each status and in total, so that one call
        totals the invoices of a customer, a period or a status.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
          example: Mercado Bom Preço
          in: query
          name: search
          required: false
          description: >-
            Free-text search over the invoice number, the customer name and the
            names of the customers whose usage the invoice bills, such as the
            subsidiaries of an organization.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: customerIds[]
          required: false
          description: Only return invoices billing these customers.
        - schema:
            type: array
            items:
              type: string
              enum:
                - open
                - in_review
                - issued
                - synced
                - pending
                - paid
                - overdue
                - canceled
                - failed
          in: query
          name: status[]
          required: false
          description: >-
            Only return invoices in these statuses. Canceled invoices are
            controlled by includeCanceled, not by this filter.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeCanceled
          required: false
          description: >-
            When false, canceled invoices are excluded. When true, canceled
            invoices are added to the statuses selected in status[]; if no
            status[] is provided, only canceled invoices are returned.
        - schema:
            type: boolean
            default: false
          in: query
          name: hideZeroAmount
          required: false
          description: When true, invoices with a zero total amount are excluded.
        - schema:
            type: string
            format: date
          in: query
          name: invoiceDate.gte
          required: false
          description: Only return invoices whose invoice date is on or after this date.
        - schema:
            type: string
            format: date
          in: query
          name: invoiceDate.lte
          required: false
          description: Only return invoices whose invoice date is on or before this date.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: contractIds[]
          required: false
          description: Only return the invoices of these contracts.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: productIds[]
          required: false
          description: >-
            Only return the invoices with at least one line item of these
            products.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: paymentAccountIds[]
          required: false
          description: Only return the invoices that bill these payment accounts.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: legalEntityIds[]
          required: false
          description: >-
            Only return the invoices of these legal entities: an invoice of a
            contract when its contract names one of them, and an invoice without
            a contract, such as a one-off invoice, when one of them is the
            default legal entity.
        - schema:
            type: object
            properties:
              contract:
                type: object
                description: >-
                  The custom field values of the contract of the invoice. An
                  invoice without a contract never matches.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
              customer:
                type: object
                description: The custom field values of the customer of the invoice.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
              product:
                type: object
                description: >-
                  The custom field values of a product. An invoice matches when
                  at least one of its line items bills a product that holds
                  them.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
              item:
                type: object
                description: >-
                  The custom field values of an item. An invoice matches when at
                  least one of its line items bills an item that holds them.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
            additionalProperties: false
          in: query
          name: customField
          required: false
          description: >-
            Only return the invoices whose records hold these custom field
            values, keyed by the record and then by the key of the custom field,
            as in `customField[contract][region][]=south`. An invoice matches a
            key when the record holds one of its values, and it matches the
            filter when it matches every key.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_custom_fields
          when: >-
            a key of the `customField` filter names no custom field of its
            record
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: >-
            The number of the invoices that match the filters and the sum of
            their total amounts, for each invoice status and in total.
          content:
            application/json:
              schema:
                type: object
                properties:
                  byStatus:
                    type: array
                    description: >-
                      One item for each invoice status that the invoice settings
                      list, in their order, with zeros for a status that no
                      selected invoice holds.
                    items:
                      type: object
                      properties:
                        status:
                          type: string
                          enum:
                            - open
                            - in_review
                            - issued
                            - synced
                            - pending
                            - paid
                            - overdue
                            - canceled
                            - failed
                          description: The invoice status.
                        count:
                          type: number
                          description: The number of selected invoices in this status.
                        totalAmount:
                          type: number
                          description: >-
                            The sum of the total amounts of the selected
                            invoices in this status, in cents.
                      required:
                        - status
                        - count
                        - totalAmount
                      additionalProperties: false
                  totalCount:
                    type: number
                    description: >-
                      The number of selected invoices across the statuses of
                      `byStatus`.
                  totalAmount:
                    type: number
                    description: >-
                      The sum of the total amounts of the selected invoices
                      across the statuses of `byStatus`, in cents.
                required:
                  - byStatus
                  - totalCount
                  - totalAmount
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.

            - `invalid_custom_fields`: a key of the `customField` filter names
            no custom field of its record.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''search'' must be string'
                    code: json_schema_validation_error
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/{id}/pdf/link:
    get:
      summary: Fetch a download link of the invoice PDF
      tags:
        - Invoices
      description: >-
        Answers a URL that downloads the file of `GET /v1/invoices/:id/pdf` with
        no API key for five minutes, after the same checks, for a client that
        cannot receive a file, such as a chat client.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the invoice in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_not_found
          when: no invoice has the `id`
        - status: 404
          code: invoice_pdf_not_found
          when: >-
            the invoice has no invoice PDF, or the storage of Aira holds no file
            for it
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: >-
            A link that downloads one file with no API key, for a client that
            cannot receive a file, such as a chat client.
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                    format: uri
                    description: >-
                      The URL that downloads the file with no API key until
                      `expiresAt`. Whoever holds the URL downloads the file, so
                      share it only with whoever may read the file.
                  fileName:
                    type: string
                    description: The name of the file that the URL downloads.
                    example: PADAR-00042.pdf
                  expiresAt:
                    type: string
                    format: date-time
                    description: >-
                      The instant, in UTC, when the URL stops working, five
                      minutes after Aira creates it.
                required:
                  - url
                  - fileName
                  - expiresAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `id`.

            - `invoice_pdf_not_found`: the invoice has no invoice PDF, or the
            storage of Aira holds no file for it.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - invoice_pdf_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                invoice_pdf_not_found:
                  value:
                    message: invoice pdf not found
                    code: invoice_pdf_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/{id}/artifacts/{invoiceArtifactId}/link:
    get:
      summary: Fetch a download link of an invoice artifact
      tags:
        - Invoices
      description: >-
        Answers a URL that downloads the file of `GET
        /v1/invoices/:id/artifacts/:invoiceArtifactId` with no API key for five
        minutes, after the same checks, for a client that cannot receive a file,
        such as a chat client.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the invoice in our system.
        - schema:
            type: string
            format: uuid
          example: 3c90c3cc-0d44-4b50-8888-8dd25736052a
          in: path
          name: invoiceArtifactId
          required: true
          description: >-
            The unique identifier of the invoice artifact, as the artifacts of
            the invoice list it.
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_not_found
          when: no invoice has the `id`
        - status: 404
          code: invoice_artifact_not_found
          when: >-
            no invoice artifact has the `invoiceArtifactId`, or Aira skipped
            that invoice artifact and made no file
        - status: 404
          code: invoice_artifact_from_other_invoice
          when: the invoice artifact belongs to another invoice
        - status: 404
          code: invoice_artifact_file_not_found
          when: the storage of Aira holds no file for the invoice artifact
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: >-
            A link that downloads one file with no API key, for a client that
            cannot receive a file, such as a chat client.
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                    format: uri
                    description: >-
                      The URL that downloads the file with no API key until
                      `expiresAt`. Whoever holds the URL downloads the file, so
                      share it only with whoever may read the file.
                  fileName:
                    type: string
                    description: The name of the file that the URL downloads.
                    example: PADAR-00042.pdf
                  expiresAt:
                    type: string
                    format: date-time
                    description: >-
                      The instant, in UTC, when the URL stops working, five
                      minutes after Aira creates it.
                required:
                  - url
                  - fileName
                  - expiresAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `id`.

            - `invoice_artifact_not_found`: no invoice artifact has the
            `invoiceArtifactId`, or Aira skipped that invoice artifact and made
            no file.

            - `invoice_artifact_from_other_invoice`: the invoice artifact
            belongs to another invoice.

            - `invoice_artifact_file_not_found`: the storage of Aira holds no
            file for the invoice artifact.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - invoice_artifact_not_found
                      - invoice_artifact_from_other_invoice
                      - invoice_artifact_file_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                invoice_artifact_not_found:
                  value:
                    message: invoice artifact not found
                    code: invoice_artifact_not_found
                invoice_artifact_from_other_invoice:
                  value:
                    message: invoice artifact from other invoice
                    code: invoice_artifact_from_other_invoice
                invoice_artifact_file_not_found:
                  value:
                    message: invoice artifact file not found in storage
                    code: invoice_artifact_file_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/{invoiceId}/attachments/{attachmentId}/download/link:
    get:
      summary: Fetch a download link of an attachment of an invoice
      tags:
        - Invoices
      description: >-
        Answers a URL that downloads the file of `GET
        /v1/invoices/:invoiceId/attachments/:attachmentId/download` with no API
        key for five minutes, after the same checks, for a client that cannot
        receive a file, such as a chat client.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice that the attachment belongs to.
        - schema:
            type: string
            format: uuid
          in: path
          name: attachmentId
          required: true
          description: The unique identifier of the invoice attachment in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - status: 404
          code: invoice_attachment_not_found
          when: >-
            no invoice attachment of the invoice has the `attachmentId`, or the
            storage of Aira holds no file for it
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: >-
            A link that downloads one file with no API key, for a client that
            cannot receive a file, such as a chat client.
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                    format: uri
                    description: >-
                      The URL that downloads the file with no API key until
                      `expiresAt`. Whoever holds the URL downloads the file, so
                      share it only with whoever may read the file.
                  fileName:
                    type: string
                    description: The name of the file that the URL downloads.
                    example: PADAR-00042.pdf
                  expiresAt:
                    type: string
                    format: date-time
                    description: >-
                      The instant, in UTC, when the URL stops working, five
                      minutes after Aira creates it.
                required:
                  - url
                  - fileName
                  - expiresAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `invoiceId`.

            - `invoice_attachment_not_found`: no invoice attachment of the
            invoice has the `attachmentId`, or the storage of Aira holds no file
            for it.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - invoice_attachment_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                invoice_attachment_not_found:
                  value:
                    message: invoice attachment not found
                    code: invoice_attachment_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/{id}/fiscal-invoice/download/link:
    get:
      summary: Fetch a download link of the fiscal document of an invoice
      tags:
        - Invoices
      description: >-
        Answers a URL that downloads the file of `GET
        /v1/invoices/:id/fiscal-invoice/download` with no API key for five
        minutes, after the same checks, for a client that cannot receive a file,
        such as a chat client.


        Requires the role `invoices:read`.
      parameters:
        - schema:
            type: string
            enum:
              - pdf
              - xml
          in: query
          name: documentType
          required: true
          description: >-
            The file of the fiscal document to download: pdf for its PDF, or xml
            for its XML.
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the invoice in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: fiscal_invoices_module_not_enabled
          when: the fiscal invoices module is off
        - status: 404
          code: invoice_fiscal_document_not_found
          when: >-
            no invoice has the `id`, or the invoice has no issued fiscal
            document
        - status: 404
          code: file_not_found
          when: the issued fiscal document has no file of the `documentType`
        - status: 404
          code: invoice_not_found
          when: >-
            the invoice of the `id` was deleted with its customer, while its
            fiscal document stays issued
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: >-
            A link that downloads one file with no API key, for a client that
            cannot receive a file, such as a chat client.
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                    format: uri
                    description: >-
                      The URL that downloads the file with no API key until
                      `expiresAt`. Whoever holds the URL downloads the file, so
                      share it only with whoever may read the file.
                  fileName:
                    type: string
                    description: The name of the file that the URL downloads.
                    example: PADAR-00042.pdf
                  expiresAt:
                    type: string
                    format: date-time
                    description: >-
                      The instant, in UTC, when the URL stops working, five
                      minutes after Aira creates it.
                required:
                  - url
                  - fileName
                  - expiresAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or a query
            parameter breaks the schema of the endpoint.

            - `fiscal_invoices_module_not_enabled`: the fiscal invoices module
            is off.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - fiscal_invoices_module_not_enabled
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                fiscal_invoices_module_not_enabled:
                  value:
                    message: fiscal invoices module not enabled
                    code: fiscal_invoices_module_not_enabled
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_fiscal_document_not_found`: no invoice has the `id`, or
            the invoice has no issued fiscal document.

            - `file_not_found`: the issued fiscal document has no file of the
            `documentType`.

            - `invoice_not_found`: the invoice of the `id` was deleted with its
            customer, while its fiscal document stays issued.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_fiscal_document_not_found
                      - file_not_found
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_fiscal_document_not_found:
                  value:
                    message: invoice fiscal document not found
                    code: invoice_fiscal_document_not_found
                file_not_found:
                  value:
                    message: email attachment file not found in storage
                    code: file_not_found
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/artifact-types:
    get:
      summary: List invoice artifact types
      tags:
        - Invoices
      description: >-
        Lists every type of invoice artifact that Aira generates, with its key
        and its name, which are the invoice artifacts that a dunning step can
        attach. Aira's team sets the list, so it has no paging.


        Requires the role `invoices:read`.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: *ref_7
      responses:
        '200':
          description: >-
            Every type of invoice artifact that Aira generates, in the order
            that Aira's team set.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A type of invoice artifact, a file that Aira generates
                        for an invoice, such as the invoice PDF or a usage
                        statement.
                      properties:
                        type:
                          anyOf:
                            - enum:
                                - default:invoice_pdf
                            - type: string
                              pattern: ^custom:.+$
                          description: >-
                            The key of the type of invoice artifact:
                            `default:invoice_pdf` for the invoice PDF, or
                            `custom:` and a name for an invoice artifact that
                            Aira writes for you. The `attachments` of a dunning
                            step name it.
                        label:
                          type:
                            - 'null'
                            - string
                          description: >-
                            The name of the type of invoice artifact, or null
                            when it has none.
                          example: Demonstrativo de uso
                      required:
                        - type
                        - label
                      additionalProperties: false
                    description: A list of items.
                required:
                  - items
                additionalProperties: false
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/invoices/{invoiceId}:
    put:
      summary: Update invoice
      tags:
        - Invoices
      description: >-
        Updates the invoice date and memo of a one-off invoice. Only one-off
        invoices can be modified through the public API.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                invoiceDate:
                  type: string
                  format: date
                  description: >-
                    The closing date of the invoice. It represents the end date
                    of the period covered by the invoice.
                memo:
                  type: string
                  description: The memo to attach to the invoice.
                  example: Entregas de novembro
              required:
                - invoiceDate
                - memo
              additionalProperties: false
        required: true
        description: >-
          Schema for updating a one-off invoice. Only invoiceDate and memo are
          mutable through this endpoint.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice to update.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: >-
            the invoice is not a one-off invoice, or it is locked, because it
            was issued or canceled
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            The document that bills one payment account of a customer: from a
            billing act of a contract, as a one-off invoice or from an import.
            It locks when it is issued or canceled, and Aira never recalculates
            a locked invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the invoice in our system.
                  idempotencyKey:
                    type: string
                    description: >-
                      A unique key that identifies the invoice for idempotent
                      creation. Supplied by the caller for one-off invoices;
                      generated by the billing engine for contract invoices.
                    example: padaria-central-2026-11
                  customerId:
                    type: string
                    format: uuid
                    description: The unique identifier of the customer this invoice bills.
                  paymentAccountId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the customer payment account used
                      as the billing account for this invoice.
                  contractId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the contract that generated this
                      invoice. Null for invoices not generated from a contract
                      (e.g. one-off and imported invoices).
                  contractInvoiceSequence:
                    type: integer
                    minimum: 1
                    nullable: true
                    description: >-
                      The number of the invoice within its contract, in the
                      order that Aira created the contract's invoices: 1 for the
                      first, 2 for the next, and so on. Every invoice gets its
                      own number, including each invoice of a split across
                      payment accounts and the replacement of a reopened
                      invoice, and a number never changes and is never reused.
                      Null for invoices without a contract.
                  issuingAccount:
                    type: object
                    description: >-
                      Snapshot of the legal entity issuing the invoice (the
                      seller), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  billingAccount:
                    type: object
                    description: >-
                      Snapshot of the billed party (the legal entity behind the
                      customer payment account), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How the originating contract distributes charges across
                      payment accounts: single bills a single payment account;
                      percent_split divides the total between payment accounts
                      by configured percentages; subsidiary_usage_split divides
                      it according to each subsidiary's usage.
                  lastCalculatedAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When the invoice amounts were last computed by the billing
                      engine. Null when the invoice has never been calculated.
                  invoiceNumber:
                    type: string
                    description: >-
                      Human-readable invoice number, built from the customer's
                      invoice prefix plus a sequential counter.
                    example: ACMEI-0042
                  invoiceDate:
                    type: string
                    format: date
                    description: >-
                      The date of the invoice. On a contract invoice it is the
                      date of its billing act: the first day of the first
                      billing cycle that the contract invoices for an activation
                      invoice, and the last day of the billing cycle for a
                      closing invoice. Its line items state the periods that it
                      bills. On a one-off or imported invoice it is the date
                      given when the invoice was created.
                  memo:
                    type: string
                    nullable: true
                    description: >-
                      Free-form memo attached to the invoice. On contract
                      invoices, it reads "Período <start> a <end>" with the
                      period of the line item that bills most often, such as the
                      month when a monthly fee is billed with an annual fee.
                      When two line items bill equally often, it uses the
                      earlier period. Null when absent.
                    example: Período 01/11/2026 a 30/11/2026
                  subtotalAmount:
                    type: number
                    description: >-
                      Sum of the line item subtotals before adjustments, in
                      cents.
                  adjustmentAmount:
                    type: number
                    description: >-
                      Net amount of all adjustments applied to the invoice line
                      items (discounts and allocation offsets), in cents.
                      Negative when adjustments reduce the amount owed.
                  totalAmount:
                    type: number
                    description: >-
                      Final invoice amount, in cents: subtotalAmount +
                      adjustmentAmount.
                  discountAmount:
                    type: number
                    description: >-
                      The discount portion of adjustmentAmount, in cents (sum of
                      monetary discount adjustments only). Negative when
                      discounts were applied.
                  status:
                    type: string
                    enum:
                      - open
                      - in_review
                      - issued
                      - synced
                      - pending
                      - paid
                      - overdue
                      - canceled
                      - failed
                    description: >-
                      Current status of the invoice lifecycle: open
                      (accumulating charges, editable), in_review (flagged for
                      manual review before issuing), issued (finalized and
                      issued to the customer), synced (registered in the
                      external ERP/payment provider), pending (a payment was
                      initiated and awaits settlement), paid, overdue (unpaid
                      past the due date), canceled, or failed (an issue/sync
                      attempt failed and needs attention).
                  isLocked:
                    type: boolean
                    description: >-
                      Whether the invoice contents are locked against edits.
                      Aira locks an invoice when it issues or cancels it,
                      together with the other invoices of its allocation group,
                      except when it cancels the invoice because its payment
                      account left the allocation of the contract, which locks
                      only that invoice. A locked invoice stays locked, also
                      when its status later moves to failed.
                  failureReason:
                    type: string
                    nullable: true
                    description: >-
                      Reason for the most recent failure on the invoice (e.g. an
                      ERP sync or payment issue). Null when the invoice has no
                      active failure.
                    example: contract_sync_not_found
                  source:
                    type: string
                    enum:
                      - contract
                      - one_off
                      - import
                    description: >-
                      How the invoice originated: contract (generated by a
                      contract billing cycle), one_off (created manually or
                      through the API), or import (ingested from an external
                      system).
                  autoIssue:
                    type: boolean
                    description: >-
                      Whether the invoice is issued automatically when its
                      billing cycle closes, without manual review.
                  amountDue:
                    type: number
                    nullable: true
                    description: >-
                      Outstanding amount due on the invoice, in cents. Null when
                      not tracked.
                  dueDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Payment due date of the invoice. Null when no due date is
                      set (e.g. before the invoice is issued).
                  lineItemGroups:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a line item group: a container that
                        gathers the line items generated from one plan instance
                        (or created as a group on one-off invoices). Monetary
                        amounts are integers in cents.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item group in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the group within the
                            invoice. Supplied by the caller for one-off groups;
                            generated by the billing engine otherwise.
                          example: servicos-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this group bills.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this group
                            belongs to.
                        planId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan whose instance
                            generated this group. Null for groups not generated
                            from a plan (e.g. on one-off invoices).
                        planInstanceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan instance that
                            generated this group. Null for groups not generated
                            from a plan instance.
                        name:
                          type: string
                          description: >-
                            Display name of the group as it appears on the
                            invoice, typically the plan or product name.
                          example: Plano Entregas
                        startDate:
                          type: string
                          format: date
                          description: >-
                            Start of the period that the group shows. On
                            contract invoices, it is the period of the group's
                            line item that bills most often, such as the month
                            when a monthly fee is billed with an annual fee.
                            When two line items bill equally often, it is the
                            earlier period.
                        endDate:
                          type: string
                          format: date
                          description: >-
                            End of the period that the group shows, which
                            `startDate` describes.
                        subtotalAmount:
                          type: number
                          description: >-
                            Sum of the group's line item subtotals before
                            adjustments, in cents.
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to the group's
                            line items (discounts and allocation offsets), in
                            cents. Negative when adjustments reduce the amount
                            owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final group amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        lineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              One amount on an invoice, such as a plan charge,
                              the contract minimum, a tax gross-up (the withheld
                              ISS, the municipal service tax, added on top), a
                              one-off amount or an additional charge.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the line item in our
                                  system.
                              idempotencyKey:
                                type: string
                                description: >-
                                  A unique key that identifies the line item
                                  within the invoice. Supplied by the caller for
                                  one-off line items; generated by the billing
                                  engine otherwise.
                                example: entrega-novembro
                              customerId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the customer whose
                                  consumption this line item bills. On split or
                                  consolidated invoices it may be a subsidiary
                                  of the invoice's customer.
                              productId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the product this line
                                  item belongs to.
                              itemId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the catalog item this
                                  line bills. Null for line items not backed by
                                  a catalog item.
                              resourceId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the metered resource
                                  behind a usage_based line item. Null for line
                                  items not driven by resource usage.
                              licenseId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the license behind a
                                  license_based line item. Null for line items
                                  not driven by a license count.
                              lineItemGroupId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the line item group
                                  containing this line item. Null for standalone
                                  line items.
                              name:
                                type: string
                                description: >-
                                  Display name of the line item as it appears on
                                  the invoice.
                                example: Entregas
                              scope:
                                type: string
                                enum:
                                  - credit_purchase
                                  - contract_minimum_commitment
                                  - minimum_commitment
                                  - fixed
                                  - usage_based
                                  - license_based
                                  - custom
                                  - additional_charge
                                  - one_off
                                  - tax_gross_up
                                description: >-
                                  What the line item charges for: usage_based
                                  (metered resource consumption), license_based
                                  (a license's reported count billed in full),
                                  fixed (recurring fixed charge of a plan),
                                  custom (custom plan charge, priced by a
                                  calculator that Aira writes for you),
                                  minimum_commitment (plan-level minimum
                                  top-up), contract_minimum_commitment
                                  (contract-level minimum top-up),
                                  credit_purchase (credit pool top-up),
                                  additional_charge (extra charge added
                                  manually), one_off (line item of a one-off
                                  invoice), or tax_gross_up (tax gross-up
                                  charge).
                              startDate:
                                type: string
                                format: date
                                description: Start of the period covered by this line item.
                              endDate:
                                type: string
                                format: date
                                description: End of the period covered by this line item.
                              totalUsage:
                                type: number
                                nullable: true
                                description: >-
                                  Total usage billed by the line item, in the
                                  unit given by usageFormat. Null for line items
                                  without a single usage (e.g. fixed charges
                                  without a quantity, and custom line items
                                  whose calculator returns no total).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read totalUsage, and the usage of each
                                  sub-line item that has no usageFormat of its
                                  own: unit means a count of resource units or a
                                  fixed charge quantity; currency means a
                                  monetary base amount in cents. Null when the
                                  line item has no single usage, as a custom
                                  line item whose sub-line items bill different
                                  kinds of volume, each with its own
                                  usageFormat.
                              subtotalAmount:
                                type: number
                                description: >-
                                  Line item amount before adjustments, in cents
                                  (sum of its sub-line item amounts).
                              adjustmentAmount:
                                type: number
                                description: >-
                                  Net amount of the adjustments applied to this
                                  line item (discounts and allocation offsets),
                                  in cents. Negative when adjustments reduce the
                                  amount owed.
                              totalAmount:
                                type: number
                                description: >-
                                  Final line item amount, in cents:
                                  subtotalAmount + adjustmentAmount.
                              discountAmount:
                                type: number
                                description: >-
                                  The discount portion of adjustmentAmount, in
                                  cents (sum of monetary discount adjustments
                                  only). Negative when discounts were applied.
                              metadata:
                                description: >-
                                  Pricing metadata for the line item, where the
                                  shape is keyed by type. Always present, but
                                  null for line items without pricing metadata:
                                  credit_purchase, additional_charge, one_off,
                                  and tax_gross_up. It is populated for fixed
                                  (the billing timing), usage_based,
                                  license_based, minimum_commitment,
                                  contract_minimum_commitment, and custom (the
                                  definition and the calculation memory) line
                                  items.
                                anyOf:
                                  - title: Fixed
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed
                                        description: >-
                                          Discriminator: metadata for a fixed line
                                          item.
                                      billingTiming:
                                        type: string
                                        enum:
                                          - in_advance
                                          - in_arrears
                                        description: >-
                                          Whether the fee was billed in advance of
                                          its service period or after it.
                                    required:
                                      - type
                                      - billingTiming
                                  - title: Usage-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - usage_based
                                        description: >-
                                          Discriminator: metadata for a
                                          usage_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the metered resource accrues over
                                          the billing period: in_full bills the
                                          full usage of the period; proration
                                          weighs usage by the fraction of the
                                          period each amount was held.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          usage was divided across tiers.
                                          unique_tier prices all usage at the
                                          single tier that contains the total;
                                          progressive prices each tier's band
                                          separately. Absent for non-tiered
                                          models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item. Charges
                                          priced before pricing models existed are
                                          reported as advanced.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: License-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_based
                                        description: >-
                                          Discriminator: metadata for a
                                          license_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the license count accrues over the
                                          billing period. Always in_full: the
                                          latest reported count is billed in full.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          the license count was divided across
                                          tiers. unique_tier prices the whole
                                          count at the single tier that contains
                                          the total; progressive prices each
                                          tier's band separately. Absent for
                                          non-tiered models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: Contract minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - contract_minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a
                                          contract_minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          whole contract in the billing period, in
                                          cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the contract's consumption amounted
                                          to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a plan-level
                                          minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          plan in the billing period, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the plan's consumption amounted to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Custom
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: >-
                                          Discriminator: metadata for a custom
                                          line item.
                                      definitionKey:
                                        type: string
                                        description: >-
                                          The key of the custom charge definition
                                          whose calculator priced the charge,
                                          following the
                                          custom:charge:<slug>:<name> convention.
                                        examples:
                                          - custom:charge:padaria-central:entregas
                                      memory:
                                        type: object
                                        additionalProperties: true
                                        description: >-
                                          The full calculation memory that the
                                          calculator returned, such as every tier
                                          it evaluated and the one it billed. Its
                                          shape belongs to the definition.
                                    required:
                                      - type
                                      - definitionKey
                                      - memory
                                  - title: No metadata
                                    type: 'null'
                              subLineItems:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing a sub-line item: one
                                    priced row of a line item's breakdown. The
                                    row type dictates the shape of metadata.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the sub-line
                                        item in our system.
                                    type:
                                      type: string
                                      enum:
                                        - fixed_price
                                        - minimum_amount
                                        - price_tier_flat
                                        - price_tier_unit
                                        - price_tier_package
                                        - price_tier_percentage
                                        - proration
                                        - license_proration
                                        - license_proration_tier
                                        - unit_price
                                        - included_quantity
                                        - package_price
                                        - percentage
                                        - overage
                                        - original_amount
                                        - fixed_unit_price
                                        - custom
                                      description: >-
                                        The kind of priced row: fixed_price and
                                        minimum_amount are companions of
                                        usage-based charges; unit_price,
                                        package_price, percentage, and
                                        included_quantity break down
                                        single-model pricing; price_tier_* rows
                                        break down tiered pricing; overage bills
                                        usage beyond the last tier; proration
                                        bills per prorated interval;
                                        license_proration bills license deltas
                                        (removals are negative); original_amount
                                        surfaces the pre-adjustment amount of an
                                        adjusted line; fixed_unit_price breaks
                                        down a fixed charge billed as a quantity
                                        times a unit amount; custom bills one
                                        component of a custom plan charge.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the sub-line item as it
                                        appears on the invoice breakdown.
                                      example: '[A partir de 1] Unidades'
                                    description:
                                      type: string
                                      nullable: true
                                      description: >-
                                        Optional descriptive text for the row.
                                        Null when absent.
                                      example: 120 x 2,50
                                    usage:
                                      type: number
                                      nullable: true
                                      description: >-
                                        The usage billed by this row: a count of
                                        resource units (the quantity for a
                                        fixed_unit_price row), or a monetary
                                        base amount in cents for
                                        percentage-priced rows (see the row's
                                        usageFormat, or the line item
                                        usageFormat when the row has none). Null
                                        for rows without usage (e.g.
                                        companions).
                                    usageFormat:
                                      type: string
                                      enum:
                                        - unit
                                        - currency
                                        - null
                                      nullable: true
                                      description: >-
                                        How to read the usage of this row when
                                        the row has a format of its own, as the
                                        custom rows of a custom line item do:
                                        unit means a count, currency means an
                                        amount in cents. Null when the row reads
                                        its usage in the line item usageFormat.
                                    amount:
                                      type: number
                                      description: >-
                                        Amount billed by this row, in cents. The
                                        sum of a line item's sub-line amounts
                                        equals its subtotalAmount.
                                    metadata:
                                      description: >-
                                        Pricing details of the row, keyed by the
                                        row type (and pricingType for overage
                                        rows).
                                      anyOf:
                                        - type: object
                                          description: >-
                                            Fixed-price companion row: the charge's
                                            configured fixed amount, billed
                                            alongside the usage rows. Only rendered
                                            when configured greater than zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_price
                                              description: >-
                                                Discriminator: fixed-price companion
                                                row.
                                            fixedPrice:
                                              type: number
                                              description: >-
                                                The fixed amount configured on the
                                                charge, in cents.
                                          required:
                                            - type
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Minimum-amount companion row: tops the
                                            charge up to its configured minimum when
                                            usage alone stays below it. Only
                                            rendered when the top-up is greater than
                                            zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - minimum_amount
                                              description: >-
                                                Discriminator: minimum-amount companion
                                                row.
                                            minimumAmount:
                                              type: number
                                              description: >-
                                                The minimum amount configured on the
                                                charge, in cents.
                                            minimumAmountApplied:
                                              type: number
                                              description: >-
                                                The top-up billed by this row to reach
                                                the configured minimum, in cents.
                                          required:
                                            - type
                                            - minimumAmount
                                            - minimumAmountApplied
                                        - type: object
                                          description: >-
                                            Flat-priced tier row: usage falling in
                                            this tier band is billed at a flat
                                            amount, regardless of the exact
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_flat
                                              description: 'Discriminator: flat-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            fixedPrice:
                                              type: string
                                              description: >-
                                                The flat amount billed for the tier, as
                                                a decimal currency-unit string.
                                              examples:
                                                - '150.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Per-unit priced tier row: units
                                            attributed to this tier band are billed
                                            at the tier's unit price.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_unit
                                              description: 'Discriminator: per-unit priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            price:
                                              type: string
                                              description: >-
                                                Price per unit within the tier, as a
                                                decimal currency-unit string.
                                              examples:
                                                - '0.25'
                                            fixedPrice:
                                              type: string
                                              nullable: true
                                              description: >-
                                                Optional flat fee billed on top when the
                                                tier applies, as a decimal currency-unit
                                                string. Null when the tier has no flat
                                                fee.
                                              examples:
                                                - '10.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - price
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Package-priced tier row: units
                                            attributed to this tier band are billed
                                            per started package of packageSize
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_package
                                              description: 'Discriminator: package-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string.
                                              examples:
                                                - '45.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - packageSize
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage-priced tier row: the monetary
                                            base amount attributed to this tier band
                                            is billed at a percentage.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_percentage
                                              description: >-
                                                Discriminator: percentage-priced tier
                                                row.
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                                Null for an unbounded final tier.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount
                                                within the tier, as a decimal string
                                                from 0 to 100 (up to 6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - percentage
                                        - type: object
                                          description: >-
                                            Proration interval row: for charges on
                                            prorated resources, each interval bills
                                            the usage held during it, priced as if
                                            held for the whole cycle and scaled by
                                            the interval's share of the cycle.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - proration
                                              description: 'Discriminator: proration interval row.'
                                            intervalSize:
                                              type: number
                                              description: >-
                                                Length of the interval, in days of the
                                                billing cycle.
                                            amount:
                                              type: string
                                              description: >-
                                                The prorated amount of the interval, as
                                                a decimal currency-unit string: the
                                                interval usage priced as if held for the
                                                whole cycle, scaled by intervalSize over
                                                the cycle length.
                                              examples:
                                                - '29.0322580645'
                                            usage:
                                              type: number
                                              description: The usage held during the interval.
                                            intervalStart:
                                              type: string
                                              format: date
                                              description: First day of the interval.
                                            intervalEnd:
                                              type: string
                                              format: date
                                              description: Last day of the interval.
                                          required:
                                            - type
                                            - intervalSize
                                            - amount
                                            - usage
                                            - intervalStart
                                            - intervalEnd
                                        - type: object
                                          description: >-
                                            License proration delta row: for
                                            per_unit license charges billing under
                                            the proration model, the cycle-start row
                                            bills the starting licenses beyond the
                                            included quantity at their full-cycle
                                            price, and each change row bills the
                                            change in those licenses prorated over
                                            the days remaining in the cycle. A
                                            change that stays inside the included
                                            quantity has no row. Tiered charges use
                                            license_proration_tier instead.
                                            quantityDelta and the row's amount are
                                            signed — removals are negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration
                                              description: >-
                                                Discriminator: license proration delta
                                                row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on the cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the licenses beyond the
                                                included quantity (the starting licenses
                                                beyond it on the cycle-start row).
                                                Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity after this
                                                change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on
                                                the cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|. On a cycle-start row
                                                that bills no license, the unit price of
                                                the charge.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                        - type: object
                                          description: >-
                                            Tiered license proration delta row: one
                                            price band of a license charge billing
                                            under the proration model with
                                            tiered_per_unit pricing. The cycle-start
                                            rows bill each band's opening occupancy
                                            at its full-cycle unit price, and each
                                            change row bills that band's occupancy
                                            delta prorated over the days remaining
                                            in the cycle. quantityDelta and the
                                            row's amount are signed — removals are
                                            negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration_tier
                                              description: >-
                                                Discriminator: tiered license proration
                                                delta row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on a cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the units this band
                                                holds (the band's opening occupancy on a
                                                cycle-start row). Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity across
                                                every band after this change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on a
                                                cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                            planChargeTierId:
                                              type: string
                                              description: >-
                                                The unique identifier of the plan charge
                                                tier this row moved through.
                                              examples:
                                                - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                            from:
                                              type: number
                                              description: >-
                                                Inclusive lower bound of the band, in
                                                licenses.
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Inclusive upper bound of the band, in
                                                licenses. Null on the last, open-ended
                                                band.
                                            unitPrice:
                                              type: string
                                              description: >-
                                                The band's full-cycle price per unit, as
                                                a decimal currency-unit string.
                                                proratedUnitRate is this scaled by
                                                remainingDays over cycleDays.
                                              examples:
                                                - '25.00'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                            - planChargeTierId
                                            - from
                                            - to
                                            - unitPrice
                                        - type: object
                                          description: >-
                                            Unit-price row: billable units
                                            multiplied by a single price per unit.
                                            The row's usage holds the billable
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - unit_price
                                              description: 'Discriminator: unit-price row.'
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.25'
                                          required:
                                            - type
                                            - price
                                        - type: object
                                          description: >-
                                            Included-quantity row: the free
                                            allotment of the charge. The row's usage
                                            holds the units consumed within the
                                            allotment and its amount is always zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - included_quantity
                                              description: 'Discriminator: included-quantity row.'
                                            includedQuantity:
                                              type: number
                                              description: >-
                                                Number of resource units included at no
                                                charge before billing starts.
                                          required:
                                            - type
                                            - includedQuantity
                                        - type: object
                                          description: >-
                                            Package-price row: billable units
                                            charged per started package of
                                            packageSize units. The row's usage holds
                                            the billable units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - package_price
                                              description: 'Discriminator: package-price row.'
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '45.00'
                                            packagesBilled:
                                              type: number
                                              description: >-
                                                Number of packages billed: the billable
                                                units divided by packageSize, rounded
                                                up.
                                          required:
                                            - type
                                            - packageSize
                                            - price
                                            - packagesBilled
                                        - type: object
                                          description: >-
                                            Percentage row: a percentage applied
                                            over a monetary base amount. The row's
                                            usage holds the base amount, in cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - percentage
                                              description: 'Discriminator: percentage row.'
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount,
                                                as a decimal string from 0 to 100 (up to
                                                6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - percentage
                                        - type: object
                                          description: >-
                                            Per-unit overage row: units beyond the
                                            last tier boundary, billed at the
                                            configured excess unit price. The row's
                                            usage holds the units over the boundary.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - per_unit
                                              description: 'Discriminator: overage billed per unit.'
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                resource units.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per excess unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.30'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage overage row: the monetary
                                            base amount beyond the last tier
                                            boundary, billed at the configured
                                            excess percentage. The row's usage holds
                                            the base amount over the boundary, in
                                            cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - percentage
                                              description: >-
                                                Discriminator: overage billed as a
                                                percentage.
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                cents of the monetary base amount.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the excess base
                                                amount, as a decimal string from 0 to
                                                100 (up to 6 decimal places).
                                              examples:
                                                - '1.5'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - percentage
                                        - type: object
                                          description: >-
                                            Original-amount row: surfaces the line
                                            item's pre-adjustment amount when the
                                            line has adjustments (e.g. a discount)
                                            but no price-component rows of its own.
                                            The row's amount equals the line item's
                                            subtotalAmount.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - original_amount
                                              description: 'Discriminator: original-amount row.'
                                          required:
                                            - type
                                        - type: object
                                          description: >-
                                            Fixed unit price row: the quantity of a
                                            fixed charge multiplied by its unit
                                            amount. The row's usage holds the
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_unit_price
                                              description: 'Discriminator: fixed unit price row.'
                                            amount:
                                              type: integer
                                              minimum: 0
                                              description: Amount of one unit, in cents.
                                          required:
                                            - type
                                            - amount
                                        - type: object
                                          description: >-
                                            Custom row: one component of a custom
                                            plan charge, as its calculator billed
                                            it. The row's name, description, usage,
                                            usageFormat and amount hold the rest of
                                            the component.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - custom
                                              description: 'Discriminator: custom row.'
                                            key:
                                              type: string
                                              description: >-
                                                The key of the component in the sub-line
                                                schema of the charge's custom charge
                                                definition, such as documents_overage.
                                              examples:
                                                - documents_overage
                                          required:
                                            - type
                                            - key
                                  required:
                                    - id
                                    - type
                                    - name
                                    - description
                                    - usage
                                    - usageFormat
                                    - amount
                                    - metadata
                                  additionalProperties: false
                                description: >-
                                  Breakdown of the line item amount into priced
                                  rows (included quantities, unit/package/tier
                                  prices, prorations, companions). Empty for
                                  line items without a breakdown.
                              adjustments:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing an adjustment applied on
                                    top of a line item subtotal, such as a
                                    discount or an allocation offset.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the adjustment
                                        in our system.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the adjustment as it
                                        appears on the invoice.
                                      example: Desconto de boas-vindas
                                    type:
                                      type: string
                                      enum:
                                        - monetary_discount
                                        - allocation_offset
                                      description: >-
                                        The kind of adjustment:
                                        monetary_discount (a discount applied to
                                        the line item) or allocation_offset (the
                                        share of the amount moved to another
                                        payment account's invoice under a split
                                        allocation strategy).
                                    amount:
                                      type: number
                                      description: >-
                                        Amount of the adjustment, in cents.
                                        Negative when the adjustment reduces the
                                        line item total.
                                  required:
                                    - id
                                    - name
                                    - type
                                    - amount
                                  additionalProperties: false
                                description: >-
                                  Adjustments applied on top of the line item
                                  subtotal, such as discounts and allocation
                                  offsets.
                            required:
                              - id
                              - idempotencyKey
                              - customerId
                              - productId
                              - resourceId
                              - licenseId
                              - lineItemGroupId
                              - name
                              - scope
                              - startDate
                              - endDate
                              - totalUsage
                              - usageFormat
                              - subtotalAmount
                              - adjustmentAmount
                              - totalAmount
                              - discountAmount
                              - metadata
                              - subLineItems
                              - adjustments
                            additionalProperties: false
                          description: The line items contained in this group.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - planId
                        - planInstanceId
                        - name
                        - startDate
                        - endDate
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - lineItems
                      additionalProperties: false
                    description: >-
                      Line item groups on the invoice. Each group gathers the
                      line items generated from one plan instance (or created as
                      a group on one-off invoices).
                  standaloneLineItems:
                    type: array
                    items:
                      type: object
                      description: >-
                        One amount on an invoice, such as a plan charge, the
                        contract minimum, a tax gross-up (the withheld ISS, the
                        municipal service tax, added on top), a one-off amount
                        or an additional charge.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the line item within
                            the invoice. Supplied by the caller for one-off line
                            items; generated by the billing engine otherwise.
                          example: entrega-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this line item bills. On split or
                            consolidated invoices it may be a subsidiary of the
                            invoice's customer.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this line item
                            belongs to.
                        itemId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the catalog item this line
                            bills. Null for line items not backed by a catalog
                            item.
                        resourceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the metered resource behind
                            a usage_based line item. Null for line items not
                            driven by resource usage.
                        licenseId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the license behind a
                            license_based line item. Null for line items not
                            driven by a license count.
                        lineItemGroupId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the line item group
                            containing this line item. Null for standalone line
                            items.
                        name:
                          type: string
                          description: >-
                            Display name of the line item as it appears on the
                            invoice.
                          example: Entregas
                        scope:
                          type: string
                          enum:
                            - credit_purchase
                            - contract_minimum_commitment
                            - minimum_commitment
                            - fixed
                            - usage_based
                            - license_based
                            - custom
                            - additional_charge
                            - one_off
                            - tax_gross_up
                          description: >-
                            What the line item charges for: usage_based (metered
                            resource consumption), license_based (a license's
                            reported count billed in full), fixed (recurring
                            fixed charge of a plan), custom (custom plan charge,
                            priced by a calculator that Aira writes for you),
                            minimum_commitment (plan-level minimum top-up),
                            contract_minimum_commitment (contract-level minimum
                            top-up), credit_purchase (credit pool top-up),
                            additional_charge (extra charge added manually),
                            one_off (line item of a one-off invoice), or
                            tax_gross_up (tax gross-up charge).
                        startDate:
                          type: string
                          format: date
                          description: Start of the period covered by this line item.
                        endDate:
                          type: string
                          format: date
                          description: End of the period covered by this line item.
                        totalUsage:
                          type: number
                          nullable: true
                          description: >-
                            Total usage billed by the line item, in the unit
                            given by usageFormat. Null for line items without a
                            single usage (e.g. fixed charges without a quantity,
                            and custom line items whose calculator returns no
                            total).
                        usageFormat:
                          type: string
                          enum:
                            - unit
                            - currency
                            - null
                          nullable: true
                          description: >-
                            How to read totalUsage, and the usage of each
                            sub-line item that has no usageFormat of its own:
                            unit means a count of resource units or a fixed
                            charge quantity; currency means a monetary base
                            amount in cents. Null when the line item has no
                            single usage, as a custom line item whose sub-line
                            items bill different kinds of volume, each with its
                            own usageFormat.
                        subtotalAmount:
                          type: number
                          description: >-
                            Line item amount before adjustments, in cents (sum
                            of its sub-line item amounts).
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to this line
                            item (discounts and allocation offsets), in cents.
                            Negative when adjustments reduce the amount owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final line item amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        metadata:
                          description: >-
                            Pricing metadata for the line item, where the shape
                            is keyed by type. Always present, but null for line
                            items without pricing metadata: credit_purchase,
                            additional_charge, one_off, and tax_gross_up. It is
                            populated for fixed (the billing timing),
                            usage_based, license_based, minimum_commitment,
                            contract_minimum_commitment, and custom (the
                            definition and the calculation memory) line items.
                          anyOf:
                            - title: Fixed
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed
                                  description: >-
                                    Discriminator: metadata for a fixed line
                                    item.
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    Whether the fee was billed in advance of its
                                    service period or after it.
                              required:
                                - type
                                - billingTiming
                            - title: Usage-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - usage_based
                                  description: >-
                                    Discriminator: metadata for a usage_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the metered resource accrues over the
                                    billing period: in_full bills the full usage
                                    of the period; proration weighs usage by the
                                    fraction of the period each amount was held.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how
                                    usage was divided across tiers. unique_tier
                                    prices all usage at the single tier that
                                    contains the total; progressive prices each
                                    tier's band separately. Absent for
                                    non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item. Charges priced
                                    before pricing models existed are reported
                                    as advanced.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: License-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_based
                                  description: >-
                                    Discriminator: metadata for a license_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the license count accrues over the
                                    billing period. Always in_full: the latest
                                    reported count is billed in full.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how the
                                    license count was divided across tiers.
                                    unique_tier prices the whole count at the
                                    single tier that contains the total;
                                    progressive prices each tier's band
                                    separately. Absent for non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: Contract minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - contract_minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a
                                    contract_minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the whole
                                    contract in the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the contract's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a plan-level
                                    minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the plan in
                                    the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the plan's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Custom
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - custom
                                  description: >-
                                    Discriminator: metadata for a custom line
                                    item.
                                definitionKey:
                                  type: string
                                  description: >-
                                    The key of the custom charge definition
                                    whose calculator priced the charge,
                                    following the custom:charge:<slug>:<name>
                                    convention.
                                  examples:
                                    - custom:charge:padaria-central:entregas
                                memory:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The full calculation memory that the
                                    calculator returned, such as every tier it
                                    evaluated and the one it billed. Its shape
                                    belongs to the definition.
                              required:
                                - type
                                - definitionKey
                                - memory
                            - title: No metadata
                              type: 'null'
                        subLineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing a sub-line item: one priced
                              row of a line item's breakdown. The row type
                              dictates the shape of metadata.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the sub-line item in
                                  our system.
                              type:
                                type: string
                                enum:
                                  - fixed_price
                                  - minimum_amount
                                  - price_tier_flat
                                  - price_tier_unit
                                  - price_tier_package
                                  - price_tier_percentage
                                  - proration
                                  - license_proration
                                  - license_proration_tier
                                  - unit_price
                                  - included_quantity
                                  - package_price
                                  - percentage
                                  - overage
                                  - original_amount
                                  - fixed_unit_price
                                  - custom
                                description: >-
                                  The kind of priced row: fixed_price and
                                  minimum_amount are companions of usage-based
                                  charges; unit_price, package_price,
                                  percentage, and included_quantity break down
                                  single-model pricing; price_tier_* rows break
                                  down tiered pricing; overage bills usage
                                  beyond the last tier; proration bills per
                                  prorated interval; license_proration bills
                                  license deltas (removals are negative);
                                  original_amount surfaces the pre-adjustment
                                  amount of an adjusted line; fixed_unit_price
                                  breaks down a fixed charge billed as a
                                  quantity times a unit amount; custom bills one
                                  component of a custom plan charge.
                              name:
                                type: string
                                description: >-
                                  Display name of the sub-line item as it
                                  appears on the invoice breakdown.
                                example: '[A partir de 1] Unidades'
                              description:
                                type: string
                                nullable: true
                                description: >-
                                  Optional descriptive text for the row. Null
                                  when absent.
                                example: 120 x 2,50
                              usage:
                                type: number
                                nullable: true
                                description: >-
                                  The usage billed by this row: a count of
                                  resource units (the quantity for a
                                  fixed_unit_price row), or a monetary base
                                  amount in cents for percentage-priced rows
                                  (see the row's usageFormat, or the line item
                                  usageFormat when the row has none). Null for
                                  rows without usage (e.g. companions).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read the usage of this row when the row
                                  has a format of its own, as the custom rows of
                                  a custom line item do: unit means a count,
                                  currency means an amount in cents. Null when
                                  the row reads its usage in the line item
                                  usageFormat.
                              amount:
                                type: number
                                description: >-
                                  Amount billed by this row, in cents. The sum
                                  of a line item's sub-line amounts equals its
                                  subtotalAmount.
                              metadata:
                                description: >-
                                  Pricing details of the row, keyed by the row
                                  type (and pricingType for overage rows).
                                anyOf:
                                  - type: object
                                    description: >-
                                      Fixed-price companion row: the charge's
                                      configured fixed amount, billed alongside
                                      the usage rows. Only rendered when
                                      configured greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_price
                                        description: >-
                                          Discriminator: fixed-price companion
                                          row.
                                      fixedPrice:
                                        type: number
                                        description: >-
                                          The fixed amount configured on the
                                          charge, in cents.
                                    required:
                                      - type
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Minimum-amount companion row: tops the
                                      charge up to its configured minimum when
                                      usage alone stays below it. Only rendered
                                      when the top-up is greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_amount
                                        description: >-
                                          Discriminator: minimum-amount companion
                                          row.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount configured on the
                                          charge, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up billed by this row to reach
                                          the configured minimum, in cents.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - type: object
                                    description: >-
                                      Flat-priced tier row: usage falling in
                                      this tier band is billed at a flat amount,
                                      regardless of the exact quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_flat
                                        description: 'Discriminator: flat-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      fixedPrice:
                                        type: string
                                        description: >-
                                          The flat amount billed for the tier, as
                                          a decimal currency-unit string.
                                        examples:
                                          - '150.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Per-unit priced tier row: units attributed
                                      to this tier band are billed at the tier's
                                      unit price.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_unit
                                        description: 'Discriminator: per-unit priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      price:
                                        type: string
                                        description: >-
                                          Price per unit within the tier, as a
                                          decimal currency-unit string.
                                        examples:
                                          - '0.25'
                                      fixedPrice:
                                        type: string
                                        nullable: true
                                        description: >-
                                          Optional flat fee billed on top when the
                                          tier applies, as a decimal currency-unit
                                          string. Null when the tier has no flat
                                          fee.
                                        examples:
                                          - '10.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - price
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Package-priced tier row: units attributed
                                      to this tier band are billed per started
                                      package of packageSize units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_package
                                        description: 'Discriminator: package-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string.
                                        examples:
                                          - '45.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - packageSize
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage-priced tier row: the monetary
                                      base amount attributed to this tier band
                                      is billed at a percentage.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_percentage
                                        description: >-
                                          Discriminator: percentage-priced tier
                                          row.
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                          Null for an unbounded final tier.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          within the tier, as a decimal string
                                          from 0 to 100 (up to 6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - percentage
                                  - type: object
                                    description: >-
                                      Proration interval row: for charges on
                                      prorated resources, each interval bills
                                      the usage held during it, priced as if
                                      held for the whole cycle and scaled by the
                                      interval's share of the cycle.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - proration
                                        description: 'Discriminator: proration interval row.'
                                      intervalSize:
                                        type: number
                                        description: >-
                                          Length of the interval, in days of the
                                          billing cycle.
                                      amount:
                                        type: string
                                        description: >-
                                          The prorated amount of the interval, as
                                          a decimal currency-unit string: the
                                          interval usage priced as if held for the
                                          whole cycle, scaled by intervalSize over
                                          the cycle length.
                                        examples:
                                          - '29.0322580645'
                                      usage:
                                        type: number
                                        description: The usage held during the interval.
                                      intervalStart:
                                        type: string
                                        format: date
                                        description: First day of the interval.
                                      intervalEnd:
                                        type: string
                                        format: date
                                        description: Last day of the interval.
                                    required:
                                      - type
                                      - intervalSize
                                      - amount
                                      - usage
                                      - intervalStart
                                      - intervalEnd
                                  - type: object
                                    description: >-
                                      License proration delta row: for per_unit
                                      license charges billing under the
                                      proration model, the cycle-start row bills
                                      the starting licenses beyond the included
                                      quantity at their full-cycle price, and
                                      each change row bills the change in those
                                      licenses prorated over the days remaining
                                      in the cycle. A change that stays inside
                                      the included quantity has no row. Tiered
                                      charges use license_proration_tier
                                      instead. quantityDelta and the row's
                                      amount are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration
                                        description: >-
                                          Discriminator: license proration delta
                                          row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on the cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the licenses beyond the
                                          included quantity (the starting licenses
                                          beyond it on the cycle-start row).
                                          Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity after this
                                          change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on
                                          the cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|. On a cycle-start row
                                          that bills no license, the unit price of
                                          the charge.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                  - type: object
                                    description: >-
                                      Tiered license proration delta row: one
                                      price band of a license charge billing
                                      under the proration model with
                                      tiered_per_unit pricing. The cycle-start
                                      rows bill each band's opening occupancy at
                                      its full-cycle unit price, and each change
                                      row bills that band's occupancy delta
                                      prorated over the days remaining in the
                                      cycle. quantityDelta and the row's amount
                                      are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration_tier
                                        description: >-
                                          Discriminator: tiered license proration
                                          delta row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on a cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the units this band
                                          holds (the band's opening occupancy on a
                                          cycle-start row). Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity across
                                          every band after this change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on a
                                          cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                      planChargeTierId:
                                        type: string
                                        description: >-
                                          The unique identifier of the plan charge
                                          tier this row moved through.
                                        examples:
                                          - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                      from:
                                        type: number
                                        description: >-
                                          Inclusive lower bound of the band, in
                                          licenses.
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Inclusive upper bound of the band, in
                                          licenses. Null on the last, open-ended
                                          band.
                                      unitPrice:
                                        type: string
                                        description: >-
                                          The band's full-cycle price per unit, as
                                          a decimal currency-unit string.
                                          proratedUnitRate is this scaled by
                                          remainingDays over cycleDays.
                                        examples:
                                          - '25.00'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                      - planChargeTierId
                                      - from
                                      - to
                                      - unitPrice
                                  - type: object
                                    description: >-
                                      Unit-price row: billable units multiplied
                                      by a single price per unit. The row's
                                      usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - unit_price
                                        description: 'Discriminator: unit-price row.'
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.25'
                                    required:
                                      - type
                                      - price
                                  - type: object
                                    description: >-
                                      Included-quantity row: the free allotment
                                      of the charge. The row's usage holds the
                                      units consumed within the allotment and
                                      its amount is always zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - included_quantity
                                        description: 'Discriminator: included-quantity row.'
                                      includedQuantity:
                                        type: number
                                        description: >-
                                          Number of resource units included at no
                                          charge before billing starts.
                                    required:
                                      - type
                                      - includedQuantity
                                  - type: object
                                    description: >-
                                      Package-price row: billable units charged
                                      per started package of packageSize units.
                                      The row's usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - package_price
                                        description: 'Discriminator: package-price row.'
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '45.00'
                                      packagesBilled:
                                        type: number
                                        description: >-
                                          Number of packages billed: the billable
                                          units divided by packageSize, rounded
                                          up.
                                    required:
                                      - type
                                      - packageSize
                                      - price
                                      - packagesBilled
                                  - type: object
                                    description: >-
                                      Percentage row: a percentage applied over
                                      a monetary base amount. The row's usage
                                      holds the base amount, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - percentage
                                        description: 'Discriminator: percentage row.'
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount,
                                          as a decimal string from 0 to 100 (up to
                                          6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - percentage
                                  - type: object
                                    description: >-
                                      Per-unit overage row: units beyond the
                                      last tier boundary, billed at the
                                      configured excess unit price. The row's
                                      usage holds the units over the boundary.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - per_unit
                                        description: 'Discriminator: overage billed per unit.'
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          resource units.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per excess unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage overage row: the monetary base
                                      amount beyond the last tier boundary,
                                      billed at the configured excess
                                      percentage. The row's usage holds the base
                                      amount over the boundary, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - percentage
                                        description: >-
                                          Discriminator: overage billed as a
                                          percentage.
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          cents of the monetary base amount.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the excess base
                                          amount, as a decimal string from 0 to
                                          100 (up to 6 decimal places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - percentage
                                  - type: object
                                    description: >-
                                      Original-amount row: surfaces the line
                                      item's pre-adjustment amount when the line
                                      has adjustments (e.g. a discount) but no
                                      price-component rows of its own. The row's
                                      amount equals the line item's
                                      subtotalAmount.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - original_amount
                                        description: 'Discriminator: original-amount row.'
                                    required:
                                      - type
                                  - type: object
                                    description: >-
                                      Fixed unit price row: the quantity of a
                                      fixed charge multiplied by its unit
                                      amount. The row's usage holds the
                                      quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_unit_price
                                        description: 'Discriminator: fixed unit price row.'
                                      amount:
                                        type: integer
                                        minimum: 0
                                        description: Amount of one unit, in cents.
                                    required:
                                      - type
                                      - amount
                                  - type: object
                                    description: >-
                                      Custom row: one component of a custom plan
                                      charge, as its calculator billed it. The
                                      row's name, description, usage,
                                      usageFormat and amount hold the rest of
                                      the component.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: 'Discriminator: custom row.'
                                      key:
                                        type: string
                                        description: >-
                                          The key of the component in the sub-line
                                          schema of the charge's custom charge
                                          definition, such as documents_overage.
                                        examples:
                                          - documents_overage
                                    required:
                                      - type
                                      - key
                            required:
                              - id
                              - type
                              - name
                              - description
                              - usage
                              - usageFormat
                              - amount
                              - metadata
                            additionalProperties: false
                          description: >-
                            Breakdown of the line item amount into priced rows
                            (included quantities, unit/package/tier prices,
                            prorations, companions). Empty for line items
                            without a breakdown.
                        adjustments:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing an adjustment applied on top
                              of a line item subtotal, such as a discount or an
                              allocation offset.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the adjustment in our
                                  system.
                              name:
                                type: string
                                description: >-
                                  Display name of the adjustment as it appears
                                  on the invoice.
                                example: Desconto de boas-vindas
                              type:
                                type: string
                                enum:
                                  - monetary_discount
                                  - allocation_offset
                                description: >-
                                  The kind of adjustment: monetary_discount (a
                                  discount applied to the line item) or
                                  allocation_offset (the share of the amount
                                  moved to another payment account's invoice
                                  under a split allocation strategy).
                              amount:
                                type: number
                                description: >-
                                  Amount of the adjustment, in cents. Negative
                                  when the adjustment reduces the line item
                                  total.
                            required:
                              - id
                              - name
                              - type
                              - amount
                            additionalProperties: false
                          description: >-
                            Adjustments applied on top of the line item
                            subtotal, such as discounts and allocation offsets.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - resourceId
                        - licenseId
                        - lineItemGroupId
                        - name
                        - scope
                        - startDate
                        - endDate
                        - totalUsage
                        - usageFormat
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - metadata
                        - subLineItems
                        - adjustments
                      additionalProperties: false
                    description: >-
                      Line items that do not belong to any line item group (e.g.
                      contract-level minimum commitments, additional charges,
                      and ungrouped one-off items).
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of invoices, keyed by the
                      key of each custom field. The object is empty when the
                      invoice holds no value. A user edits them in the billing
                      app, and `PUT /v1/invoices/{id}/custom-fields` replaces
                      the whole set, in any status of the invoice.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  sentAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When Aira last sent the invoice by e-mail to its invoice
                      recipients, in an invoice delivery. Null when Aira has not
                      sent it.
                  replaceReason:
                    type: string
                    enum:
                      - contract_allocation_changed
                      - manually_reopened
                      - null
                    nullable: true
                    description: >-
                      Why one invoice of the same invoice slot replaced another,
                      on both invoices of the replacement: manually_reopened for
                      a reopening, and contract_allocation_changed when a change
                      to the contract allocation canceled the invoice and a
                      later billing of its billing act replaced it. Null when
                      the invoice replaces no invoice and no invoice replaces
                      it.
                  replacesInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the canceled invoice that this
                      invoice replaces in its invoice slot. Null when the
                      invoice replaces no invoice.
                  replacedByInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the invoice that replaces this
                      canceled invoice in its invoice slot. Null when no invoice
                      replaces it.
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - paymentAccountId
                  - contractId
                  - contractInvoiceSequence
                  - issuingAccount
                  - billingAccount
                  - invoiceAllocationStrategy
                  - lastCalculatedAt
                  - invoiceNumber
                  - invoiceDate
                  - memo
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - status
                  - isLocked
                  - failureReason
                  - source
                  - autoIssue
                  - amountDue
                  - dueDate
                  - lineItemGroups
                  - standaloneLineItems
                  - customFields
                  - sentAt
                  - replaceReason
                  - replacesInvoiceId
                  - replacedByInvoiceId
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is not a one-off invoice,
            or it is locked, because it was issued or canceled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceDate'' is required'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `invoiceId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
  /v1/invoices/{invoiceId}/cancel:
    post:
      summary: Cancel invoice
      tags:
        - Invoices
      description: >-
        Cancels an invoice, as the billing app does. Aira cancels a contract
        invoice with every invoice of its invoice allocation group. A canceled
        invoice comes back as it is.


        Requires the role `invoices:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice to cancel.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: >-
            the invoice, or another invoice of its invoice allocation group, is
            paid or has a pending invoice sync
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            The document that bills one payment account of a customer: from a
            billing act of a contract, as a one-off invoice or from an import.
            It locks when it is issued or canceled, and Aira never recalculates
            a locked invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the invoice in our system.
                  idempotencyKey:
                    type: string
                    description: >-
                      A unique key that identifies the invoice for idempotent
                      creation. Supplied by the caller for one-off invoices;
                      generated by the billing engine for contract invoices.
                    example: padaria-central-2026-11
                  customerId:
                    type: string
                    format: uuid
                    description: The unique identifier of the customer this invoice bills.
                  paymentAccountId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the customer payment account used
                      as the billing account for this invoice.
                  contractId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the contract that generated this
                      invoice. Null for invoices not generated from a contract
                      (e.g. one-off and imported invoices).
                  contractInvoiceSequence:
                    type: integer
                    minimum: 1
                    nullable: true
                    description: >-
                      The number of the invoice within its contract, in the
                      order that Aira created the contract's invoices: 1 for the
                      first, 2 for the next, and so on. Every invoice gets its
                      own number, including each invoice of a split across
                      payment accounts and the replacement of a reopened
                      invoice, and a number never changes and is never reused.
                      Null for invoices without a contract.
                  issuingAccount:
                    type: object
                    description: >-
                      Snapshot of the legal entity issuing the invoice (the
                      seller), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  billingAccount:
                    type: object
                    description: >-
                      Snapshot of the billed party (the legal entity behind the
                      customer payment account), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How the originating contract distributes charges across
                      payment accounts: single bills a single payment account;
                      percent_split divides the total between payment accounts
                      by configured percentages; subsidiary_usage_split divides
                      it according to each subsidiary's usage.
                  lastCalculatedAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When the invoice amounts were last computed by the billing
                      engine. Null when the invoice has never been calculated.
                  invoiceNumber:
                    type: string
                    description: >-
                      Human-readable invoice number, built from the customer's
                      invoice prefix plus a sequential counter.
                    example: ACMEI-0042
                  invoiceDate:
                    type: string
                    format: date
                    description: >-
                      The date of the invoice. On a contract invoice it is the
                      date of its billing act: the first day of the first
                      billing cycle that the contract invoices for an activation
                      invoice, and the last day of the billing cycle for a
                      closing invoice. Its line items state the periods that it
                      bills. On a one-off or imported invoice it is the date
                      given when the invoice was created.
                  memo:
                    type: string
                    nullable: true
                    description: >-
                      Free-form memo attached to the invoice. On contract
                      invoices, it reads "Período <start> a <end>" with the
                      period of the line item that bills most often, such as the
                      month when a monthly fee is billed with an annual fee.
                      When two line items bill equally often, it uses the
                      earlier period. Null when absent.
                    example: Período 01/11/2026 a 30/11/2026
                  subtotalAmount:
                    type: number
                    description: >-
                      Sum of the line item subtotals before adjustments, in
                      cents.
                  adjustmentAmount:
                    type: number
                    description: >-
                      Net amount of all adjustments applied to the invoice line
                      items (discounts and allocation offsets), in cents.
                      Negative when adjustments reduce the amount owed.
                  totalAmount:
                    type: number
                    description: >-
                      Final invoice amount, in cents: subtotalAmount +
                      adjustmentAmount.
                  discountAmount:
                    type: number
                    description: >-
                      The discount portion of adjustmentAmount, in cents (sum of
                      monetary discount adjustments only). Negative when
                      discounts were applied.
                  status:
                    type: string
                    enum:
                      - open
                      - in_review
                      - issued
                      - synced
                      - pending
                      - paid
                      - overdue
                      - canceled
                      - failed
                    description: >-
                      Current status of the invoice lifecycle: open
                      (accumulating charges, editable), in_review (flagged for
                      manual review before issuing), issued (finalized and
                      issued to the customer), synced (registered in the
                      external ERP/payment provider), pending (a payment was
                      initiated and awaits settlement), paid, overdue (unpaid
                      past the due date), canceled, or failed (an issue/sync
                      attempt failed and needs attention).
                  isLocked:
                    type: boolean
                    description: >-
                      Whether the invoice contents are locked against edits.
                      Aira locks an invoice when it issues or cancels it,
                      together with the other invoices of its allocation group,
                      except when it cancels the invoice because its payment
                      account left the allocation of the contract, which locks
                      only that invoice. A locked invoice stays locked, also
                      when its status later moves to failed.
                  failureReason:
                    type: string
                    nullable: true
                    description: >-
                      Reason for the most recent failure on the invoice (e.g. an
                      ERP sync or payment issue). Null when the invoice has no
                      active failure.
                    example: contract_sync_not_found
                  source:
                    type: string
                    enum:
                      - contract
                      - one_off
                      - import
                    description: >-
                      How the invoice originated: contract (generated by a
                      contract billing cycle), one_off (created manually or
                      through the API), or import (ingested from an external
                      system).
                  autoIssue:
                    type: boolean
                    description: >-
                      Whether the invoice is issued automatically when its
                      billing cycle closes, without manual review.
                  amountDue:
                    type: number
                    nullable: true
                    description: >-
                      Outstanding amount due on the invoice, in cents. Null when
                      not tracked.
                  dueDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Payment due date of the invoice. Null when no due date is
                      set (e.g. before the invoice is issued).
                  lineItemGroups:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a line item group: a container that
                        gathers the line items generated from one plan instance
                        (or created as a group on one-off invoices). Monetary
                        amounts are integers in cents.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item group in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the group within the
                            invoice. Supplied by the caller for one-off groups;
                            generated by the billing engine otherwise.
                          example: servicos-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this group bills.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this group
                            belongs to.
                        planId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan whose instance
                            generated this group. Null for groups not generated
                            from a plan (e.g. on one-off invoices).
                        planInstanceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan instance that
                            generated this group. Null for groups not generated
                            from a plan instance.
                        name:
                          type: string
                          description: >-
                            Display name of the group as it appears on the
                            invoice, typically the plan or product name.
                          example: Plano Entregas
                        startDate:
                          type: string
                          format: date
                          description: >-
                            Start of the period that the group shows. On
                            contract invoices, it is the period of the group's
                            line item that bills most often, such as the month
                            when a monthly fee is billed with an annual fee.
                            When two line items bill equally often, it is the
                            earlier period.
                        endDate:
                          type: string
                          format: date
                          description: >-
                            End of the period that the group shows, which
                            `startDate` describes.
                        subtotalAmount:
                          type: number
                          description: >-
                            Sum of the group's line item subtotals before
                            adjustments, in cents.
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to the group's
                            line items (discounts and allocation offsets), in
                            cents. Negative when adjustments reduce the amount
                            owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final group amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        lineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              One amount on an invoice, such as a plan charge,
                              the contract minimum, a tax gross-up (the withheld
                              ISS, the municipal service tax, added on top), a
                              one-off amount or an additional charge.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the line item in our
                                  system.
                              idempotencyKey:
                                type: string
                                description: >-
                                  A unique key that identifies the line item
                                  within the invoice. Supplied by the caller for
                                  one-off line items; generated by the billing
                                  engine otherwise.
                                example: entrega-novembro
                              customerId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the customer whose
                                  consumption this line item bills. On split or
                                  consolidated invoices it may be a subsidiary
                                  of the invoice's customer.
                              productId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the product this line
                                  item belongs to.
                              itemId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the catalog item this
                                  line bills. Null for line items not backed by
                                  a catalog item.
                              resourceId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the metered resource
                                  behind a usage_based line item. Null for line
                                  items not driven by resource usage.
                              licenseId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the license behind a
                                  license_based line item. Null for line items
                                  not driven by a license count.
                              lineItemGroupId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the line item group
                                  containing this line item. Null for standalone
                                  line items.
                              name:
                                type: string
                                description: >-
                                  Display name of the line item as it appears on
                                  the invoice.
                                example: Entregas
                              scope:
                                type: string
                                enum:
                                  - credit_purchase
                                  - contract_minimum_commitment
                                  - minimum_commitment
                                  - fixed
                                  - usage_based
                                  - license_based
                                  - custom
                                  - additional_charge
                                  - one_off
                                  - tax_gross_up
                                description: >-
                                  What the line item charges for: usage_based
                                  (metered resource consumption), license_based
                                  (a license's reported count billed in full),
                                  fixed (recurring fixed charge of a plan),
                                  custom (custom plan charge, priced by a
                                  calculator that Aira writes for you),
                                  minimum_commitment (plan-level minimum
                                  top-up), contract_minimum_commitment
                                  (contract-level minimum top-up),
                                  credit_purchase (credit pool top-up),
                                  additional_charge (extra charge added
                                  manually), one_off (line item of a one-off
                                  invoice), or tax_gross_up (tax gross-up
                                  charge).
                              startDate:
                                type: string
                                format: date
                                description: Start of the period covered by this line item.
                              endDate:
                                type: string
                                format: date
                                description: End of the period covered by this line item.
                              totalUsage:
                                type: number
                                nullable: true
                                description: >-
                                  Total usage billed by the line item, in the
                                  unit given by usageFormat. Null for line items
                                  without a single usage (e.g. fixed charges
                                  without a quantity, and custom line items
                                  whose calculator returns no total).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read totalUsage, and the usage of each
                                  sub-line item that has no usageFormat of its
                                  own: unit means a count of resource units or a
                                  fixed charge quantity; currency means a
                                  monetary base amount in cents. Null when the
                                  line item has no single usage, as a custom
                                  line item whose sub-line items bill different
                                  kinds of volume, each with its own
                                  usageFormat.
                              subtotalAmount:
                                type: number
                                description: >-
                                  Line item amount before adjustments, in cents
                                  (sum of its sub-line item amounts).
                              adjustmentAmount:
                                type: number
                                description: >-
                                  Net amount of the adjustments applied to this
                                  line item (discounts and allocation offsets),
                                  in cents. Negative when adjustments reduce the
                                  amount owed.
                              totalAmount:
                                type: number
                                description: >-
                                  Final line item amount, in cents:
                                  subtotalAmount + adjustmentAmount.
                              discountAmount:
                                type: number
                                description: >-
                                  The discount portion of adjustmentAmount, in
                                  cents (sum of monetary discount adjustments
                                  only). Negative when discounts were applied.
                              metadata:
                                description: >-
                                  Pricing metadata for the line item, where the
                                  shape is keyed by type. Always present, but
                                  null for line items without pricing metadata:
                                  credit_purchase, additional_charge, one_off,
                                  and tax_gross_up. It is populated for fixed
                                  (the billing timing), usage_based,
                                  license_based, minimum_commitment,
                                  contract_minimum_commitment, and custom (the
                                  definition and the calculation memory) line
                                  items.
                                anyOf:
                                  - title: Fixed
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed
                                        description: >-
                                          Discriminator: metadata for a fixed line
                                          item.
                                      billingTiming:
                                        type: string
                                        enum:
                                          - in_advance
                                          - in_arrears
                                        description: >-
                                          Whether the fee was billed in advance of
                                          its service period or after it.
                                    required:
                                      - type
                                      - billingTiming
                                  - title: Usage-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - usage_based
                                        description: >-
                                          Discriminator: metadata for a
                                          usage_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the metered resource accrues over
                                          the billing period: in_full bills the
                                          full usage of the period; proration
                                          weighs usage by the fraction of the
                                          period each amount was held.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          usage was divided across tiers.
                                          unique_tier prices all usage at the
                                          single tier that contains the total;
                                          progressive prices each tier's band
                                          separately. Absent for non-tiered
                                          models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item. Charges
                                          priced before pricing models existed are
                                          reported as advanced.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: License-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_based
                                        description: >-
                                          Discriminator: metadata for a
                                          license_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the license count accrues over the
                                          billing period. Always in_full: the
                                          latest reported count is billed in full.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          the license count was divided across
                                          tiers. unique_tier prices the whole
                                          count at the single tier that contains
                                          the total; progressive prices each
                                          tier's band separately. Absent for
                                          non-tiered models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: Contract minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - contract_minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a
                                          contract_minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          whole contract in the billing period, in
                                          cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the contract's consumption amounted
                                          to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a plan-level
                                          minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          plan in the billing period, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the plan's consumption amounted to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Custom
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: >-
                                          Discriminator: metadata for a custom
                                          line item.
                                      definitionKey:
                                        type: string
                                        description: >-
                                          The key of the custom charge definition
                                          whose calculator priced the charge,
                                          following the
                                          custom:charge:<slug>:<name> convention.
                                        examples:
                                          - custom:charge:padaria-central:entregas
                                      memory:
                                        type: object
                                        additionalProperties: true
                                        description: >-
                                          The full calculation memory that the
                                          calculator returned, such as every tier
                                          it evaluated and the one it billed. Its
                                          shape belongs to the definition.
                                    required:
                                      - type
                                      - definitionKey
                                      - memory
                                  - title: No metadata
                                    type: 'null'
                              subLineItems:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing a sub-line item: one
                                    priced row of a line item's breakdown. The
                                    row type dictates the shape of metadata.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the sub-line
                                        item in our system.
                                    type:
                                      type: string
                                      enum:
                                        - fixed_price
                                        - minimum_amount
                                        - price_tier_flat
                                        - price_tier_unit
                                        - price_tier_package
                                        - price_tier_percentage
                                        - proration
                                        - license_proration
                                        - license_proration_tier
                                        - unit_price
                                        - included_quantity
                                        - package_price
                                        - percentage
                                        - overage
                                        - original_amount
                                        - fixed_unit_price
                                        - custom
                                      description: >-
                                        The kind of priced row: fixed_price and
                                        minimum_amount are companions of
                                        usage-based charges; unit_price,
                                        package_price, percentage, and
                                        included_quantity break down
                                        single-model pricing; price_tier_* rows
                                        break down tiered pricing; overage bills
                                        usage beyond the last tier; proration
                                        bills per prorated interval;
                                        license_proration bills license deltas
                                        (removals are negative); original_amount
                                        surfaces the pre-adjustment amount of an
                                        adjusted line; fixed_unit_price breaks
                                        down a fixed charge billed as a quantity
                                        times a unit amount; custom bills one
                                        component of a custom plan charge.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the sub-line item as it
                                        appears on the invoice breakdown.
                                      example: '[A partir de 1] Unidades'
                                    description:
                                      type: string
                                      nullable: true
                                      description: >-
                                        Optional descriptive text for the row.
                                        Null when absent.
                                      example: 120 x 2,50
                                    usage:
                                      type: number
                                      nullable: true
                                      description: >-
                                        The usage billed by this row: a count of
                                        resource units (the quantity for a
                                        fixed_unit_price row), or a monetary
                                        base amount in cents for
                                        percentage-priced rows (see the row's
                                        usageFormat, or the line item
                                        usageFormat when the row has none). Null
                                        for rows without usage (e.g.
                                        companions).
                                    usageFormat:
                                      type: string
                                      enum:
                                        - unit
                                        - currency
                                        - null
                                      nullable: true
                                      description: >-
                                        How to read the usage of this row when
                                        the row has a format of its own, as the
                                        custom rows of a custom line item do:
                                        unit means a count, currency means an
                                        amount in cents. Null when the row reads
                                        its usage in the line item usageFormat.
                                    amount:
                                      type: number
                                      description: >-
                                        Amount billed by this row, in cents. The
                                        sum of a line item's sub-line amounts
                                        equals its subtotalAmount.
                                    metadata:
                                      description: >-
                                        Pricing details of the row, keyed by the
                                        row type (and pricingType for overage
                                        rows).
                                      anyOf:
                                        - type: object
                                          description: >-
                                            Fixed-price companion row: the charge's
                                            configured fixed amount, billed
                                            alongside the usage rows. Only rendered
                                            when configured greater than zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_price
                                              description: >-
                                                Discriminator: fixed-price companion
                                                row.
                                            fixedPrice:
                                              type: number
                                              description: >-
                                                The fixed amount configured on the
                                                charge, in cents.
                                          required:
                                            - type
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Minimum-amount companion row: tops the
                                            charge up to its configured minimum when
                                            usage alone stays below it. Only
                                            rendered when the top-up is greater than
                                            zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - minimum_amount
                                              description: >-
                                                Discriminator: minimum-amount companion
                                                row.
                                            minimumAmount:
                                              type: number
                                              description: >-
                                                The minimum amount configured on the
                                                charge, in cents.
                                            minimumAmountApplied:
                                              type: number
                                              description: >-
                                                The top-up billed by this row to reach
                                                the configured minimum, in cents.
                                          required:
                                            - type
                                            - minimumAmount
                                            - minimumAmountApplied
                                        - type: object
                                          description: >-
                                            Flat-priced tier row: usage falling in
                                            this tier band is billed at a flat
                                            amount, regardless of the exact
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_flat
                                              description: 'Discriminator: flat-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            fixedPrice:
                                              type: string
                                              description: >-
                                                The flat amount billed for the tier, as
                                                a decimal currency-unit string.
                                              examples:
                                                - '150.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Per-unit priced tier row: units
                                            attributed to this tier band are billed
                                            at the tier's unit price.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_unit
                                              description: 'Discriminator: per-unit priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            price:
                                              type: string
                                              description: >-
                                                Price per unit within the tier, as a
                                                decimal currency-unit string.
                                              examples:
                                                - '0.25'
                                            fixedPrice:
                                              type: string
                                              nullable: true
                                              description: >-
                                                Optional flat fee billed on top when the
                                                tier applies, as a decimal currency-unit
                                                string. Null when the tier has no flat
                                                fee.
                                              examples:
                                                - '10.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - price
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Package-priced tier row: units
                                            attributed to this tier band are billed
                                            per started package of packageSize
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_package
                                              description: 'Discriminator: package-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string.
                                              examples:
                                                - '45.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - packageSize
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage-priced tier row: the monetary
                                            base amount attributed to this tier band
                                            is billed at a percentage.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_percentage
                                              description: >-
                                                Discriminator: percentage-priced tier
                                                row.
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                                Null for an unbounded final tier.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount
                                                within the tier, as a decimal string
                                                from 0 to 100 (up to 6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - percentage
                                        - type: object
                                          description: >-
                                            Proration interval row: for charges on
                                            prorated resources, each interval bills
                                            the usage held during it, priced as if
                                            held for the whole cycle and scaled by
                                            the interval's share of the cycle.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - proration
                                              description: 'Discriminator: proration interval row.'
                                            intervalSize:
                                              type: number
                                              description: >-
                                                Length of the interval, in days of the
                                                billing cycle.
                                            amount:
                                              type: string
                                              description: >-
                                                The prorated amount of the interval, as
                                                a decimal currency-unit string: the
                                                interval usage priced as if held for the
                                                whole cycle, scaled by intervalSize over
                                                the cycle length.
                                              examples:
                                                - '29.0322580645'
                                            usage:
                                              type: number
                                              description: The usage held during the interval.
                                            intervalStart:
                                              type: string
                                              format: date
                                              description: First day of the interval.
                                            intervalEnd:
                                              type: string
                                              format: date
                                              description: Last day of the interval.
                                          required:
                                            - type
                                            - intervalSize
                                            - amount
                                            - usage
                                            - intervalStart
                                            - intervalEnd
                                        - type: object
                                          description: >-
                                            License proration delta row: for
                                            per_unit license charges billing under
                                            the proration model, the cycle-start row
                                            bills the starting licenses beyond the
                                            included quantity at their full-cycle
                                            price, and each change row bills the
                                            change in those licenses prorated over
                                            the days remaining in the cycle. A
                                            change that stays inside the included
                                            quantity has no row. Tiered charges use
                                            license_proration_tier instead.
                                            quantityDelta and the row's amount are
                                            signed — removals are negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration
                                              description: >-
                                                Discriminator: license proration delta
                                                row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on the cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the licenses beyond the
                                                included quantity (the starting licenses
                                                beyond it on the cycle-start row).
                                                Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity after this
                                                change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on
                                                the cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|. On a cycle-start row
                                                that bills no license, the unit price of
                                                the charge.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                        - type: object
                                          description: >-
                                            Tiered license proration delta row: one
                                            price band of a license charge billing
                                            under the proration model with
                                            tiered_per_unit pricing. The cycle-start
                                            rows bill each band's opening occupancy
                                            at its full-cycle unit price, and each
                                            change row bills that band's occupancy
                                            delta prorated over the days remaining
                                            in the cycle. quantityDelta and the
                                            row's amount are signed — removals are
                                            negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration_tier
                                              description: >-
                                                Discriminator: tiered license proration
                                                delta row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on a cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the units this band
                                                holds (the band's opening occupancy on a
                                                cycle-start row). Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity across
                                                every band after this change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on a
                                                cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                            planChargeTierId:
                                              type: string
                                              description: >-
                                                The unique identifier of the plan charge
                                                tier this row moved through.
                                              examples:
                                                - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                            from:
                                              type: number
                                              description: >-
                                                Inclusive lower bound of the band, in
                                                licenses.
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Inclusive upper bound of the band, in
                                                licenses. Null on the last, open-ended
                                                band.
                                            unitPrice:
                                              type: string
                                              description: >-
                                                The band's full-cycle price per unit, as
                                                a decimal currency-unit string.
                                                proratedUnitRate is this scaled by
                                                remainingDays over cycleDays.
                                              examples:
                                                - '25.00'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                            - planChargeTierId
                                            - from
                                            - to
                                            - unitPrice
                                        - type: object
                                          description: >-
                                            Unit-price row: billable units
                                            multiplied by a single price per unit.
                                            The row's usage holds the billable
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - unit_price
                                              description: 'Discriminator: unit-price row.'
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.25'
                                          required:
                                            - type
                                            - price
                                        - type: object
                                          description: >-
                                            Included-quantity row: the free
                                            allotment of the charge. The row's usage
                                            holds the units consumed within the
                                            allotment and its amount is always zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - included_quantity
                                              description: 'Discriminator: included-quantity row.'
                                            includedQuantity:
                                              type: number
                                              description: >-
                                                Number of resource units included at no
                                                charge before billing starts.
                                          required:
                                            - type
                                            - includedQuantity
                                        - type: object
                                          description: >-
                                            Package-price row: billable units
                                            charged per started package of
                                            packageSize units. The row's usage holds
                                            the billable units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - package_price
                                              description: 'Discriminator: package-price row.'
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '45.00'
                                            packagesBilled:
                                              type: number
                                              description: >-
                                                Number of packages billed: the billable
                                                units divided by packageSize, rounded
                                                up.
                                          required:
                                            - type
                                            - packageSize
                                            - price
                                            - packagesBilled
                                        - type: object
                                          description: >-
                                            Percentage row: a percentage applied
                                            over a monetary base amount. The row's
                                            usage holds the base amount, in cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - percentage
                                              description: 'Discriminator: percentage row.'
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount,
                                                as a decimal string from 0 to 100 (up to
                                                6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - percentage
                                        - type: object
                                          description: >-
                                            Per-unit overage row: units beyond the
                                            last tier boundary, billed at the
                                            configured excess unit price. The row's
                                            usage holds the units over the boundary.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - per_unit
                                              description: 'Discriminator: overage billed per unit.'
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                resource units.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per excess unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.30'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage overage row: the monetary
                                            base amount beyond the last tier
                                            boundary, billed at the configured
                                            excess percentage. The row's usage holds
                                            the base amount over the boundary, in
                                            cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - percentage
                                              description: >-
                                                Discriminator: overage billed as a
                                                percentage.
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                cents of the monetary base amount.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the excess base
                                                amount, as a decimal string from 0 to
                                                100 (up to 6 decimal places).
                                              examples:
                                                - '1.5'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - percentage
                                        - type: object
                                          description: >-
                                            Original-amount row: surfaces the line
                                            item's pre-adjustment amount when the
                                            line has adjustments (e.g. a discount)
                                            but no price-component rows of its own.
                                            The row's amount equals the line item's
                                            subtotalAmount.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - original_amount
                                              description: 'Discriminator: original-amount row.'
                                          required:
                                            - type
                                        - type: object
                                          description: >-
                                            Fixed unit price row: the quantity of a
                                            fixed charge multiplied by its unit
                                            amount. The row's usage holds the
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_unit_price
                                              description: 'Discriminator: fixed unit price row.'
                                            amount:
                                              type: integer
                                              minimum: 0
                                              description: Amount of one unit, in cents.
                                          required:
                                            - type
                                            - amount
                                        - type: object
                                          description: >-
                                            Custom row: one component of a custom
                                            plan charge, as its calculator billed
                                            it. The row's name, description, usage,
                                            usageFormat and amount hold the rest of
                                            the component.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - custom
                                              description: 'Discriminator: custom row.'
                                            key:
                                              type: string
                                              description: >-
                                                The key of the component in the sub-line
                                                schema of the charge's custom charge
                                                definition, such as documents_overage.
                                              examples:
                                                - documents_overage
                                          required:
                                            - type
                                            - key
                                  required:
                                    - id
                                    - type
                                    - name
                                    - description
                                    - usage
                                    - usageFormat
                                    - amount
                                    - metadata
                                  additionalProperties: false
                                description: >-
                                  Breakdown of the line item amount into priced
                                  rows (included quantities, unit/package/tier
                                  prices, prorations, companions). Empty for
                                  line items without a breakdown.
                              adjustments:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing an adjustment applied on
                                    top of a line item subtotal, such as a
                                    discount or an allocation offset.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the adjustment
                                        in our system.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the adjustment as it
                                        appears on the invoice.
                                      example: Desconto de boas-vindas
                                    type:
                                      type: string
                                      enum:
                                        - monetary_discount
                                        - allocation_offset
                                      description: >-
                                        The kind of adjustment:
                                        monetary_discount (a discount applied to
                                        the line item) or allocation_offset (the
                                        share of the amount moved to another
                                        payment account's invoice under a split
                                        allocation strategy).
                                    amount:
                                      type: number
                                      description: >-
                                        Amount of the adjustment, in cents.
                                        Negative when the adjustment reduces the
                                        line item total.
                                  required:
                                    - id
                                    - name
                                    - type
                                    - amount
                                  additionalProperties: false
                                description: >-
                                  Adjustments applied on top of the line item
                                  subtotal, such as discounts and allocation
                                  offsets.
                            required:
                              - id
                              - idempotencyKey
                              - customerId
                              - productId
                              - resourceId
                              - licenseId
                              - lineItemGroupId
                              - name
                              - scope
                              - startDate
                              - endDate
                              - totalUsage
                              - usageFormat
                              - subtotalAmount
                              - adjustmentAmount
                              - totalAmount
                              - discountAmount
                              - metadata
                              - subLineItems
                              - adjustments
                            additionalProperties: false
                          description: The line items contained in this group.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - planId
                        - planInstanceId
                        - name
                        - startDate
                        - endDate
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - lineItems
                      additionalProperties: false
                    description: >-
                      Line item groups on the invoice. Each group gathers the
                      line items generated from one plan instance (or created as
                      a group on one-off invoices).
                  standaloneLineItems:
                    type: array
                    items:
                      type: object
                      description: >-
                        One amount on an invoice, such as a plan charge, the
                        contract minimum, a tax gross-up (the withheld ISS, the
                        municipal service tax, added on top), a one-off amount
                        or an additional charge.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the line item within
                            the invoice. Supplied by the caller for one-off line
                            items; generated by the billing engine otherwise.
                          example: entrega-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this line item bills. On split or
                            consolidated invoices it may be a subsidiary of the
                            invoice's customer.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this line item
                            belongs to.
                        itemId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the catalog item this line
                            bills. Null for line items not backed by a catalog
                            item.
                        resourceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the metered resource behind
                            a usage_based line item. Null for line items not
                            driven by resource usage.
                        licenseId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the license behind a
                            license_based line item. Null for line items not
                            driven by a license count.
                        lineItemGroupId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the line item group
                            containing this line item. Null for standalone line
                            items.
                        name:
                          type: string
                          description: >-
                            Display name of the line item as it appears on the
                            invoice.
                          example: Entregas
                        scope:
                          type: string
                          enum:
                            - credit_purchase
                            - contract_minimum_commitment
                            - minimum_commitment
                            - fixed
                            - usage_based
                            - license_based
                            - custom
                            - additional_charge
                            - one_off
                            - tax_gross_up
                          description: >-
                            What the line item charges for: usage_based (metered
                            resource consumption), license_based (a license's
                            reported count billed in full), fixed (recurring
                            fixed charge of a plan), custom (custom plan charge,
                            priced by a calculator that Aira writes for you),
                            minimum_commitment (plan-level minimum top-up),
                            contract_minimum_commitment (contract-level minimum
                            top-up), credit_purchase (credit pool top-up),
                            additional_charge (extra charge added manually),
                            one_off (line item of a one-off invoice), or
                            tax_gross_up (tax gross-up charge).
                        startDate:
                          type: string
                          format: date
                          description: Start of the period covered by this line item.
                        endDate:
                          type: string
                          format: date
                          description: End of the period covered by this line item.
                        totalUsage:
                          type: number
                          nullable: true
                          description: >-
                            Total usage billed by the line item, in the unit
                            given by usageFormat. Null for line items without a
                            single usage (e.g. fixed charges without a quantity,
                            and custom line items whose calculator returns no
                            total).
                        usageFormat:
                          type: string
                          enum:
                            - unit
                            - currency
                            - null
                          nullable: true
                          description: >-
                            How to read totalUsage, and the usage of each
                            sub-line item that has no usageFormat of its own:
                            unit means a count of resource units or a fixed
                            charge quantity; currency means a monetary base
                            amount in cents. Null when the line item has no
                            single usage, as a custom line item whose sub-line
                            items bill different kinds of volume, each with its
                            own usageFormat.
                        subtotalAmount:
                          type: number
                          description: >-
                            Line item amount before adjustments, in cents (sum
                            of its sub-line item amounts).
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to this line
                            item (discounts and allocation offsets), in cents.
                            Negative when adjustments reduce the amount owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final line item amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        metadata:
                          description: >-
                            Pricing metadata for the line item, where the shape
                            is keyed by type. Always present, but null for line
                            items without pricing metadata: credit_purchase,
                            additional_charge, one_off, and tax_gross_up. It is
                            populated for fixed (the billing timing),
                            usage_based, license_based, minimum_commitment,
                            contract_minimum_commitment, and custom (the
                            definition and the calculation memory) line items.
                          anyOf:
                            - title: Fixed
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed
                                  description: >-
                                    Discriminator: metadata for a fixed line
                                    item.
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    Whether the fee was billed in advance of its
                                    service period or after it.
                              required:
                                - type
                                - billingTiming
                            - title: Usage-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - usage_based
                                  description: >-
                                    Discriminator: metadata for a usage_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the metered resource accrues over the
                                    billing period: in_full bills the full usage
                                    of the period; proration weighs usage by the
                                    fraction of the period each amount was held.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how
                                    usage was divided across tiers. unique_tier
                                    prices all usage at the single tier that
                                    contains the total; progressive prices each
                                    tier's band separately. Absent for
                                    non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item. Charges priced
                                    before pricing models existed are reported
                                    as advanced.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: License-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_based
                                  description: >-
                                    Discriminator: metadata for a license_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the license count accrues over the
                                    billing period. Always in_full: the latest
                                    reported count is billed in full.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how the
                                    license count was divided across tiers.
                                    unique_tier prices the whole count at the
                                    single tier that contains the total;
                                    progressive prices each tier's band
                                    separately. Absent for non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: Contract minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - contract_minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a
                                    contract_minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the whole
                                    contract in the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the contract's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a plan-level
                                    minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the plan in
                                    the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the plan's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Custom
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - custom
                                  description: >-
                                    Discriminator: metadata for a custom line
                                    item.
                                definitionKey:
                                  type: string
                                  description: >-
                                    The key of the custom charge definition
                                    whose calculator priced the charge,
                                    following the custom:charge:<slug>:<name>
                                    convention.
                                  examples:
                                    - custom:charge:padaria-central:entregas
                                memory:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The full calculation memory that the
                                    calculator returned, such as every tier it
                                    evaluated and the one it billed. Its shape
                                    belongs to the definition.
                              required:
                                - type
                                - definitionKey
                                - memory
                            - title: No metadata
                              type: 'null'
                        subLineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing a sub-line item: one priced
                              row of a line item's breakdown. The row type
                              dictates the shape of metadata.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the sub-line item in
                                  our system.
                              type:
                                type: string
                                enum:
                                  - fixed_price
                                  - minimum_amount
                                  - price_tier_flat
                                  - price_tier_unit
                                  - price_tier_package
                                  - price_tier_percentage
                                  - proration
                                  - license_proration
                                  - license_proration_tier
                                  - unit_price
                                  - included_quantity
                                  - package_price
                                  - percentage
                                  - overage
                                  - original_amount
                                  - fixed_unit_price
                                  - custom
                                description: >-
                                  The kind of priced row: fixed_price and
                                  minimum_amount are companions of usage-based
                                  charges; unit_price, package_price,
                                  percentage, and included_quantity break down
                                  single-model pricing; price_tier_* rows break
                                  down tiered pricing; overage bills usage
                                  beyond the last tier; proration bills per
                                  prorated interval; license_proration bills
                                  license deltas (removals are negative);
                                  original_amount surfaces the pre-adjustment
                                  amount of an adjusted line; fixed_unit_price
                                  breaks down a fixed charge billed as a
                                  quantity times a unit amount; custom bills one
                                  component of a custom plan charge.
                              name:
                                type: string
                                description: >-
                                  Display name of the sub-line item as it
                                  appears on the invoice breakdown.
                                example: '[A partir de 1] Unidades'
                              description:
                                type: string
                                nullable: true
                                description: >-
                                  Optional descriptive text for the row. Null
                                  when absent.
                                example: 120 x 2,50
                              usage:
                                type: number
                                nullable: true
                                description: >-
                                  The usage billed by this row: a count of
                                  resource units (the quantity for a
                                  fixed_unit_price row), or a monetary base
                                  amount in cents for percentage-priced rows
                                  (see the row's usageFormat, or the line item
                                  usageFormat when the row has none). Null for
                                  rows without usage (e.g. companions).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read the usage of this row when the row
                                  has a format of its own, as the custom rows of
                                  a custom line item do: unit means a count,
                                  currency means an amount in cents. Null when
                                  the row reads its usage in the line item
                                  usageFormat.
                              amount:
                                type: number
                                description: >-
                                  Amount billed by this row, in cents. The sum
                                  of a line item's sub-line amounts equals its
                                  subtotalAmount.
                              metadata:
                                description: >-
                                  Pricing details of the row, keyed by the row
                                  type (and pricingType for overage rows).
                                anyOf:
                                  - type: object
                                    description: >-
                                      Fixed-price companion row: the charge's
                                      configured fixed amount, billed alongside
                                      the usage rows. Only rendered when
                                      configured greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_price
                                        description: >-
                                          Discriminator: fixed-price companion
                                          row.
                                      fixedPrice:
                                        type: number
                                        description: >-
                                          The fixed amount configured on the
                                          charge, in cents.
                                    required:
                                      - type
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Minimum-amount companion row: tops the
                                      charge up to its configured minimum when
                                      usage alone stays below it. Only rendered
                                      when the top-up is greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_amount
                                        description: >-
                                          Discriminator: minimum-amount companion
                                          row.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount configured on the
                                          charge, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up billed by this row to reach
                                          the configured minimum, in cents.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - type: object
                                    description: >-
                                      Flat-priced tier row: usage falling in
                                      this tier band is billed at a flat amount,
                                      regardless of the exact quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_flat
                                        description: 'Discriminator: flat-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      fixedPrice:
                                        type: string
                                        description: >-
                                          The flat amount billed for the tier, as
                                          a decimal currency-unit string.
                                        examples:
                                          - '150.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Per-unit priced tier row: units attributed
                                      to this tier band are billed at the tier's
                                      unit price.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_unit
                                        description: 'Discriminator: per-unit priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      price:
                                        type: string
                                        description: >-
                                          Price per unit within the tier, as a
                                          decimal currency-unit string.
                                        examples:
                                          - '0.25'
                                      fixedPrice:
                                        type: string
                                        nullable: true
                                        description: >-
                                          Optional flat fee billed on top when the
                                          tier applies, as a decimal currency-unit
                                          string. Null when the tier has no flat
                                          fee.
                                        examples:
                                          - '10.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - price
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Package-priced tier row: units attributed
                                      to this tier band are billed per started
                                      package of packageSize units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_package
                                        description: 'Discriminator: package-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string.
                                        examples:
                                          - '45.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - packageSize
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage-priced tier row: the monetary
                                      base amount attributed to this tier band
                                      is billed at a percentage.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_percentage
                                        description: >-
                                          Discriminator: percentage-priced tier
                                          row.
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                          Null for an unbounded final tier.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          within the tier, as a decimal string
                                          from 0 to 100 (up to 6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - percentage
                                  - type: object
                                    description: >-
                                      Proration interval row: for charges on
                                      prorated resources, each interval bills
                                      the usage held during it, priced as if
                                      held for the whole cycle and scaled by the
                                      interval's share of the cycle.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - proration
                                        description: 'Discriminator: proration interval row.'
                                      intervalSize:
                                        type: number
                                        description: >-
                                          Length of the interval, in days of the
                                          billing cycle.
                                      amount:
                                        type: string
                                        description: >-
                                          The prorated amount of the interval, as
                                          a decimal currency-unit string: the
                                          interval usage priced as if held for the
                                          whole cycle, scaled by intervalSize over
                                          the cycle length.
                                        examples:
                                          - '29.0322580645'
                                      usage:
                                        type: number
                                        description: The usage held during the interval.
                                      intervalStart:
                                        type: string
                                        format: date
                                        description: First day of the interval.
                                      intervalEnd:
                                        type: string
                                        format: date
                                        description: Last day of the interval.
                                    required:
                                      - type
                                      - intervalSize
                                      - amount
                                      - usage
                                      - intervalStart
                                      - intervalEnd
                                  - type: object
                                    description: >-
                                      License proration delta row: for per_unit
                                      license charges billing under the
                                      proration model, the cycle-start row bills
                                      the starting licenses beyond the included
                                      quantity at their full-cycle price, and
                                      each change row bills the change in those
                                      licenses prorated over the days remaining
                                      in the cycle. A change that stays inside
                                      the included quantity has no row. Tiered
                                      charges use license_proration_tier
                                      instead. quantityDelta and the row's
                                      amount are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration
                                        description: >-
                                          Discriminator: license proration delta
                                          row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on the cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the licenses beyond the
                                          included quantity (the starting licenses
                                          beyond it on the cycle-start row).
                                          Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity after this
                                          change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on
                                          the cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|. On a cycle-start row
                                          that bills no license, the unit price of
                                          the charge.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                  - type: object
                                    description: >-
                                      Tiered license proration delta row: one
                                      price band of a license charge billing
                                      under the proration model with
                                      tiered_per_unit pricing. The cycle-start
                                      rows bill each band's opening occupancy at
                                      its full-cycle unit price, and each change
                                      row bills that band's occupancy delta
                                      prorated over the days remaining in the
                                      cycle. quantityDelta and the row's amount
                                      are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration_tier
                                        description: >-
                                          Discriminator: tiered license proration
                                          delta row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on a cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the units this band
                                          holds (the band's opening occupancy on a
                                          cycle-start row). Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity across
                                          every band after this change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on a
                                          cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                      planChargeTierId:
                                        type: string
                                        description: >-
                                          The unique identifier of the plan charge
                                          tier this row moved through.
                                        examples:
                                          - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                      from:
                                        type: number
                                        description: >-
                                          Inclusive lower bound of the band, in
                                          licenses.
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Inclusive upper bound of the band, in
                                          licenses. Null on the last, open-ended
                                          band.
                                      unitPrice:
                                        type: string
                                        description: >-
                                          The band's full-cycle price per unit, as
                                          a decimal currency-unit string.
                                          proratedUnitRate is this scaled by
                                          remainingDays over cycleDays.
                                        examples:
                                          - '25.00'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                      - planChargeTierId
                                      - from
                                      - to
                                      - unitPrice
                                  - type: object
                                    description: >-
                                      Unit-price row: billable units multiplied
                                      by a single price per unit. The row's
                                      usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - unit_price
                                        description: 'Discriminator: unit-price row.'
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.25'
                                    required:
                                      - type
                                      - price
                                  - type: object
                                    description: >-
                                      Included-quantity row: the free allotment
                                      of the charge. The row's usage holds the
                                      units consumed within the allotment and
                                      its amount is always zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - included_quantity
                                        description: 'Discriminator: included-quantity row.'
                                      includedQuantity:
                                        type: number
                                        description: >-
                                          Number of resource units included at no
                                          charge before billing starts.
                                    required:
                                      - type
                                      - includedQuantity
                                  - type: object
                                    description: >-
                                      Package-price row: billable units charged
                                      per started package of packageSize units.
                                      The row's usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - package_price
                                        description: 'Discriminator: package-price row.'
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '45.00'
                                      packagesBilled:
                                        type: number
                                        description: >-
                                          Number of packages billed: the billable
                                          units divided by packageSize, rounded
                                          up.
                                    required:
                                      - type
                                      - packageSize
                                      - price
                                      - packagesBilled
                                  - type: object
                                    description: >-
                                      Percentage row: a percentage applied over
                                      a monetary base amount. The row's usage
                                      holds the base amount, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - percentage
                                        description: 'Discriminator: percentage row.'
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount,
                                          as a decimal string from 0 to 100 (up to
                                          6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - percentage
                                  - type: object
                                    description: >-
                                      Per-unit overage row: units beyond the
                                      last tier boundary, billed at the
                                      configured excess unit price. The row's
                                      usage holds the units over the boundary.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - per_unit
                                        description: 'Discriminator: overage billed per unit.'
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          resource units.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per excess unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage overage row: the monetary base
                                      amount beyond the last tier boundary,
                                      billed at the configured excess
                                      percentage. The row's usage holds the base
                                      amount over the boundary, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - percentage
                                        description: >-
                                          Discriminator: overage billed as a
                                          percentage.
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          cents of the monetary base amount.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the excess base
                                          amount, as a decimal string from 0 to
                                          100 (up to 6 decimal places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - percentage
                                  - type: object
                                    description: >-
                                      Original-amount row: surfaces the line
                                      item's pre-adjustment amount when the line
                                      has adjustments (e.g. a discount) but no
                                      price-component rows of its own. The row's
                                      amount equals the line item's
                                      subtotalAmount.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - original_amount
                                        description: 'Discriminator: original-amount row.'
                                    required:
                                      - type
                                  - type: object
                                    description: >-
                                      Fixed unit price row: the quantity of a
                                      fixed charge multiplied by its unit
                                      amount. The row's usage holds the
                                      quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_unit_price
                                        description: 'Discriminator: fixed unit price row.'
                                      amount:
                                        type: integer
                                        minimum: 0
                                        description: Amount of one unit, in cents.
                                    required:
                                      - type
                                      - amount
                                  - type: object
                                    description: >-
                                      Custom row: one component of a custom plan
                                      charge, as its calculator billed it. The
                                      row's name, description, usage,
                                      usageFormat and amount hold the rest of
                                      the component.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: 'Discriminator: custom row.'
                                      key:
                                        type: string
                                        description: >-
                                          The key of the component in the sub-line
                                          schema of the charge's custom charge
                                          definition, such as documents_overage.
                                        examples:
                                          - documents_overage
                                    required:
                                      - type
                                      - key
                            required:
                              - id
                              - type
                              - name
                              - description
                              - usage
                              - usageFormat
                              - amount
                              - metadata
                            additionalProperties: false
                          description: >-
                            Breakdown of the line item amount into priced rows
                            (included quantities, unit/package/tier prices,
                            prorations, companions). Empty for line items
                            without a breakdown.
                        adjustments:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing an adjustment applied on top
                              of a line item subtotal, such as a discount or an
                              allocation offset.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the adjustment in our
                                  system.
                              name:
                                type: string
                                description: >-
                                  Display name of the adjustment as it appears
                                  on the invoice.
                                example: Desconto de boas-vindas
                              type:
                                type: string
                                enum:
                                  - monetary_discount
                                  - allocation_offset
                                description: >-
                                  The kind of adjustment: monetary_discount (a
                                  discount applied to the line item) or
                                  allocation_offset (the share of the amount
                                  moved to another payment account's invoice
                                  under a split allocation strategy).
                              amount:
                                type: number
                                description: >-
                                  Amount of the adjustment, in cents. Negative
                                  when the adjustment reduces the line item
                                  total.
                            required:
                              - id
                              - name
                              - type
                              - amount
                            additionalProperties: false
                          description: >-
                            Adjustments applied on top of the line item
                            subtotal, such as discounts and allocation offsets.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - resourceId
                        - licenseId
                        - lineItemGroupId
                        - name
                        - scope
                        - startDate
                        - endDate
                        - totalUsage
                        - usageFormat
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - metadata
                        - subLineItems
                        - adjustments
                      additionalProperties: false
                    description: >-
                      Line items that do not belong to any line item group (e.g.
                      contract-level minimum commitments, additional charges,
                      and ungrouped one-off items).
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of invoices, keyed by the
                      key of each custom field. The object is empty when the
                      invoice holds no value. A user edits them in the billing
                      app, and `PUT /v1/invoices/{id}/custom-fields` replaces
                      the whole set, in any status of the invoice.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  sentAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When Aira last sent the invoice by e-mail to its invoice
                      recipients, in an invoice delivery. Null when Aira has not
                      sent it.
                  replaceReason:
                    type: string
                    enum:
                      - contract_allocation_changed
                      - manually_reopened
                      - null
                    nullable: true
                    description: >-
                      Why one invoice of the same invoice slot replaced another,
                      on both invoices of the replacement: manually_reopened for
                      a reopening, and contract_allocation_changed when a change
                      to the contract allocation canceled the invoice and a
                      later billing of its billing act replaced it. Null when
                      the invoice replaces no invoice and no invoice replaces
                      it.
                  replacesInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the canceled invoice that this
                      invoice replaces in its invoice slot. Null when the
                      invoice replaces no invoice.
                  replacedByInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the invoice that replaces this
                      canceled invoice in its invoice slot. Null when no invoice
                      replaces it.
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - paymentAccountId
                  - contractId
                  - contractInvoiceSequence
                  - issuingAccount
                  - billingAccount
                  - invoiceAllocationStrategy
                  - lastCalculatedAt
                  - invoiceNumber
                  - invoiceDate
                  - memo
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - status
                  - isLocked
                  - failureReason
                  - source
                  - autoIssue
                  - amountDue
                  - dueDate
                  - lineItemGroups
                  - standaloneLineItems
                  - customFields
                  - sentAt
                  - replaceReason
                  - replacesInvoiceId
                  - replacedByInvoiceId
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `invoice_cannot_be_updated`: the invoice, or another invoice of
            its invoice allocation group, is paid or has a pending invoice sync.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `invoiceId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
  /v1/invoices/{invoiceId}/in-review:
    post:
      summary: Mark invoice as in review
      tags:
        - Invoices
      description: >-
        Marks a one-off invoice as in_review. Only one-off invoices can be
        modified through the public API.


        Requires the role `invoices:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice to mark as in review.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: >-
            the invoice is not a one-off invoice, or it is neither open nor in
            review
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            The document that bills one payment account of a customer: from a
            billing act of a contract, as a one-off invoice or from an import.
            It locks when it is issued or canceled, and Aira never recalculates
            a locked invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the invoice in our system.
                  idempotencyKey:
                    type: string
                    description: >-
                      A unique key that identifies the invoice for idempotent
                      creation. Supplied by the caller for one-off invoices;
                      generated by the billing engine for contract invoices.
                    example: padaria-central-2026-11
                  customerId:
                    type: string
                    format: uuid
                    description: The unique identifier of the customer this invoice bills.
                  paymentAccountId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the customer payment account used
                      as the billing account for this invoice.
                  contractId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the contract that generated this
                      invoice. Null for invoices not generated from a contract
                      (e.g. one-off and imported invoices).
                  contractInvoiceSequence:
                    type: integer
                    minimum: 1
                    nullable: true
                    description: >-
                      The number of the invoice within its contract, in the
                      order that Aira created the contract's invoices: 1 for the
                      first, 2 for the next, and so on. Every invoice gets its
                      own number, including each invoice of a split across
                      payment accounts and the replacement of a reopened
                      invoice, and a number never changes and is never reused.
                      Null for invoices without a contract.
                  issuingAccount:
                    type: object
                    description: >-
                      Snapshot of the legal entity issuing the invoice (the
                      seller), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  billingAccount:
                    type: object
                    description: >-
                      Snapshot of the billed party (the legal entity behind the
                      customer payment account), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How the originating contract distributes charges across
                      payment accounts: single bills a single payment account;
                      percent_split divides the total between payment accounts
                      by configured percentages; subsidiary_usage_split divides
                      it according to each subsidiary's usage.
                  lastCalculatedAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When the invoice amounts were last computed by the billing
                      engine. Null when the invoice has never been calculated.
                  invoiceNumber:
                    type: string
                    description: >-
                      Human-readable invoice number, built from the customer's
                      invoice prefix plus a sequential counter.
                    example: ACMEI-0042
                  invoiceDate:
                    type: string
                    format: date
                    description: >-
                      The date of the invoice. On a contract invoice it is the
                      date of its billing act: the first day of the first
                      billing cycle that the contract invoices for an activation
                      invoice, and the last day of the billing cycle for a
                      closing invoice. Its line items state the periods that it
                      bills. On a one-off or imported invoice it is the date
                      given when the invoice was created.
                  memo:
                    type: string
                    nullable: true
                    description: >-
                      Free-form memo attached to the invoice. On contract
                      invoices, it reads "Período <start> a <end>" with the
                      period of the line item that bills most often, such as the
                      month when a monthly fee is billed with an annual fee.
                      When two line items bill equally often, it uses the
                      earlier period. Null when absent.
                    example: Período 01/11/2026 a 30/11/2026
                  subtotalAmount:
                    type: number
                    description: >-
                      Sum of the line item subtotals before adjustments, in
                      cents.
                  adjustmentAmount:
                    type: number
                    description: >-
                      Net amount of all adjustments applied to the invoice line
                      items (discounts and allocation offsets), in cents.
                      Negative when adjustments reduce the amount owed.
                  totalAmount:
                    type: number
                    description: >-
                      Final invoice amount, in cents: subtotalAmount +
                      adjustmentAmount.
                  discountAmount:
                    type: number
                    description: >-
                      The discount portion of adjustmentAmount, in cents (sum of
                      monetary discount adjustments only). Negative when
                      discounts were applied.
                  status:
                    type: string
                    enum:
                      - open
                      - in_review
                      - issued
                      - synced
                      - pending
                      - paid
                      - overdue
                      - canceled
                      - failed
                    description: >-
                      Current status of the invoice lifecycle: open
                      (accumulating charges, editable), in_review (flagged for
                      manual review before issuing), issued (finalized and
                      issued to the customer), synced (registered in the
                      external ERP/payment provider), pending (a payment was
                      initiated and awaits settlement), paid, overdue (unpaid
                      past the due date), canceled, or failed (an issue/sync
                      attempt failed and needs attention).
                  isLocked:
                    type: boolean
                    description: >-
                      Whether the invoice contents are locked against edits.
                      Aira locks an invoice when it issues or cancels it,
                      together with the other invoices of its allocation group,
                      except when it cancels the invoice because its payment
                      account left the allocation of the contract, which locks
                      only that invoice. A locked invoice stays locked, also
                      when its status later moves to failed.
                  failureReason:
                    type: string
                    nullable: true
                    description: >-
                      Reason for the most recent failure on the invoice (e.g. an
                      ERP sync or payment issue). Null when the invoice has no
                      active failure.
                    example: contract_sync_not_found
                  source:
                    type: string
                    enum:
                      - contract
                      - one_off
                      - import
                    description: >-
                      How the invoice originated: contract (generated by a
                      contract billing cycle), one_off (created manually or
                      through the API), or import (ingested from an external
                      system).
                  autoIssue:
                    type: boolean
                    description: >-
                      Whether the invoice is issued automatically when its
                      billing cycle closes, without manual review.
                  amountDue:
                    type: number
                    nullable: true
                    description: >-
                      Outstanding amount due on the invoice, in cents. Null when
                      not tracked.
                  dueDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Payment due date of the invoice. Null when no due date is
                      set (e.g. before the invoice is issued).
                  lineItemGroups:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a line item group: a container that
                        gathers the line items generated from one plan instance
                        (or created as a group on one-off invoices). Monetary
                        amounts are integers in cents.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item group in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the group within the
                            invoice. Supplied by the caller for one-off groups;
                            generated by the billing engine otherwise.
                          example: servicos-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this group bills.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this group
                            belongs to.
                        planId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan whose instance
                            generated this group. Null for groups not generated
                            from a plan (e.g. on one-off invoices).
                        planInstanceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan instance that
                            generated this group. Null for groups not generated
                            from a plan instance.
                        name:
                          type: string
                          description: >-
                            Display name of the group as it appears on the
                            invoice, typically the plan or product name.
                          example: Plano Entregas
                        startDate:
                          type: string
                          format: date
                          description: >-
                            Start of the period that the group shows. On
                            contract invoices, it is the period of the group's
                            line item that bills most often, such as the month
                            when a monthly fee is billed with an annual fee.
                            When two line items bill equally often, it is the
                            earlier period.
                        endDate:
                          type: string
                          format: date
                          description: >-
                            End of the period that the group shows, which
                            `startDate` describes.
                        subtotalAmount:
                          type: number
                          description: >-
                            Sum of the group's line item subtotals before
                            adjustments, in cents.
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to the group's
                            line items (discounts and allocation offsets), in
                            cents. Negative when adjustments reduce the amount
                            owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final group amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        lineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              One amount on an invoice, such as a plan charge,
                              the contract minimum, a tax gross-up (the withheld
                              ISS, the municipal service tax, added on top), a
                              one-off amount or an additional charge.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the line item in our
                                  system.
                              idempotencyKey:
                                type: string
                                description: >-
                                  A unique key that identifies the line item
                                  within the invoice. Supplied by the caller for
                                  one-off line items; generated by the billing
                                  engine otherwise.
                                example: entrega-novembro
                              customerId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the customer whose
                                  consumption this line item bills. On split or
                                  consolidated invoices it may be a subsidiary
                                  of the invoice's customer.
                              productId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the product this line
                                  item belongs to.
                              itemId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the catalog item this
                                  line bills. Null for line items not backed by
                                  a catalog item.
                              resourceId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the metered resource
                                  behind a usage_based line item. Null for line
                                  items not driven by resource usage.
                              licenseId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the license behind a
                                  license_based line item. Null for line items
                                  not driven by a license count.
                              lineItemGroupId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the line item group
                                  containing this line item. Null for standalone
                                  line items.
                              name:
                                type: string
                                description: >-
                                  Display name of the line item as it appears on
                                  the invoice.
                                example: Entregas
                              scope:
                                type: string
                                enum:
                                  - credit_purchase
                                  - contract_minimum_commitment
                                  - minimum_commitment
                                  - fixed
                                  - usage_based
                                  - license_based
                                  - custom
                                  - additional_charge
                                  - one_off
                                  - tax_gross_up
                                description: >-
                                  What the line item charges for: usage_based
                                  (metered resource consumption), license_based
                                  (a license's reported count billed in full),
                                  fixed (recurring fixed charge of a plan),
                                  custom (custom plan charge, priced by a
                                  calculator that Aira writes for you),
                                  minimum_commitment (plan-level minimum
                                  top-up), contract_minimum_commitment
                                  (contract-level minimum top-up),
                                  credit_purchase (credit pool top-up),
                                  additional_charge (extra charge added
                                  manually), one_off (line item of a one-off
                                  invoice), or tax_gross_up (tax gross-up
                                  charge).
                              startDate:
                                type: string
                                format: date
                                description: Start of the period covered by this line item.
                              endDate:
                                type: string
                                format: date
                                description: End of the period covered by this line item.
                              totalUsage:
                                type: number
                                nullable: true
                                description: >-
                                  Total usage billed by the line item, in the
                                  unit given by usageFormat. Null for line items
                                  without a single usage (e.g. fixed charges
                                  without a quantity, and custom line items
                                  whose calculator returns no total).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read totalUsage, and the usage of each
                                  sub-line item that has no usageFormat of its
                                  own: unit means a count of resource units or a
                                  fixed charge quantity; currency means a
                                  monetary base amount in cents. Null when the
                                  line item has no single usage, as a custom
                                  line item whose sub-line items bill different
                                  kinds of volume, each with its own
                                  usageFormat.
                              subtotalAmount:
                                type: number
                                description: >-
                                  Line item amount before adjustments, in cents
                                  (sum of its sub-line item amounts).
                              adjustmentAmount:
                                type: number
                                description: >-
                                  Net amount of the adjustments applied to this
                                  line item (discounts and allocation offsets),
                                  in cents. Negative when adjustments reduce the
                                  amount owed.
                              totalAmount:
                                type: number
                                description: >-
                                  Final line item amount, in cents:
                                  subtotalAmount + adjustmentAmount.
                              discountAmount:
                                type: number
                                description: >-
                                  The discount portion of adjustmentAmount, in
                                  cents (sum of monetary discount adjustments
                                  only). Negative when discounts were applied.
                              metadata:
                                description: >-
                                  Pricing metadata for the line item, where the
                                  shape is keyed by type. Always present, but
                                  null for line items without pricing metadata:
                                  credit_purchase, additional_charge, one_off,
                                  and tax_gross_up. It is populated for fixed
                                  (the billing timing), usage_based,
                                  license_based, minimum_commitment,
                                  contract_minimum_commitment, and custom (the
                                  definition and the calculation memory) line
                                  items.
                                anyOf:
                                  - title: Fixed
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed
                                        description: >-
                                          Discriminator: metadata for a fixed line
                                          item.
                                      billingTiming:
                                        type: string
                                        enum:
                                          - in_advance
                                          - in_arrears
                                        description: >-
                                          Whether the fee was billed in advance of
                                          its service period or after it.
                                    required:
                                      - type
                                      - billingTiming
                                  - title: Usage-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - usage_based
                                        description: >-
                                          Discriminator: metadata for a
                                          usage_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the metered resource accrues over
                                          the billing period: in_full bills the
                                          full usage of the period; proration
                                          weighs usage by the fraction of the
                                          period each amount was held.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          usage was divided across tiers.
                                          unique_tier prices all usage at the
                                          single tier that contains the total;
                                          progressive prices each tier's band
                                          separately. Absent for non-tiered
                                          models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item. Charges
                                          priced before pricing models existed are
                                          reported as advanced.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: License-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_based
                                        description: >-
                                          Discriminator: metadata for a
                                          license_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the license count accrues over the
                                          billing period. Always in_full: the
                                          latest reported count is billed in full.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          the license count was divided across
                                          tiers. unique_tier prices the whole
                                          count at the single tier that contains
                                          the total; progressive prices each
                                          tier's band separately. Absent for
                                          non-tiered models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: Contract minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - contract_minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a
                                          contract_minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          whole contract in the billing period, in
                                          cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the contract's consumption amounted
                                          to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a plan-level
                                          minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          plan in the billing period, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the plan's consumption amounted to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Custom
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: >-
                                          Discriminator: metadata for a custom
                                          line item.
                                      definitionKey:
                                        type: string
                                        description: >-
                                          The key of the custom charge definition
                                          whose calculator priced the charge,
                                          following the
                                          custom:charge:<slug>:<name> convention.
                                        examples:
                                          - custom:charge:padaria-central:entregas
                                      memory:
                                        type: object
                                        additionalProperties: true
                                        description: >-
                                          The full calculation memory that the
                                          calculator returned, such as every tier
                                          it evaluated and the one it billed. Its
                                          shape belongs to the definition.
                                    required:
                                      - type
                                      - definitionKey
                                      - memory
                                  - title: No metadata
                                    type: 'null'
                              subLineItems:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing a sub-line item: one
                                    priced row of a line item's breakdown. The
                                    row type dictates the shape of metadata.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the sub-line
                                        item in our system.
                                    type:
                                      type: string
                                      enum:
                                        - fixed_price
                                        - minimum_amount
                                        - price_tier_flat
                                        - price_tier_unit
                                        - price_tier_package
                                        - price_tier_percentage
                                        - proration
                                        - license_proration
                                        - license_proration_tier
                                        - unit_price
                                        - included_quantity
                                        - package_price
                                        - percentage
                                        - overage
                                        - original_amount
                                        - fixed_unit_price
                                        - custom
                                      description: >-
                                        The kind of priced row: fixed_price and
                                        minimum_amount are companions of
                                        usage-based charges; unit_price,
                                        package_price, percentage, and
                                        included_quantity break down
                                        single-model pricing; price_tier_* rows
                                        break down tiered pricing; overage bills
                                        usage beyond the last tier; proration
                                        bills per prorated interval;
                                        license_proration bills license deltas
                                        (removals are negative); original_amount
                                        surfaces the pre-adjustment amount of an
                                        adjusted line; fixed_unit_price breaks
                                        down a fixed charge billed as a quantity
                                        times a unit amount; custom bills one
                                        component of a custom plan charge.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the sub-line item as it
                                        appears on the invoice breakdown.
                                      example: '[A partir de 1] Unidades'
                                    description:
                                      type: string
                                      nullable: true
                                      description: >-
                                        Optional descriptive text for the row.
                                        Null when absent.
                                      example: 120 x 2,50
                                    usage:
                                      type: number
                                      nullable: true
                                      description: >-
                                        The usage billed by this row: a count of
                                        resource units (the quantity for a
                                        fixed_unit_price row), or a monetary
                                        base amount in cents for
                                        percentage-priced rows (see the row's
                                        usageFormat, or the line item
                                        usageFormat when the row has none). Null
                                        for rows without usage (e.g.
                                        companions).
                                    usageFormat:
                                      type: string
                                      enum:
                                        - unit
                                        - currency
                                        - null
                                      nullable: true
                                      description: >-
                                        How to read the usage of this row when
                                        the row has a format of its own, as the
                                        custom rows of a custom line item do:
                                        unit means a count, currency means an
                                        amount in cents. Null when the row reads
                                        its usage in the line item usageFormat.
                                    amount:
                                      type: number
                                      description: >-
                                        Amount billed by this row, in cents. The
                                        sum of a line item's sub-line amounts
                                        equals its subtotalAmount.
                                    metadata:
                                      description: >-
                                        Pricing details of the row, keyed by the
                                        row type (and pricingType for overage
                                        rows).
                                      anyOf:
                                        - type: object
                                          description: >-
                                            Fixed-price companion row: the charge's
                                            configured fixed amount, billed
                                            alongside the usage rows. Only rendered
                                            when configured greater than zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_price
                                              description: >-
                                                Discriminator: fixed-price companion
                                                row.
                                            fixedPrice:
                                              type: number
                                              description: >-
                                                The fixed amount configured on the
                                                charge, in cents.
                                          required:
                                            - type
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Minimum-amount companion row: tops the
                                            charge up to its configured minimum when
                                            usage alone stays below it. Only
                                            rendered when the top-up is greater than
                                            zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - minimum_amount
                                              description: >-
                                                Discriminator: minimum-amount companion
                                                row.
                                            minimumAmount:
                                              type: number
                                              description: >-
                                                The minimum amount configured on the
                                                charge, in cents.
                                            minimumAmountApplied:
                                              type: number
                                              description: >-
                                                The top-up billed by this row to reach
                                                the configured minimum, in cents.
                                          required:
                                            - type
                                            - minimumAmount
                                            - minimumAmountApplied
                                        - type: object
                                          description: >-
                                            Flat-priced tier row: usage falling in
                                            this tier band is billed at a flat
                                            amount, regardless of the exact
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_flat
                                              description: 'Discriminator: flat-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            fixedPrice:
                                              type: string
                                              description: >-
                                                The flat amount billed for the tier, as
                                                a decimal currency-unit string.
                                              examples:
                                                - '150.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Per-unit priced tier row: units
                                            attributed to this tier band are billed
                                            at the tier's unit price.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_unit
                                              description: 'Discriminator: per-unit priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            price:
                                              type: string
                                              description: >-
                                                Price per unit within the tier, as a
                                                decimal currency-unit string.
                                              examples:
                                                - '0.25'
                                            fixedPrice:
                                              type: string
                                              nullable: true
                                              description: >-
                                                Optional flat fee billed on top when the
                                                tier applies, as a decimal currency-unit
                                                string. Null when the tier has no flat
                                                fee.
                                              examples:
                                                - '10.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - price
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Package-priced tier row: units
                                            attributed to this tier band are billed
                                            per started package of packageSize
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_package
                                              description: 'Discriminator: package-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string.
                                              examples:
                                                - '45.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - packageSize
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage-priced tier row: the monetary
                                            base amount attributed to this tier band
                                            is billed at a percentage.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_percentage
                                              description: >-
                                                Discriminator: percentage-priced tier
                                                row.
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                                Null for an unbounded final tier.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount
                                                within the tier, as a decimal string
                                                from 0 to 100 (up to 6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - percentage
                                        - type: object
                                          description: >-
                                            Proration interval row: for charges on
                                            prorated resources, each interval bills
                                            the usage held during it, priced as if
                                            held for the whole cycle and scaled by
                                            the interval's share of the cycle.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - proration
                                              description: 'Discriminator: proration interval row.'
                                            intervalSize:
                                              type: number
                                              description: >-
                                                Length of the interval, in days of the
                                                billing cycle.
                                            amount:
                                              type: string
                                              description: >-
                                                The prorated amount of the interval, as
                                                a decimal currency-unit string: the
                                                interval usage priced as if held for the
                                                whole cycle, scaled by intervalSize over
                                                the cycle length.
                                              examples:
                                                - '29.0322580645'
                                            usage:
                                              type: number
                                              description: The usage held during the interval.
                                            intervalStart:
                                              type: string
                                              format: date
                                              description: First day of the interval.
                                            intervalEnd:
                                              type: string
                                              format: date
                                              description: Last day of the interval.
                                          required:
                                            - type
                                            - intervalSize
                                            - amount
                                            - usage
                                            - intervalStart
                                            - intervalEnd
                                        - type: object
                                          description: >-
                                            License proration delta row: for
                                            per_unit license charges billing under
                                            the proration model, the cycle-start row
                                            bills the starting licenses beyond the
                                            included quantity at their full-cycle
                                            price, and each change row bills the
                                            change in those licenses prorated over
                                            the days remaining in the cycle. A
                                            change that stays inside the included
                                            quantity has no row. Tiered charges use
                                            license_proration_tier instead.
                                            quantityDelta and the row's amount are
                                            signed — removals are negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration
                                              description: >-
                                                Discriminator: license proration delta
                                                row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on the cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the licenses beyond the
                                                included quantity (the starting licenses
                                                beyond it on the cycle-start row).
                                                Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity after this
                                                change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on
                                                the cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|. On a cycle-start row
                                                that bills no license, the unit price of
                                                the charge.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                        - type: object
                                          description: >-
                                            Tiered license proration delta row: one
                                            price band of a license charge billing
                                            under the proration model with
                                            tiered_per_unit pricing. The cycle-start
                                            rows bill each band's opening occupancy
                                            at its full-cycle unit price, and each
                                            change row bills that band's occupancy
                                            delta prorated over the days remaining
                                            in the cycle. quantityDelta and the
                                            row's amount are signed — removals are
                                            negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration_tier
                                              description: >-
                                                Discriminator: tiered license proration
                                                delta row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on a cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the units this band
                                                holds (the band's opening occupancy on a
                                                cycle-start row). Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity across
                                                every band after this change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on a
                                                cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                            planChargeTierId:
                                              type: string
                                              description: >-
                                                The unique identifier of the plan charge
                                                tier this row moved through.
                                              examples:
                                                - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                            from:
                                              type: number
                                              description: >-
                                                Inclusive lower bound of the band, in
                                                licenses.
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Inclusive upper bound of the band, in
                                                licenses. Null on the last, open-ended
                                                band.
                                            unitPrice:
                                              type: string
                                              description: >-
                                                The band's full-cycle price per unit, as
                                                a decimal currency-unit string.
                                                proratedUnitRate is this scaled by
                                                remainingDays over cycleDays.
                                              examples:
                                                - '25.00'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                            - planChargeTierId
                                            - from
                                            - to
                                            - unitPrice
                                        - type: object
                                          description: >-
                                            Unit-price row: billable units
                                            multiplied by a single price per unit.
                                            The row's usage holds the billable
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - unit_price
                                              description: 'Discriminator: unit-price row.'
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.25'
                                          required:
                                            - type
                                            - price
                                        - type: object
                                          description: >-
                                            Included-quantity row: the free
                                            allotment of the charge. The row's usage
                                            holds the units consumed within the
                                            allotment and its amount is always zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - included_quantity
                                              description: 'Discriminator: included-quantity row.'
                                            includedQuantity:
                                              type: number
                                              description: >-
                                                Number of resource units included at no
                                                charge before billing starts.
                                          required:
                                            - type
                                            - includedQuantity
                                        - type: object
                                          description: >-
                                            Package-price row: billable units
                                            charged per started package of
                                            packageSize units. The row's usage holds
                                            the billable units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - package_price
                                              description: 'Discriminator: package-price row.'
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '45.00'
                                            packagesBilled:
                                              type: number
                                              description: >-
                                                Number of packages billed: the billable
                                                units divided by packageSize, rounded
                                                up.
                                          required:
                                            - type
                                            - packageSize
                                            - price
                                            - packagesBilled
                                        - type: object
                                          description: >-
                                            Percentage row: a percentage applied
                                            over a monetary base amount. The row's
                                            usage holds the base amount, in cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - percentage
                                              description: 'Discriminator: percentage row.'
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount,
                                                as a decimal string from 0 to 100 (up to
                                                6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - percentage
                                        - type: object
                                          description: >-
                                            Per-unit overage row: units beyond the
                                            last tier boundary, billed at the
                                            configured excess unit price. The row's
                                            usage holds the units over the boundary.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - per_unit
                                              description: 'Discriminator: overage billed per unit.'
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                resource units.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per excess unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.30'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage overage row: the monetary
                                            base amount beyond the last tier
                                            boundary, billed at the configured
                                            excess percentage. The row's usage holds
                                            the base amount over the boundary, in
                                            cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - percentage
                                              description: >-
                                                Discriminator: overage billed as a
                                                percentage.
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                cents of the monetary base amount.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the excess base
                                                amount, as a decimal string from 0 to
                                                100 (up to 6 decimal places).
                                              examples:
                                                - '1.5'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - percentage
                                        - type: object
                                          description: >-
                                            Original-amount row: surfaces the line
                                            item's pre-adjustment amount when the
                                            line has adjustments (e.g. a discount)
                                            but no price-component rows of its own.
                                            The row's amount equals the line item's
                                            subtotalAmount.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - original_amount
                                              description: 'Discriminator: original-amount row.'
                                          required:
                                            - type
                                        - type: object
                                          description: >-
                                            Fixed unit price row: the quantity of a
                                            fixed charge multiplied by its unit
                                            amount. The row's usage holds the
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_unit_price
                                              description: 'Discriminator: fixed unit price row.'
                                            amount:
                                              type: integer
                                              minimum: 0
                                              description: Amount of one unit, in cents.
                                          required:
                                            - type
                                            - amount
                                        - type: object
                                          description: >-
                                            Custom row: one component of a custom
                                            plan charge, as its calculator billed
                                            it. The row's name, description, usage,
                                            usageFormat and amount hold the rest of
                                            the component.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - custom
                                              description: 'Discriminator: custom row.'
                                            key:
                                              type: string
                                              description: >-
                                                The key of the component in the sub-line
                                                schema of the charge's custom charge
                                                definition, such as documents_overage.
                                              examples:
                                                - documents_overage
                                          required:
                                            - type
                                            - key
                                  required:
                                    - id
                                    - type
                                    - name
                                    - description
                                    - usage
                                    - usageFormat
                                    - amount
                                    - metadata
                                  additionalProperties: false
                                description: >-
                                  Breakdown of the line item amount into priced
                                  rows (included quantities, unit/package/tier
                                  prices, prorations, companions). Empty for
                                  line items without a breakdown.
                              adjustments:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing an adjustment applied on
                                    top of a line item subtotal, such as a
                                    discount or an allocation offset.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the adjustment
                                        in our system.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the adjustment as it
                                        appears on the invoice.
                                      example: Desconto de boas-vindas
                                    type:
                                      type: string
                                      enum:
                                        - monetary_discount
                                        - allocation_offset
                                      description: >-
                                        The kind of adjustment:
                                        monetary_discount (a discount applied to
                                        the line item) or allocation_offset (the
                                        share of the amount moved to another
                                        payment account's invoice under a split
                                        allocation strategy).
                                    amount:
                                      type: number
                                      description: >-
                                        Amount of the adjustment, in cents.
                                        Negative when the adjustment reduces the
                                        line item total.
                                  required:
                                    - id
                                    - name
                                    - type
                                    - amount
                                  additionalProperties: false
                                description: >-
                                  Adjustments applied on top of the line item
                                  subtotal, such as discounts and allocation
                                  offsets.
                            required:
                              - id
                              - idempotencyKey
                              - customerId
                              - productId
                              - resourceId
                              - licenseId
                              - lineItemGroupId
                              - name
                              - scope
                              - startDate
                              - endDate
                              - totalUsage
                              - usageFormat
                              - subtotalAmount
                              - adjustmentAmount
                              - totalAmount
                              - discountAmount
                              - metadata
                              - subLineItems
                              - adjustments
                            additionalProperties: false
                          description: The line items contained in this group.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - planId
                        - planInstanceId
                        - name
                        - startDate
                        - endDate
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - lineItems
                      additionalProperties: false
                    description: >-
                      Line item groups on the invoice. Each group gathers the
                      line items generated from one plan instance (or created as
                      a group on one-off invoices).
                  standaloneLineItems:
                    type: array
                    items:
                      type: object
                      description: >-
                        One amount on an invoice, such as a plan charge, the
                        contract minimum, a tax gross-up (the withheld ISS, the
                        municipal service tax, added on top), a one-off amount
                        or an additional charge.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the line item within
                            the invoice. Supplied by the caller for one-off line
                            items; generated by the billing engine otherwise.
                          example: entrega-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this line item bills. On split or
                            consolidated invoices it may be a subsidiary of the
                            invoice's customer.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this line item
                            belongs to.
                        itemId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the catalog item this line
                            bills. Null for line items not backed by a catalog
                            item.
                        resourceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the metered resource behind
                            a usage_based line item. Null for line items not
                            driven by resource usage.
                        licenseId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the license behind a
                            license_based line item. Null for line items not
                            driven by a license count.
                        lineItemGroupId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the line item group
                            containing this line item. Null for standalone line
                            items.
                        name:
                          type: string
                          description: >-
                            Display name of the line item as it appears on the
                            invoice.
                          example: Entregas
                        scope:
                          type: string
                          enum:
                            - credit_purchase
                            - contract_minimum_commitment
                            - minimum_commitment
                            - fixed
                            - usage_based
                            - license_based
                            - custom
                            - additional_charge
                            - one_off
                            - tax_gross_up
                          description: >-
                            What the line item charges for: usage_based (metered
                            resource consumption), license_based (a license's
                            reported count billed in full), fixed (recurring
                            fixed charge of a plan), custom (custom plan charge,
                            priced by a calculator that Aira writes for you),
                            minimum_commitment (plan-level minimum top-up),
                            contract_minimum_commitment (contract-level minimum
                            top-up), credit_purchase (credit pool top-up),
                            additional_charge (extra charge added manually),
                            one_off (line item of a one-off invoice), or
                            tax_gross_up (tax gross-up charge).
                        startDate:
                          type: string
                          format: date
                          description: Start of the period covered by this line item.
                        endDate:
                          type: string
                          format: date
                          description: End of the period covered by this line item.
                        totalUsage:
                          type: number
                          nullable: true
                          description: >-
                            Total usage billed by the line item, in the unit
                            given by usageFormat. Null for line items without a
                            single usage (e.g. fixed charges without a quantity,
                            and custom line items whose calculator returns no
                            total).
                        usageFormat:
                          type: string
                          enum:
                            - unit
                            - currency
                            - null
                          nullable: true
                          description: >-
                            How to read totalUsage, and the usage of each
                            sub-line item that has no usageFormat of its own:
                            unit means a count of resource units or a fixed
                            charge quantity; currency means a monetary base
                            amount in cents. Null when the line item has no
                            single usage, as a custom line item whose sub-line
                            items bill different kinds of volume, each with its
                            own usageFormat.
                        subtotalAmount:
                          type: number
                          description: >-
                            Line item amount before adjustments, in cents (sum
                            of its sub-line item amounts).
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to this line
                            item (discounts and allocation offsets), in cents.
                            Negative when adjustments reduce the amount owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final line item amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        metadata:
                          description: >-
                            Pricing metadata for the line item, where the shape
                            is keyed by type. Always present, but null for line
                            items without pricing metadata: credit_purchase,
                            additional_charge, one_off, and tax_gross_up. It is
                            populated for fixed (the billing timing),
                            usage_based, license_based, minimum_commitment,
                            contract_minimum_commitment, and custom (the
                            definition and the calculation memory) line items.
                          anyOf:
                            - title: Fixed
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed
                                  description: >-
                                    Discriminator: metadata for a fixed line
                                    item.
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    Whether the fee was billed in advance of its
                                    service period or after it.
                              required:
                                - type
                                - billingTiming
                            - title: Usage-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - usage_based
                                  description: >-
                                    Discriminator: metadata for a usage_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the metered resource accrues over the
                                    billing period: in_full bills the full usage
                                    of the period; proration weighs usage by the
                                    fraction of the period each amount was held.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how
                                    usage was divided across tiers. unique_tier
                                    prices all usage at the single tier that
                                    contains the total; progressive prices each
                                    tier's band separately. Absent for
                                    non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item. Charges priced
                                    before pricing models existed are reported
                                    as advanced.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: License-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_based
                                  description: >-
                                    Discriminator: metadata for a license_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the license count accrues over the
                                    billing period. Always in_full: the latest
                                    reported count is billed in full.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how the
                                    license count was divided across tiers.
                                    unique_tier prices the whole count at the
                                    single tier that contains the total;
                                    progressive prices each tier's band
                                    separately. Absent for non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: Contract minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - contract_minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a
                                    contract_minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the whole
                                    contract in the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the contract's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a plan-level
                                    minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the plan in
                                    the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the plan's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Custom
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - custom
                                  description: >-
                                    Discriminator: metadata for a custom line
                                    item.
                                definitionKey:
                                  type: string
                                  description: >-
                                    The key of the custom charge definition
                                    whose calculator priced the charge,
                                    following the custom:charge:<slug>:<name>
                                    convention.
                                  examples:
                                    - custom:charge:padaria-central:entregas
                                memory:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The full calculation memory that the
                                    calculator returned, such as every tier it
                                    evaluated and the one it billed. Its shape
                                    belongs to the definition.
                              required:
                                - type
                                - definitionKey
                                - memory
                            - title: No metadata
                              type: 'null'
                        subLineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing a sub-line item: one priced
                              row of a line item's breakdown. The row type
                              dictates the shape of metadata.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the sub-line item in
                                  our system.
                              type:
                                type: string
                                enum:
                                  - fixed_price
                                  - minimum_amount
                                  - price_tier_flat
                                  - price_tier_unit
                                  - price_tier_package
                                  - price_tier_percentage
                                  - proration
                                  - license_proration
                                  - license_proration_tier
                                  - unit_price
                                  - included_quantity
                                  - package_price
                                  - percentage
                                  - overage
                                  - original_amount
                                  - fixed_unit_price
                                  - custom
                                description: >-
                                  The kind of priced row: fixed_price and
                                  minimum_amount are companions of usage-based
                                  charges; unit_price, package_price,
                                  percentage, and included_quantity break down
                                  single-model pricing; price_tier_* rows break
                                  down tiered pricing; overage bills usage
                                  beyond the last tier; proration bills per
                                  prorated interval; license_proration bills
                                  license deltas (removals are negative);
                                  original_amount surfaces the pre-adjustment
                                  amount of an adjusted line; fixed_unit_price
                                  breaks down a fixed charge billed as a
                                  quantity times a unit amount; custom bills one
                                  component of a custom plan charge.
                              name:
                                type: string
                                description: >-
                                  Display name of the sub-line item as it
                                  appears on the invoice breakdown.
                                example: '[A partir de 1] Unidades'
                              description:
                                type: string
                                nullable: true
                                description: >-
                                  Optional descriptive text for the row. Null
                                  when absent.
                                example: 120 x 2,50
                              usage:
                                type: number
                                nullable: true
                                description: >-
                                  The usage billed by this row: a count of
                                  resource units (the quantity for a
                                  fixed_unit_price row), or a monetary base
                                  amount in cents for percentage-priced rows
                                  (see the row's usageFormat, or the line item
                                  usageFormat when the row has none). Null for
                                  rows without usage (e.g. companions).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read the usage of this row when the row
                                  has a format of its own, as the custom rows of
                                  a custom line item do: unit means a count,
                                  currency means an amount in cents. Null when
                                  the row reads its usage in the line item
                                  usageFormat.
                              amount:
                                type: number
                                description: >-
                                  Amount billed by this row, in cents. The sum
                                  of a line item's sub-line amounts equals its
                                  subtotalAmount.
                              metadata:
                                description: >-
                                  Pricing details of the row, keyed by the row
                                  type (and pricingType for overage rows).
                                anyOf:
                                  - type: object
                                    description: >-
                                      Fixed-price companion row: the charge's
                                      configured fixed amount, billed alongside
                                      the usage rows. Only rendered when
                                      configured greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_price
                                        description: >-
                                          Discriminator: fixed-price companion
                                          row.
                                      fixedPrice:
                                        type: number
                                        description: >-
                                          The fixed amount configured on the
                                          charge, in cents.
                                    required:
                                      - type
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Minimum-amount companion row: tops the
                                      charge up to its configured minimum when
                                      usage alone stays below it. Only rendered
                                      when the top-up is greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_amount
                                        description: >-
                                          Discriminator: minimum-amount companion
                                          row.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount configured on the
                                          charge, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up billed by this row to reach
                                          the configured minimum, in cents.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - type: object
                                    description: >-
                                      Flat-priced tier row: usage falling in
                                      this tier band is billed at a flat amount,
                                      regardless of the exact quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_flat
                                        description: 'Discriminator: flat-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      fixedPrice:
                                        type: string
                                        description: >-
                                          The flat amount billed for the tier, as
                                          a decimal currency-unit string.
                                        examples:
                                          - '150.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Per-unit priced tier row: units attributed
                                      to this tier band are billed at the tier's
                                      unit price.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_unit
                                        description: 'Discriminator: per-unit priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      price:
                                        type: string
                                        description: >-
                                          Price per unit within the tier, as a
                                          decimal currency-unit string.
                                        examples:
                                          - '0.25'
                                      fixedPrice:
                                        type: string
                                        nullable: true
                                        description: >-
                                          Optional flat fee billed on top when the
                                          tier applies, as a decimal currency-unit
                                          string. Null when the tier has no flat
                                          fee.
                                        examples:
                                          - '10.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - price
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Package-priced tier row: units attributed
                                      to this tier band are billed per started
                                      package of packageSize units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_package
                                        description: 'Discriminator: package-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string.
                                        examples:
                                          - '45.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - packageSize
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage-priced tier row: the monetary
                                      base amount attributed to this tier band
                                      is billed at a percentage.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_percentage
                                        description: >-
                                          Discriminator: percentage-priced tier
                                          row.
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                          Null for an unbounded final tier.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          within the tier, as a decimal string
                                          from 0 to 100 (up to 6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - percentage
                                  - type: object
                                    description: >-
                                      Proration interval row: for charges on
                                      prorated resources, each interval bills
                                      the usage held during it, priced as if
                                      held for the whole cycle and scaled by the
                                      interval's share of the cycle.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - proration
                                        description: 'Discriminator: proration interval row.'
                                      intervalSize:
                                        type: number
                                        description: >-
                                          Length of the interval, in days of the
                                          billing cycle.
                                      amount:
                                        type: string
                                        description: >-
                                          The prorated amount of the interval, as
                                          a decimal currency-unit string: the
                                          interval usage priced as if held for the
                                          whole cycle, scaled by intervalSize over
                                          the cycle length.
                                        examples:
                                          - '29.0322580645'
                                      usage:
                                        type: number
                                        description: The usage held during the interval.
                                      intervalStart:
                                        type: string
                                        format: date
                                        description: First day of the interval.
                                      intervalEnd:
                                        type: string
                                        format: date
                                        description: Last day of the interval.
                                    required:
                                      - type
                                      - intervalSize
                                      - amount
                                      - usage
                                      - intervalStart
                                      - intervalEnd
                                  - type: object
                                    description: >-
                                      License proration delta row: for per_unit
                                      license charges billing under the
                                      proration model, the cycle-start row bills
                                      the starting licenses beyond the included
                                      quantity at their full-cycle price, and
                                      each change row bills the change in those
                                      licenses prorated over the days remaining
                                      in the cycle. A change that stays inside
                                      the included quantity has no row. Tiered
                                      charges use license_proration_tier
                                      instead. quantityDelta and the row's
                                      amount are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration
                                        description: >-
                                          Discriminator: license proration delta
                                          row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on the cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the licenses beyond the
                                          included quantity (the starting licenses
                                          beyond it on the cycle-start row).
                                          Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity after this
                                          change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on
                                          the cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|. On a cycle-start row
                                          that bills no license, the unit price of
                                          the charge.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                  - type: object
                                    description: >-
                                      Tiered license proration delta row: one
                                      price band of a license charge billing
                                      under the proration model with
                                      tiered_per_unit pricing. The cycle-start
                                      rows bill each band's opening occupancy at
                                      its full-cycle unit price, and each change
                                      row bills that band's occupancy delta
                                      prorated over the days remaining in the
                                      cycle. quantityDelta and the row's amount
                                      are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration_tier
                                        description: >-
                                          Discriminator: tiered license proration
                                          delta row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on a cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the units this band
                                          holds (the band's opening occupancy on a
                                          cycle-start row). Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity across
                                          every band after this change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on a
                                          cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                      planChargeTierId:
                                        type: string
                                        description: >-
                                          The unique identifier of the plan charge
                                          tier this row moved through.
                                        examples:
                                          - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                      from:
                                        type: number
                                        description: >-
                                          Inclusive lower bound of the band, in
                                          licenses.
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Inclusive upper bound of the band, in
                                          licenses. Null on the last, open-ended
                                          band.
                                      unitPrice:
                                        type: string
                                        description: >-
                                          The band's full-cycle price per unit, as
                                          a decimal currency-unit string.
                                          proratedUnitRate is this scaled by
                                          remainingDays over cycleDays.
                                        examples:
                                          - '25.00'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                      - planChargeTierId
                                      - from
                                      - to
                                      - unitPrice
                                  - type: object
                                    description: >-
                                      Unit-price row: billable units multiplied
                                      by a single price per unit. The row's
                                      usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - unit_price
                                        description: 'Discriminator: unit-price row.'
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.25'
                                    required:
                                      - type
                                      - price
                                  - type: object
                                    description: >-
                                      Included-quantity row: the free allotment
                                      of the charge. The row's usage holds the
                                      units consumed within the allotment and
                                      its amount is always zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - included_quantity
                                        description: 'Discriminator: included-quantity row.'
                                      includedQuantity:
                                        type: number
                                        description: >-
                                          Number of resource units included at no
                                          charge before billing starts.
                                    required:
                                      - type
                                      - includedQuantity
                                  - type: object
                                    description: >-
                                      Package-price row: billable units charged
                                      per started package of packageSize units.
                                      The row's usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - package_price
                                        description: 'Discriminator: package-price row.'
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '45.00'
                                      packagesBilled:
                                        type: number
                                        description: >-
                                          Number of packages billed: the billable
                                          units divided by packageSize, rounded
                                          up.
                                    required:
                                      - type
                                      - packageSize
                                      - price
                                      - packagesBilled
                                  - type: object
                                    description: >-
                                      Percentage row: a percentage applied over
                                      a monetary base amount. The row's usage
                                      holds the base amount, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - percentage
                                        description: 'Discriminator: percentage row.'
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount,
                                          as a decimal string from 0 to 100 (up to
                                          6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - percentage
                                  - type: object
                                    description: >-
                                      Per-unit overage row: units beyond the
                                      last tier boundary, billed at the
                                      configured excess unit price. The row's
                                      usage holds the units over the boundary.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - per_unit
                                        description: 'Discriminator: overage billed per unit.'
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          resource units.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per excess unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage overage row: the monetary base
                                      amount beyond the last tier boundary,
                                      billed at the configured excess
                                      percentage. The row's usage holds the base
                                      amount over the boundary, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - percentage
                                        description: >-
                                          Discriminator: overage billed as a
                                          percentage.
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          cents of the monetary base amount.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the excess base
                                          amount, as a decimal string from 0 to
                                          100 (up to 6 decimal places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - percentage
                                  - type: object
                                    description: >-
                                      Original-amount row: surfaces the line
                                      item's pre-adjustment amount when the line
                                      has adjustments (e.g. a discount) but no
                                      price-component rows of its own. The row's
                                      amount equals the line item's
                                      subtotalAmount.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - original_amount
                                        description: 'Discriminator: original-amount row.'
                                    required:
                                      - type
                                  - type: object
                                    description: >-
                                      Fixed unit price row: the quantity of a
                                      fixed charge multiplied by its unit
                                      amount. The row's usage holds the
                                      quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_unit_price
                                        description: 'Discriminator: fixed unit price row.'
                                      amount:
                                        type: integer
                                        minimum: 0
                                        description: Amount of one unit, in cents.
                                    required:
                                      - type
                                      - amount
                                  - type: object
                                    description: >-
                                      Custom row: one component of a custom plan
                                      charge, as its calculator billed it. The
                                      row's name, description, usage,
                                      usageFormat and amount hold the rest of
                                      the component.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: 'Discriminator: custom row.'
                                      key:
                                        type: string
                                        description: >-
                                          The key of the component in the sub-line
                                          schema of the charge's custom charge
                                          definition, such as documents_overage.
                                        examples:
                                          - documents_overage
                                    required:
                                      - type
                                      - key
                            required:
                              - id
                              - type
                              - name
                              - description
                              - usage
                              - usageFormat
                              - amount
                              - metadata
                            additionalProperties: false
                          description: >-
                            Breakdown of the line item amount into priced rows
                            (included quantities, unit/package/tier prices,
                            prorations, companions). Empty for line items
                            without a breakdown.
                        adjustments:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing an adjustment applied on top
                              of a line item subtotal, such as a discount or an
                              allocation offset.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the adjustment in our
                                  system.
                              name:
                                type: string
                                description: >-
                                  Display name of the adjustment as it appears
                                  on the invoice.
                                example: Desconto de boas-vindas
                              type:
                                type: string
                                enum:
                                  - monetary_discount
                                  - allocation_offset
                                description: >-
                                  The kind of adjustment: monetary_discount (a
                                  discount applied to the line item) or
                                  allocation_offset (the share of the amount
                                  moved to another payment account's invoice
                                  under a split allocation strategy).
                              amount:
                                type: number
                                description: >-
                                  Amount of the adjustment, in cents. Negative
                                  when the adjustment reduces the line item
                                  total.
                            required:
                              - id
                              - name
                              - type
                              - amount
                            additionalProperties: false
                          description: >-
                            Adjustments applied on top of the line item
                            subtotal, such as discounts and allocation offsets.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - resourceId
                        - licenseId
                        - lineItemGroupId
                        - name
                        - scope
                        - startDate
                        - endDate
                        - totalUsage
                        - usageFormat
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - metadata
                        - subLineItems
                        - adjustments
                      additionalProperties: false
                    description: >-
                      Line items that do not belong to any line item group (e.g.
                      contract-level minimum commitments, additional charges,
                      and ungrouped one-off items).
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of invoices, keyed by the
                      key of each custom field. The object is empty when the
                      invoice holds no value. A user edits them in the billing
                      app, and `PUT /v1/invoices/{id}/custom-fields` replaces
                      the whole set, in any status of the invoice.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  sentAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When Aira last sent the invoice by e-mail to its invoice
                      recipients, in an invoice delivery. Null when Aira has not
                      sent it.
                  replaceReason:
                    type: string
                    enum:
                      - contract_allocation_changed
                      - manually_reopened
                      - null
                    nullable: true
                    description: >-
                      Why one invoice of the same invoice slot replaced another,
                      on both invoices of the replacement: manually_reopened for
                      a reopening, and contract_allocation_changed when a change
                      to the contract allocation canceled the invoice and a
                      later billing of its billing act replaced it. Null when
                      the invoice replaces no invoice and no invoice replaces
                      it.
                  replacesInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the canceled invoice that this
                      invoice replaces in its invoice slot. Null when the
                      invoice replaces no invoice.
                  replacedByInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the invoice that replaces this
                      canceled invoice in its invoice slot. Null when no invoice
                      replaces it.
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - paymentAccountId
                  - contractId
                  - contractInvoiceSequence
                  - issuingAccount
                  - billingAccount
                  - invoiceAllocationStrategy
                  - lastCalculatedAt
                  - invoiceNumber
                  - invoiceDate
                  - memo
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - status
                  - isLocked
                  - failureReason
                  - source
                  - autoIssue
                  - amountDue
                  - dueDate
                  - lineItemGroups
                  - standaloneLineItems
                  - customFields
                  - sentAt
                  - replaceReason
                  - replacesInvoiceId
                  - replacedByInvoiceId
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is not a one-off invoice,
            or it is neither open nor in review.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `invoiceId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
  /v1/invoices/{invoiceId}/issue:
    post:
      summary: Issue invoice
      tags:
        - Invoices
      description: >-
        Issues an invoice in in_review, one-off or of a contract. An invoice
        that Aira already issued comes back as it is, so a retry is safe.


        Requires the role `invoices:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice to issue.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_issue_blocked
          when: Aira is still generating the invoice artifacts of the invoice
        - status: 400
          code: invoice_cannot_be_updated
          when: the invoice is open or canceled
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            The document that bills one payment account of a customer: from a
            billing act of a contract, as a one-off invoice or from an import.
            It locks when it is issued or canceled, and Aira never recalculates
            a locked invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the invoice in our system.
                  idempotencyKey:
                    type: string
                    description: >-
                      A unique key that identifies the invoice for idempotent
                      creation. Supplied by the caller for one-off invoices;
                      generated by the billing engine for contract invoices.
                    example: padaria-central-2026-11
                  customerId:
                    type: string
                    format: uuid
                    description: The unique identifier of the customer this invoice bills.
                  paymentAccountId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the customer payment account used
                      as the billing account for this invoice.
                  contractId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the contract that generated this
                      invoice. Null for invoices not generated from a contract
                      (e.g. one-off and imported invoices).
                  contractInvoiceSequence:
                    type: integer
                    minimum: 1
                    nullable: true
                    description: >-
                      The number of the invoice within its contract, in the
                      order that Aira created the contract's invoices: 1 for the
                      first, 2 for the next, and so on. Every invoice gets its
                      own number, including each invoice of a split across
                      payment accounts and the replacement of a reopened
                      invoice, and a number never changes and is never reused.
                      Null for invoices without a contract.
                  issuingAccount:
                    type: object
                    description: >-
                      Snapshot of the legal entity issuing the invoice (the
                      seller), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  billingAccount:
                    type: object
                    description: >-
                      Snapshot of the billed party (the legal entity behind the
                      customer payment account), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How the originating contract distributes charges across
                      payment accounts: single bills a single payment account;
                      percent_split divides the total between payment accounts
                      by configured percentages; subsidiary_usage_split divides
                      it according to each subsidiary's usage.
                  lastCalculatedAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When the invoice amounts were last computed by the billing
                      engine. Null when the invoice has never been calculated.
                  invoiceNumber:
                    type: string
                    description: >-
                      Human-readable invoice number, built from the customer's
                      invoice prefix plus a sequential counter.
                    example: ACMEI-0042
                  invoiceDate:
                    type: string
                    format: date
                    description: >-
                      The date of the invoice. On a contract invoice it is the
                      date of its billing act: the first day of the first
                      billing cycle that the contract invoices for an activation
                      invoice, and the last day of the billing cycle for a
                      closing invoice. Its line items state the periods that it
                      bills. On a one-off or imported invoice it is the date
                      given when the invoice was created.
                  memo:
                    type: string
                    nullable: true
                    description: >-
                      Free-form memo attached to the invoice. On contract
                      invoices, it reads "Período <start> a <end>" with the
                      period of the line item that bills most often, such as the
                      month when a monthly fee is billed with an annual fee.
                      When two line items bill equally often, it uses the
                      earlier period. Null when absent.
                    example: Período 01/11/2026 a 30/11/2026
                  subtotalAmount:
                    type: number
                    description: >-
                      Sum of the line item subtotals before adjustments, in
                      cents.
                  adjustmentAmount:
                    type: number
                    description: >-
                      Net amount of all adjustments applied to the invoice line
                      items (discounts and allocation offsets), in cents.
                      Negative when adjustments reduce the amount owed.
                  totalAmount:
                    type: number
                    description: >-
                      Final invoice amount, in cents: subtotalAmount +
                      adjustmentAmount.
                  discountAmount:
                    type: number
                    description: >-
                      The discount portion of adjustmentAmount, in cents (sum of
                      monetary discount adjustments only). Negative when
                      discounts were applied.
                  status:
                    type: string
                    enum:
                      - open
                      - in_review
                      - issued
                      - synced
                      - pending
                      - paid
                      - overdue
                      - canceled
                      - failed
                    description: >-
                      Current status of the invoice lifecycle: open
                      (accumulating charges, editable), in_review (flagged for
                      manual review before issuing), issued (finalized and
                      issued to the customer), synced (registered in the
                      external ERP/payment provider), pending (a payment was
                      initiated and awaits settlement), paid, overdue (unpaid
                      past the due date), canceled, or failed (an issue/sync
                      attempt failed and needs attention).
                  isLocked:
                    type: boolean
                    description: >-
                      Whether the invoice contents are locked against edits.
                      Aira locks an invoice when it issues or cancels it,
                      together with the other invoices of its allocation group,
                      except when it cancels the invoice because its payment
                      account left the allocation of the contract, which locks
                      only that invoice. A locked invoice stays locked, also
                      when its status later moves to failed.
                  failureReason:
                    type: string
                    nullable: true
                    description: >-
                      Reason for the most recent failure on the invoice (e.g. an
                      ERP sync or payment issue). Null when the invoice has no
                      active failure.
                    example: contract_sync_not_found
                  source:
                    type: string
                    enum:
                      - contract
                      - one_off
                      - import
                    description: >-
                      How the invoice originated: contract (generated by a
                      contract billing cycle), one_off (created manually or
                      through the API), or import (ingested from an external
                      system).
                  autoIssue:
                    type: boolean
                    description: >-
                      Whether the invoice is issued automatically when its
                      billing cycle closes, without manual review.
                  amountDue:
                    type: number
                    nullable: true
                    description: >-
                      Outstanding amount due on the invoice, in cents. Null when
                      not tracked.
                  dueDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Payment due date of the invoice. Null when no due date is
                      set (e.g. before the invoice is issued).
                  lineItemGroups:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a line item group: a container that
                        gathers the line items generated from one plan instance
                        (or created as a group on one-off invoices). Monetary
                        amounts are integers in cents.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item group in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the group within the
                            invoice. Supplied by the caller for one-off groups;
                            generated by the billing engine otherwise.
                          example: servicos-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this group bills.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this group
                            belongs to.
                        planId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan whose instance
                            generated this group. Null for groups not generated
                            from a plan (e.g. on one-off invoices).
                        planInstanceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan instance that
                            generated this group. Null for groups not generated
                            from a plan instance.
                        name:
                          type: string
                          description: >-
                            Display name of the group as it appears on the
                            invoice, typically the plan or product name.
                          example: Plano Entregas
                        startDate:
                          type: string
                          format: date
                          description: >-
                            Start of the period that the group shows. On
                            contract invoices, it is the period of the group's
                            line item that bills most often, such as the month
                            when a monthly fee is billed with an annual fee.
                            When two line items bill equally often, it is the
                            earlier period.
                        endDate:
                          type: string
                          format: date
                          description: >-
                            End of the period that the group shows, which
                            `startDate` describes.
                        subtotalAmount:
                          type: number
                          description: >-
                            Sum of the group's line item subtotals before
                            adjustments, in cents.
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to the group's
                            line items (discounts and allocation offsets), in
                            cents. Negative when adjustments reduce the amount
                            owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final group amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        lineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              One amount on an invoice, such as a plan charge,
                              the contract minimum, a tax gross-up (the withheld
                              ISS, the municipal service tax, added on top), a
                              one-off amount or an additional charge.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the line item in our
                                  system.
                              idempotencyKey:
                                type: string
                                description: >-
                                  A unique key that identifies the line item
                                  within the invoice. Supplied by the caller for
                                  one-off line items; generated by the billing
                                  engine otherwise.
                                example: entrega-novembro
                              customerId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the customer whose
                                  consumption this line item bills. On split or
                                  consolidated invoices it may be a subsidiary
                                  of the invoice's customer.
                              productId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the product this line
                                  item belongs to.
                              itemId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the catalog item this
                                  line bills. Null for line items not backed by
                                  a catalog item.
                              resourceId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the metered resource
                                  behind a usage_based line item. Null for line
                                  items not driven by resource usage.
                              licenseId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the license behind a
                                  license_based line item. Null for line items
                                  not driven by a license count.
                              lineItemGroupId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the line item group
                                  containing this line item. Null for standalone
                                  line items.
                              name:
                                type: string
                                description: >-
                                  Display name of the line item as it appears on
                                  the invoice.
                                example: Entregas
                              scope:
                                type: string
                                enum:
                                  - credit_purchase
                                  - contract_minimum_commitment
                                  - minimum_commitment
                                  - fixed
                                  - usage_based
                                  - license_based
                                  - custom
                                  - additional_charge
                                  - one_off
                                  - tax_gross_up
                                description: >-
                                  What the line item charges for: usage_based
                                  (metered resource consumption), license_based
                                  (a license's reported count billed in full),
                                  fixed (recurring fixed charge of a plan),
                                  custom (custom plan charge, priced by a
                                  calculator that Aira writes for you),
                                  minimum_commitment (plan-level minimum
                                  top-up), contract_minimum_commitment
                                  (contract-level minimum top-up),
                                  credit_purchase (credit pool top-up),
                                  additional_charge (extra charge added
                                  manually), one_off (line item of a one-off
                                  invoice), or tax_gross_up (tax gross-up
                                  charge).
                              startDate:
                                type: string
                                format: date
                                description: Start of the period covered by this line item.
                              endDate:
                                type: string
                                format: date
                                description: End of the period covered by this line item.
                              totalUsage:
                                type: number
                                nullable: true
                                description: >-
                                  Total usage billed by the line item, in the
                                  unit given by usageFormat. Null for line items
                                  without a single usage (e.g. fixed charges
                                  without a quantity, and custom line items
                                  whose calculator returns no total).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read totalUsage, and the usage of each
                                  sub-line item that has no usageFormat of its
                                  own: unit means a count of resource units or a
                                  fixed charge quantity; currency means a
                                  monetary base amount in cents. Null when the
                                  line item has no single usage, as a custom
                                  line item whose sub-line items bill different
                                  kinds of volume, each with its own
                                  usageFormat.
                              subtotalAmount:
                                type: number
                                description: >-
                                  Line item amount before adjustments, in cents
                                  (sum of its sub-line item amounts).
                              adjustmentAmount:
                                type: number
                                description: >-
                                  Net amount of the adjustments applied to this
                                  line item (discounts and allocation offsets),
                                  in cents. Negative when adjustments reduce the
                                  amount owed.
                              totalAmount:
                                type: number
                                description: >-
                                  Final line item amount, in cents:
                                  subtotalAmount + adjustmentAmount.
                              discountAmount:
                                type: number
                                description: >-
                                  The discount portion of adjustmentAmount, in
                                  cents (sum of monetary discount adjustments
                                  only). Negative when discounts were applied.
                              metadata:
                                description: >-
                                  Pricing metadata for the line item, where the
                                  shape is keyed by type. Always present, but
                                  null for line items without pricing metadata:
                                  credit_purchase, additional_charge, one_off,
                                  and tax_gross_up. It is populated for fixed
                                  (the billing timing), usage_based,
                                  license_based, minimum_commitment,
                                  contract_minimum_commitment, and custom (the
                                  definition and the calculation memory) line
                                  items.
                                anyOf:
                                  - title: Fixed
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed
                                        description: >-
                                          Discriminator: metadata for a fixed line
                                          item.
                                      billingTiming:
                                        type: string
                                        enum:
                                          - in_advance
                                          - in_arrears
                                        description: >-
                                          Whether the fee was billed in advance of
                                          its service period or after it.
                                    required:
                                      - type
                                      - billingTiming
                                  - title: Usage-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - usage_based
                                        description: >-
                                          Discriminator: metadata for a
                                          usage_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the metered resource accrues over
                                          the billing period: in_full bills the
                                          full usage of the period; proration
                                          weighs usage by the fraction of the
                                          period each amount was held.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          usage was divided across tiers.
                                          unique_tier prices all usage at the
                                          single tier that contains the total;
                                          progressive prices each tier's band
                                          separately. Absent for non-tiered
                                          models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item. Charges
                                          priced before pricing models existed are
                                          reported as advanced.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: License-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_based
                                        description: >-
                                          Discriminator: metadata for a
                                          license_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the license count accrues over the
                                          billing period. Always in_full: the
                                          latest reported count is billed in full.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          the license count was divided across
                                          tiers. unique_tier prices the whole
                                          count at the single tier that contains
                                          the total; progressive prices each
                                          tier's band separately. Absent for
                                          non-tiered models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: Contract minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - contract_minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a
                                          contract_minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          whole contract in the billing period, in
                                          cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the contract's consumption amounted
                                          to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a plan-level
                                          minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          plan in the billing period, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the plan's consumption amounted to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Custom
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: >-
                                          Discriminator: metadata for a custom
                                          line item.
                                      definitionKey:
                                        type: string
                                        description: >-
                                          The key of the custom charge definition
                                          whose calculator priced the charge,
                                          following the
                                          custom:charge:<slug>:<name> convention.
                                        examples:
                                          - custom:charge:padaria-central:entregas
                                      memory:
                                        type: object
                                        additionalProperties: true
                                        description: >-
                                          The full calculation memory that the
                                          calculator returned, such as every tier
                                          it evaluated and the one it billed. Its
                                          shape belongs to the definition.
                                    required:
                                      - type
                                      - definitionKey
                                      - memory
                                  - title: No metadata
                                    type: 'null'
                              subLineItems:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing a sub-line item: one
                                    priced row of a line item's breakdown. The
                                    row type dictates the shape of metadata.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the sub-line
                                        item in our system.
                                    type:
                                      type: string
                                      enum:
                                        - fixed_price
                                        - minimum_amount
                                        - price_tier_flat
                                        - price_tier_unit
                                        - price_tier_package
                                        - price_tier_percentage
                                        - proration
                                        - license_proration
                                        - license_proration_tier
                                        - unit_price
                                        - included_quantity
                                        - package_price
                                        - percentage
                                        - overage
                                        - original_amount
                                        - fixed_unit_price
                                        - custom
                                      description: >-
                                        The kind of priced row: fixed_price and
                                        minimum_amount are companions of
                                        usage-based charges; unit_price,
                                        package_price, percentage, and
                                        included_quantity break down
                                        single-model pricing; price_tier_* rows
                                        break down tiered pricing; overage bills
                                        usage beyond the last tier; proration
                                        bills per prorated interval;
                                        license_proration bills license deltas
                                        (removals are negative); original_amount
                                        surfaces the pre-adjustment amount of an
                                        adjusted line; fixed_unit_price breaks
                                        down a fixed charge billed as a quantity
                                        times a unit amount; custom bills one
                                        component of a custom plan charge.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the sub-line item as it
                                        appears on the invoice breakdown.
                                      example: '[A partir de 1] Unidades'
                                    description:
                                      type: string
                                      nullable: true
                                      description: >-
                                        Optional descriptive text for the row.
                                        Null when absent.
                                      example: 120 x 2,50
                                    usage:
                                      type: number
                                      nullable: true
                                      description: >-
                                        The usage billed by this row: a count of
                                        resource units (the quantity for a
                                        fixed_unit_price row), or a monetary
                                        base amount in cents for
                                        percentage-priced rows (see the row's
                                        usageFormat, or the line item
                                        usageFormat when the row has none). Null
                                        for rows without usage (e.g.
                                        companions).
                                    usageFormat:
                                      type: string
                                      enum:
                                        - unit
                                        - currency
                                        - null
                                      nullable: true
                                      description: >-
                                        How to read the usage of this row when
                                        the row has a format of its own, as the
                                        custom rows of a custom line item do:
                                        unit means a count, currency means an
                                        amount in cents. Null when the row reads
                                        its usage in the line item usageFormat.
                                    amount:
                                      type: number
                                      description: >-
                                        Amount billed by this row, in cents. The
                                        sum of a line item's sub-line amounts
                                        equals its subtotalAmount.
                                    metadata:
                                      description: >-
                                        Pricing details of the row, keyed by the
                                        row type (and pricingType for overage
                                        rows).
                                      anyOf:
                                        - type: object
                                          description: >-
                                            Fixed-price companion row: the charge's
                                            configured fixed amount, billed
                                            alongside the usage rows. Only rendered
                                            when configured greater than zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_price
                                              description: >-
                                                Discriminator: fixed-price companion
                                                row.
                                            fixedPrice:
                                              type: number
                                              description: >-
                                                The fixed amount configured on the
                                                charge, in cents.
                                          required:
                                            - type
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Minimum-amount companion row: tops the
                                            charge up to its configured minimum when
                                            usage alone stays below it. Only
                                            rendered when the top-up is greater than
                                            zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - minimum_amount
                                              description: >-
                                                Discriminator: minimum-amount companion
                                                row.
                                            minimumAmount:
                                              type: number
                                              description: >-
                                                The minimum amount configured on the
                                                charge, in cents.
                                            minimumAmountApplied:
                                              type: number
                                              description: >-
                                                The top-up billed by this row to reach
                                                the configured minimum, in cents.
                                          required:
                                            - type
                                            - minimumAmount
                                            - minimumAmountApplied
                                        - type: object
                                          description: >-
                                            Flat-priced tier row: usage falling in
                                            this tier band is billed at a flat
                                            amount, regardless of the exact
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_flat
                                              description: 'Discriminator: flat-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            fixedPrice:
                                              type: string
                                              description: >-
                                                The flat amount billed for the tier, as
                                                a decimal currency-unit string.
                                              examples:
                                                - '150.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Per-unit priced tier row: units
                                            attributed to this tier band are billed
                                            at the tier's unit price.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_unit
                                              description: 'Discriminator: per-unit priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            price:
                                              type: string
                                              description: >-
                                                Price per unit within the tier, as a
                                                decimal currency-unit string.
                                              examples:
                                                - '0.25'
                                            fixedPrice:
                                              type: string
                                              nullable: true
                                              description: >-
                                                Optional flat fee billed on top when the
                                                tier applies, as a decimal currency-unit
                                                string. Null when the tier has no flat
                                                fee.
                                              examples:
                                                - '10.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - price
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Package-priced tier row: units
                                            attributed to this tier band are billed
                                            per started package of packageSize
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_package
                                              description: 'Discriminator: package-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string.
                                              examples:
                                                - '45.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - packageSize
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage-priced tier row: the monetary
                                            base amount attributed to this tier band
                                            is billed at a percentage.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_percentage
                                              description: >-
                                                Discriminator: percentage-priced tier
                                                row.
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                                Null for an unbounded final tier.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount
                                                within the tier, as a decimal string
                                                from 0 to 100 (up to 6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - percentage
                                        - type: object
                                          description: >-
                                            Proration interval row: for charges on
                                            prorated resources, each interval bills
                                            the usage held during it, priced as if
                                            held for the whole cycle and scaled by
                                            the interval's share of the cycle.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - proration
                                              description: 'Discriminator: proration interval row.'
                                            intervalSize:
                                              type: number
                                              description: >-
                                                Length of the interval, in days of the
                                                billing cycle.
                                            amount:
                                              type: string
                                              description: >-
                                                The prorated amount of the interval, as
                                                a decimal currency-unit string: the
                                                interval usage priced as if held for the
                                                whole cycle, scaled by intervalSize over
                                                the cycle length.
                                              examples:
                                                - '29.0322580645'
                                            usage:
                                              type: number
                                              description: The usage held during the interval.
                                            intervalStart:
                                              type: string
                                              format: date
                                              description: First day of the interval.
                                            intervalEnd:
                                              type: string
                                              format: date
                                              description: Last day of the interval.
                                          required:
                                            - type
                                            - intervalSize
                                            - amount
                                            - usage
                                            - intervalStart
                                            - intervalEnd
                                        - type: object
                                          description: >-
                                            License proration delta row: for
                                            per_unit license charges billing under
                                            the proration model, the cycle-start row
                                            bills the starting licenses beyond the
                                            included quantity at their full-cycle
                                            price, and each change row bills the
                                            change in those licenses prorated over
                                            the days remaining in the cycle. A
                                            change that stays inside the included
                                            quantity has no row. Tiered charges use
                                            license_proration_tier instead.
                                            quantityDelta and the row's amount are
                                            signed — removals are negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration
                                              description: >-
                                                Discriminator: license proration delta
                                                row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on the cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the licenses beyond the
                                                included quantity (the starting licenses
                                                beyond it on the cycle-start row).
                                                Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity after this
                                                change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on
                                                the cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|. On a cycle-start row
                                                that bills no license, the unit price of
                                                the charge.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                        - type: object
                                          description: >-
                                            Tiered license proration delta row: one
                                            price band of a license charge billing
                                            under the proration model with
                                            tiered_per_unit pricing. The cycle-start
                                            rows bill each band's opening occupancy
                                            at its full-cycle unit price, and each
                                            change row bills that band's occupancy
                                            delta prorated over the days remaining
                                            in the cycle. quantityDelta and the
                                            row's amount are signed — removals are
                                            negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration_tier
                                              description: >-
                                                Discriminator: tiered license proration
                                                delta row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on a cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the units this band
                                                holds (the band's opening occupancy on a
                                                cycle-start row). Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity across
                                                every band after this change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on a
                                                cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                            planChargeTierId:
                                              type: string
                                              description: >-
                                                The unique identifier of the plan charge
                                                tier this row moved through.
                                              examples:
                                                - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                            from:
                                              type: number
                                              description: >-
                                                Inclusive lower bound of the band, in
                                                licenses.
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Inclusive upper bound of the band, in
                                                licenses. Null on the last, open-ended
                                                band.
                                            unitPrice:
                                              type: string
                                              description: >-
                                                The band's full-cycle price per unit, as
                                                a decimal currency-unit string.
                                                proratedUnitRate is this scaled by
                                                remainingDays over cycleDays.
                                              examples:
                                                - '25.00'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                            - planChargeTierId
                                            - from
                                            - to
                                            - unitPrice
                                        - type: object
                                          description: >-
                                            Unit-price row: billable units
                                            multiplied by a single price per unit.
                                            The row's usage holds the billable
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - unit_price
                                              description: 'Discriminator: unit-price row.'
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.25'
                                          required:
                                            - type
                                            - price
                                        - type: object
                                          description: >-
                                            Included-quantity row: the free
                                            allotment of the charge. The row's usage
                                            holds the units consumed within the
                                            allotment and its amount is always zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - included_quantity
                                              description: 'Discriminator: included-quantity row.'
                                            includedQuantity:
                                              type: number
                                              description: >-
                                                Number of resource units included at no
                                                charge before billing starts.
                                          required:
                                            - type
                                            - includedQuantity
                                        - type: object
                                          description: >-
                                            Package-price row: billable units
                                            charged per started package of
                                            packageSize units. The row's usage holds
                                            the billable units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - package_price
                                              description: 'Discriminator: package-price row.'
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '45.00'
                                            packagesBilled:
                                              type: number
                                              description: >-
                                                Number of packages billed: the billable
                                                units divided by packageSize, rounded
                                                up.
                                          required:
                                            - type
                                            - packageSize
                                            - price
                                            - packagesBilled
                                        - type: object
                                          description: >-
                                            Percentage row: a percentage applied
                                            over a monetary base amount. The row's
                                            usage holds the base amount, in cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - percentage
                                              description: 'Discriminator: percentage row.'
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount,
                                                as a decimal string from 0 to 100 (up to
                                                6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - percentage
                                        - type: object
                                          description: >-
                                            Per-unit overage row: units beyond the
                                            last tier boundary, billed at the
                                            configured excess unit price. The row's
                                            usage holds the units over the boundary.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - per_unit
                                              description: 'Discriminator: overage billed per unit.'
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                resource units.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per excess unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.30'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage overage row: the monetary
                                            base amount beyond the last tier
                                            boundary, billed at the configured
                                            excess percentage. The row's usage holds
                                            the base amount over the boundary, in
                                            cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - percentage
                                              description: >-
                                                Discriminator: overage billed as a
                                                percentage.
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                cents of the monetary base amount.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the excess base
                                                amount, as a decimal string from 0 to
                                                100 (up to 6 decimal places).
                                              examples:
                                                - '1.5'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - percentage
                                        - type: object
                                          description: >-
                                            Original-amount row: surfaces the line
                                            item's pre-adjustment amount when the
                                            line has adjustments (e.g. a discount)
                                            but no price-component rows of its own.
                                            The row's amount equals the line item's
                                            subtotalAmount.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - original_amount
                                              description: 'Discriminator: original-amount row.'
                                          required:
                                            - type
                                        - type: object
                                          description: >-
                                            Fixed unit price row: the quantity of a
                                            fixed charge multiplied by its unit
                                            amount. The row's usage holds the
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_unit_price
                                              description: 'Discriminator: fixed unit price row.'
                                            amount:
                                              type: integer
                                              minimum: 0
                                              description: Amount of one unit, in cents.
                                          required:
                                            - type
                                            - amount
                                        - type: object
                                          description: >-
                                            Custom row: one component of a custom
                                            plan charge, as its calculator billed
                                            it. The row's name, description, usage,
                                            usageFormat and amount hold the rest of
                                            the component.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - custom
                                              description: 'Discriminator: custom row.'
                                            key:
                                              type: string
                                              description: >-
                                                The key of the component in the sub-line
                                                schema of the charge's custom charge
                                                definition, such as documents_overage.
                                              examples:
                                                - documents_overage
                                          required:
                                            - type
                                            - key
                                  required:
                                    - id
                                    - type
                                    - name
                                    - description
                                    - usage
                                    - usageFormat
                                    - amount
                                    - metadata
                                  additionalProperties: false
                                description: >-
                                  Breakdown of the line item amount into priced
                                  rows (included quantities, unit/package/tier
                                  prices, prorations, companions). Empty for
                                  line items without a breakdown.
                              adjustments:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing an adjustment applied on
                                    top of a line item subtotal, such as a
                                    discount or an allocation offset.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the adjustment
                                        in our system.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the adjustment as it
                                        appears on the invoice.
                                      example: Desconto de boas-vindas
                                    type:
                                      type: string
                                      enum:
                                        - monetary_discount
                                        - allocation_offset
                                      description: >-
                                        The kind of adjustment:
                                        monetary_discount (a discount applied to
                                        the line item) or allocation_offset (the
                                        share of the amount moved to another
                                        payment account's invoice under a split
                                        allocation strategy).
                                    amount:
                                      type: number
                                      description: >-
                                        Amount of the adjustment, in cents.
                                        Negative when the adjustment reduces the
                                        line item total.
                                  required:
                                    - id
                                    - name
                                    - type
                                    - amount
                                  additionalProperties: false
                                description: >-
                                  Adjustments applied on top of the line item
                                  subtotal, such as discounts and allocation
                                  offsets.
                            required:
                              - id
                              - idempotencyKey
                              - customerId
                              - productId
                              - resourceId
                              - licenseId
                              - lineItemGroupId
                              - name
                              - scope
                              - startDate
                              - endDate
                              - totalUsage
                              - usageFormat
                              - subtotalAmount
                              - adjustmentAmount
                              - totalAmount
                              - discountAmount
                              - metadata
                              - subLineItems
                              - adjustments
                            additionalProperties: false
                          description: The line items contained in this group.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - planId
                        - planInstanceId
                        - name
                        - startDate
                        - endDate
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - lineItems
                      additionalProperties: false
                    description: >-
                      Line item groups on the invoice. Each group gathers the
                      line items generated from one plan instance (or created as
                      a group on one-off invoices).
                  standaloneLineItems:
                    type: array
                    items:
                      type: object
                      description: >-
                        One amount on an invoice, such as a plan charge, the
                        contract minimum, a tax gross-up (the withheld ISS, the
                        municipal service tax, added on top), a one-off amount
                        or an additional charge.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the line item within
                            the invoice. Supplied by the caller for one-off line
                            items; generated by the billing engine otherwise.
                          example: entrega-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this line item bills. On split or
                            consolidated invoices it may be a subsidiary of the
                            invoice's customer.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this line item
                            belongs to.
                        itemId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the catalog item this line
                            bills. Null for line items not backed by a catalog
                            item.
                        resourceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the metered resource behind
                            a usage_based line item. Null for line items not
                            driven by resource usage.
                        licenseId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the license behind a
                            license_based line item. Null for line items not
                            driven by a license count.
                        lineItemGroupId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the line item group
                            containing this line item. Null for standalone line
                            items.
                        name:
                          type: string
                          description: >-
                            Display name of the line item as it appears on the
                            invoice.
                          example: Entregas
                        scope:
                          type: string
                          enum:
                            - credit_purchase
                            - contract_minimum_commitment
                            - minimum_commitment
                            - fixed
                            - usage_based
                            - license_based
                            - custom
                            - additional_charge
                            - one_off
                            - tax_gross_up
                          description: >-
                            What the line item charges for: usage_based (metered
                            resource consumption), license_based (a license's
                            reported count billed in full), fixed (recurring
                            fixed charge of a plan), custom (custom plan charge,
                            priced by a calculator that Aira writes for you),
                            minimum_commitment (plan-level minimum top-up),
                            contract_minimum_commitment (contract-level minimum
                            top-up), credit_purchase (credit pool top-up),
                            additional_charge (extra charge added manually),
                            one_off (line item of a one-off invoice), or
                            tax_gross_up (tax gross-up charge).
                        startDate:
                          type: string
                          format: date
                          description: Start of the period covered by this line item.
                        endDate:
                          type: string
                          format: date
                          description: End of the period covered by this line item.
                        totalUsage:
                          type: number
                          nullable: true
                          description: >-
                            Total usage billed by the line item, in the unit
                            given by usageFormat. Null for line items without a
                            single usage (e.g. fixed charges without a quantity,
                            and custom line items whose calculator returns no
                            total).
                        usageFormat:
                          type: string
                          enum:
                            - unit
                            - currency
                            - null
                          nullable: true
                          description: >-
                            How to read totalUsage, and the usage of each
                            sub-line item that has no usageFormat of its own:
                            unit means a count of resource units or a fixed
                            charge quantity; currency means a monetary base
                            amount in cents. Null when the line item has no
                            single usage, as a custom line item whose sub-line
                            items bill different kinds of volume, each with its
                            own usageFormat.
                        subtotalAmount:
                          type: number
                          description: >-
                            Line item amount before adjustments, in cents (sum
                            of its sub-line item amounts).
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to this line
                            item (discounts and allocation offsets), in cents.
                            Negative when adjustments reduce the amount owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final line item amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        metadata:
                          description: >-
                            Pricing metadata for the line item, where the shape
                            is keyed by type. Always present, but null for line
                            items without pricing metadata: credit_purchase,
                            additional_charge, one_off, and tax_gross_up. It is
                            populated for fixed (the billing timing),
                            usage_based, license_based, minimum_commitment,
                            contract_minimum_commitment, and custom (the
                            definition and the calculation memory) line items.
                          anyOf:
                            - title: Fixed
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed
                                  description: >-
                                    Discriminator: metadata for a fixed line
                                    item.
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    Whether the fee was billed in advance of its
                                    service period or after it.
                              required:
                                - type
                                - billingTiming
                            - title: Usage-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - usage_based
                                  description: >-
                                    Discriminator: metadata for a usage_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the metered resource accrues over the
                                    billing period: in_full bills the full usage
                                    of the period; proration weighs usage by the
                                    fraction of the period each amount was held.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how
                                    usage was divided across tiers. unique_tier
                                    prices all usage at the single tier that
                                    contains the total; progressive prices each
                                    tier's band separately. Absent for
                                    non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item. Charges priced
                                    before pricing models existed are reported
                                    as advanced.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: License-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_based
                                  description: >-
                                    Discriminator: metadata for a license_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the license count accrues over the
                                    billing period. Always in_full: the latest
                                    reported count is billed in full.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how the
                                    license count was divided across tiers.
                                    unique_tier prices the whole count at the
                                    single tier that contains the total;
                                    progressive prices each tier's band
                                    separately. Absent for non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: Contract minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - contract_minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a
                                    contract_minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the whole
                                    contract in the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the contract's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a plan-level
                                    minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the plan in
                                    the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the plan's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Custom
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - custom
                                  description: >-
                                    Discriminator: metadata for a custom line
                                    item.
                                definitionKey:
                                  type: string
                                  description: >-
                                    The key of the custom charge definition
                                    whose calculator priced the charge,
                                    following the custom:charge:<slug>:<name>
                                    convention.
                                  examples:
                                    - custom:charge:padaria-central:entregas
                                memory:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The full calculation memory that the
                                    calculator returned, such as every tier it
                                    evaluated and the one it billed. Its shape
                                    belongs to the definition.
                              required:
                                - type
                                - definitionKey
                                - memory
                            - title: No metadata
                              type: 'null'
                        subLineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing a sub-line item: one priced
                              row of a line item's breakdown. The row type
                              dictates the shape of metadata.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the sub-line item in
                                  our system.
                              type:
                                type: string
                                enum:
                                  - fixed_price
                                  - minimum_amount
                                  - price_tier_flat
                                  - price_tier_unit
                                  - price_tier_package
                                  - price_tier_percentage
                                  - proration
                                  - license_proration
                                  - license_proration_tier
                                  - unit_price
                                  - included_quantity
                                  - package_price
                                  - percentage
                                  - overage
                                  - original_amount
                                  - fixed_unit_price
                                  - custom
                                description: >-
                                  The kind of priced row: fixed_price and
                                  minimum_amount are companions of usage-based
                                  charges; unit_price, package_price,
                                  percentage, and included_quantity break down
                                  single-model pricing; price_tier_* rows break
                                  down tiered pricing; overage bills usage
                                  beyond the last tier; proration bills per
                                  prorated interval; license_proration bills
                                  license deltas (removals are negative);
                                  original_amount surfaces the pre-adjustment
                                  amount of an adjusted line; fixed_unit_price
                                  breaks down a fixed charge billed as a
                                  quantity times a unit amount; custom bills one
                                  component of a custom plan charge.
                              name:
                                type: string
                                description: >-
                                  Display name of the sub-line item as it
                                  appears on the invoice breakdown.
                                example: '[A partir de 1] Unidades'
                              description:
                                type: string
                                nullable: true
                                description: >-
                                  Optional descriptive text for the row. Null
                                  when absent.
                                example: 120 x 2,50
                              usage:
                                type: number
                                nullable: true
                                description: >-
                                  The usage billed by this row: a count of
                                  resource units (the quantity for a
                                  fixed_unit_price row), or a monetary base
                                  amount in cents for percentage-priced rows
                                  (see the row's usageFormat, or the line item
                                  usageFormat when the row has none). Null for
                                  rows without usage (e.g. companions).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read the usage of this row when the row
                                  has a format of its own, as the custom rows of
                                  a custom line item do: unit means a count,
                                  currency means an amount in cents. Null when
                                  the row reads its usage in the line item
                                  usageFormat.
                              amount:
                                type: number
                                description: >-
                                  Amount billed by this row, in cents. The sum
                                  of a line item's sub-line amounts equals its
                                  subtotalAmount.
                              metadata:
                                description: >-
                                  Pricing details of the row, keyed by the row
                                  type (and pricingType for overage rows).
                                anyOf:
                                  - type: object
                                    description: >-
                                      Fixed-price companion row: the charge's
                                      configured fixed amount, billed alongside
                                      the usage rows. Only rendered when
                                      configured greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_price
                                        description: >-
                                          Discriminator: fixed-price companion
                                          row.
                                      fixedPrice:
                                        type: number
                                        description: >-
                                          The fixed amount configured on the
                                          charge, in cents.
                                    required:
                                      - type
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Minimum-amount companion row: tops the
                                      charge up to its configured minimum when
                                      usage alone stays below it. Only rendered
                                      when the top-up is greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_amount
                                        description: >-
                                          Discriminator: minimum-amount companion
                                          row.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount configured on the
                                          charge, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up billed by this row to reach
                                          the configured minimum, in cents.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - type: object
                                    description: >-
                                      Flat-priced tier row: usage falling in
                                      this tier band is billed at a flat amount,
                                      regardless of the exact quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_flat
                                        description: 'Discriminator: flat-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      fixedPrice:
                                        type: string
                                        description: >-
                                          The flat amount billed for the tier, as
                                          a decimal currency-unit string.
                                        examples:
                                          - '150.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Per-unit priced tier row: units attributed
                                      to this tier band are billed at the tier's
                                      unit price.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_unit
                                        description: 'Discriminator: per-unit priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      price:
                                        type: string
                                        description: >-
                                          Price per unit within the tier, as a
                                          decimal currency-unit string.
                                        examples:
                                          - '0.25'
                                      fixedPrice:
                                        type: string
                                        nullable: true
                                        description: >-
                                          Optional flat fee billed on top when the
                                          tier applies, as a decimal currency-unit
                                          string. Null when the tier has no flat
                                          fee.
                                        examples:
                                          - '10.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - price
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Package-priced tier row: units attributed
                                      to this tier band are billed per started
                                      package of packageSize units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_package
                                        description: 'Discriminator: package-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string.
                                        examples:
                                          - '45.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - packageSize
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage-priced tier row: the monetary
                                      base amount attributed to this tier band
                                      is billed at a percentage.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_percentage
                                        description: >-
                                          Discriminator: percentage-priced tier
                                          row.
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                          Null for an unbounded final tier.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          within the tier, as a decimal string
                                          from 0 to 100 (up to 6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - percentage
                                  - type: object
                                    description: >-
                                      Proration interval row: for charges on
                                      prorated resources, each interval bills
                                      the usage held during it, priced as if
                                      held for the whole cycle and scaled by the
                                      interval's share of the cycle.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - proration
                                        description: 'Discriminator: proration interval row.'
                                      intervalSize:
                                        type: number
                                        description: >-
                                          Length of the interval, in days of the
                                          billing cycle.
                                      amount:
                                        type: string
                                        description: >-
                                          The prorated amount of the interval, as
                                          a decimal currency-unit string: the
                                          interval usage priced as if held for the
                                          whole cycle, scaled by intervalSize over
                                          the cycle length.
                                        examples:
                                          - '29.0322580645'
                                      usage:
                                        type: number
                                        description: The usage held during the interval.
                                      intervalStart:
                                        type: string
                                        format: date
                                        description: First day of the interval.
                                      intervalEnd:
                                        type: string
                                        format: date
                                        description: Last day of the interval.
                                    required:
                                      - type
                                      - intervalSize
                                      - amount
                                      - usage
                                      - intervalStart
                                      - intervalEnd
                                  - type: object
                                    description: >-
                                      License proration delta row: for per_unit
                                      license charges billing under the
                                      proration model, the cycle-start row bills
                                      the starting licenses beyond the included
                                      quantity at their full-cycle price, and
                                      each change row bills the change in those
                                      licenses prorated over the days remaining
                                      in the cycle. A change that stays inside
                                      the included quantity has no row. Tiered
                                      charges use license_proration_tier
                                      instead. quantityDelta and the row's
                                      amount are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration
                                        description: >-
                                          Discriminator: license proration delta
                                          row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on the cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the licenses beyond the
                                          included quantity (the starting licenses
                                          beyond it on the cycle-start row).
                                          Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity after this
                                          change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on
                                          the cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|. On a cycle-start row
                                          that bills no license, the unit price of
                                          the charge.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                  - type: object
                                    description: >-
                                      Tiered license proration delta row: one
                                      price band of a license charge billing
                                      under the proration model with
                                      tiered_per_unit pricing. The cycle-start
                                      rows bill each band's opening occupancy at
                                      its full-cycle unit price, and each change
                                      row bills that band's occupancy delta
                                      prorated over the days remaining in the
                                      cycle. quantityDelta and the row's amount
                                      are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration_tier
                                        description: >-
                                          Discriminator: tiered license proration
                                          delta row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on a cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the units this band
                                          holds (the band's opening occupancy on a
                                          cycle-start row). Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity across
                                          every band after this change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on a
                                          cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                      planChargeTierId:
                                        type: string
                                        description: >-
                                          The unique identifier of the plan charge
                                          tier this row moved through.
                                        examples:
                                          - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                      from:
                                        type: number
                                        description: >-
                                          Inclusive lower bound of the band, in
                                          licenses.
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Inclusive upper bound of the band, in
                                          licenses. Null on the last, open-ended
                                          band.
                                      unitPrice:
                                        type: string
                                        description: >-
                                          The band's full-cycle price per unit, as
                                          a decimal currency-unit string.
                                          proratedUnitRate is this scaled by
                                          remainingDays over cycleDays.
                                        examples:
                                          - '25.00'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                      - planChargeTierId
                                      - from
                                      - to
                                      - unitPrice
                                  - type: object
                                    description: >-
                                      Unit-price row: billable units multiplied
                                      by a single price per unit. The row's
                                      usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - unit_price
                                        description: 'Discriminator: unit-price row.'
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.25'
                                    required:
                                      - type
                                      - price
                                  - type: object
                                    description: >-
                                      Included-quantity row: the free allotment
                                      of the charge. The row's usage holds the
                                      units consumed within the allotment and
                                      its amount is always zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - included_quantity
                                        description: 'Discriminator: included-quantity row.'
                                      includedQuantity:
                                        type: number
                                        description: >-
                                          Number of resource units included at no
                                          charge before billing starts.
                                    required:
                                      - type
                                      - includedQuantity
                                  - type: object
                                    description: >-
                                      Package-price row: billable units charged
                                      per started package of packageSize units.
                                      The row's usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - package_price
                                        description: 'Discriminator: package-price row.'
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '45.00'
                                      packagesBilled:
                                        type: number
                                        description: >-
                                          Number of packages billed: the billable
                                          units divided by packageSize, rounded
                                          up.
                                    required:
                                      - type
                                      - packageSize
                                      - price
                                      - packagesBilled
                                  - type: object
                                    description: >-
                                      Percentage row: a percentage applied over
                                      a monetary base amount. The row's usage
                                      holds the base amount, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - percentage
                                        description: 'Discriminator: percentage row.'
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount,
                                          as a decimal string from 0 to 100 (up to
                                          6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - percentage
                                  - type: object
                                    description: >-
                                      Per-unit overage row: units beyond the
                                      last tier boundary, billed at the
                                      configured excess unit price. The row's
                                      usage holds the units over the boundary.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - per_unit
                                        description: 'Discriminator: overage billed per unit.'
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          resource units.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per excess unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage overage row: the monetary base
                                      amount beyond the last tier boundary,
                                      billed at the configured excess
                                      percentage. The row's usage holds the base
                                      amount over the boundary, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - percentage
                                        description: >-
                                          Discriminator: overage billed as a
                                          percentage.
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          cents of the monetary base amount.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the excess base
                                          amount, as a decimal string from 0 to
                                          100 (up to 6 decimal places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - percentage
                                  - type: object
                                    description: >-
                                      Original-amount row: surfaces the line
                                      item's pre-adjustment amount when the line
                                      has adjustments (e.g. a discount) but no
                                      price-component rows of its own. The row's
                                      amount equals the line item's
                                      subtotalAmount.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - original_amount
                                        description: 'Discriminator: original-amount row.'
                                    required:
                                      - type
                                  - type: object
                                    description: >-
                                      Fixed unit price row: the quantity of a
                                      fixed charge multiplied by its unit
                                      amount. The row's usage holds the
                                      quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_unit_price
                                        description: 'Discriminator: fixed unit price row.'
                                      amount:
                                        type: integer
                                        minimum: 0
                                        description: Amount of one unit, in cents.
                                    required:
                                      - type
                                      - amount
                                  - type: object
                                    description: >-
                                      Custom row: one component of a custom plan
                                      charge, as its calculator billed it. The
                                      row's name, description, usage,
                                      usageFormat and amount hold the rest of
                                      the component.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: 'Discriminator: custom row.'
                                      key:
                                        type: string
                                        description: >-
                                          The key of the component in the sub-line
                                          schema of the charge's custom charge
                                          definition, such as documents_overage.
                                        examples:
                                          - documents_overage
                                    required:
                                      - type
                                      - key
                            required:
                              - id
                              - type
                              - name
                              - description
                              - usage
                              - usageFormat
                              - amount
                              - metadata
                            additionalProperties: false
                          description: >-
                            Breakdown of the line item amount into priced rows
                            (included quantities, unit/package/tier prices,
                            prorations, companions). Empty for line items
                            without a breakdown.
                        adjustments:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing an adjustment applied on top
                              of a line item subtotal, such as a discount or an
                              allocation offset.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the adjustment in our
                                  system.
                              name:
                                type: string
                                description: >-
                                  Display name of the adjustment as it appears
                                  on the invoice.
                                example: Desconto de boas-vindas
                              type:
                                type: string
                                enum:
                                  - monetary_discount
                                  - allocation_offset
                                description: >-
                                  The kind of adjustment: monetary_discount (a
                                  discount applied to the line item) or
                                  allocation_offset (the share of the amount
                                  moved to another payment account's invoice
                                  under a split allocation strategy).
                              amount:
                                type: number
                                description: >-
                                  Amount of the adjustment, in cents. Negative
                                  when the adjustment reduces the line item
                                  total.
                            required:
                              - id
                              - name
                              - type
                              - amount
                            additionalProperties: false
                          description: >-
                            Adjustments applied on top of the line item
                            subtotal, such as discounts and allocation offsets.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - resourceId
                        - licenseId
                        - lineItemGroupId
                        - name
                        - scope
                        - startDate
                        - endDate
                        - totalUsage
                        - usageFormat
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - metadata
                        - subLineItems
                        - adjustments
                      additionalProperties: false
                    description: >-
                      Line items that do not belong to any line item group (e.g.
                      contract-level minimum commitments, additional charges,
                      and ungrouped one-off items).
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of invoices, keyed by the
                      key of each custom field. The object is empty when the
                      invoice holds no value. A user edits them in the billing
                      app, and `PUT /v1/invoices/{id}/custom-fields` replaces
                      the whole set, in any status of the invoice.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  sentAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When Aira last sent the invoice by e-mail to its invoice
                      recipients, in an invoice delivery. Null when Aira has not
                      sent it.
                  replaceReason:
                    type: string
                    enum:
                      - contract_allocation_changed
                      - manually_reopened
                      - null
                    nullable: true
                    description: >-
                      Why one invoice of the same invoice slot replaced another,
                      on both invoices of the replacement: manually_reopened for
                      a reopening, and contract_allocation_changed when a change
                      to the contract allocation canceled the invoice and a
                      later billing of its billing act replaced it. Null when
                      the invoice replaces no invoice and no invoice replaces
                      it.
                  replacesInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the canceled invoice that this
                      invoice replaces in its invoice slot. Null when the
                      invoice replaces no invoice.
                  replacedByInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the invoice that replaces this
                      canceled invoice in its invoice slot. Null when no invoice
                      replaces it.
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - paymentAccountId
                  - contractId
                  - contractInvoiceSequence
                  - issuingAccount
                  - billingAccount
                  - invoiceAllocationStrategy
                  - lastCalculatedAt
                  - invoiceNumber
                  - invoiceDate
                  - memo
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - status
                  - isLocked
                  - failureReason
                  - source
                  - autoIssue
                  - amountDue
                  - dueDate
                  - lineItemGroups
                  - standaloneLineItems
                  - customFields
                  - sentAt
                  - replaceReason
                  - replacesInvoiceId
                  - replacedByInvoiceId
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `invoice_issue_blocked`: Aira is still generating the invoice
            artifacts of the invoice.

            - `invoice_cannot_be_updated`: the invoice is open or canceled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_issue_blocked
                      - invoice_cannot_be_updated
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
                invoice_issue_blocked:
                  value:
                    message: cannot issue invoices while a blocker is in progress
                    code: invoice_issue_blocked
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `invoiceId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
  /v1/invoices/{invoiceId}/pay:
    post:
      summary: Mark invoice as paid
      tags:
        - Invoices
      description: >-
        Marks an invoice as paid, for a payment made outside Aira, as the
        billing app does. An issued, synced, pending or overdue invoice becomes
        paid, and Aira cancels its active payment. A paid invoice comes back as
        it is, so a retry is safe.


        Requires the role `invoices:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice to mark as paid.
      x-public-api: true
      x-errors:
        - status: 400
          code: payment_integration_not_enabled
          when: the payments module is off
        - status: 400
          code: invoice_cannot_be_updated
          when: >-
            the invoice is open, in review, failed or canceled, or it has more
            than one payment that is created or pending
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            The document that bills one payment account of a customer: from a
            billing act of a contract, as a one-off invoice or from an import.
            It locks when it is issued or canceled, and Aira never recalculates
            a locked invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the invoice in our system.
                  idempotencyKey:
                    type: string
                    description: >-
                      A unique key that identifies the invoice for idempotent
                      creation. Supplied by the caller for one-off invoices;
                      generated by the billing engine for contract invoices.
                    example: padaria-central-2026-11
                  customerId:
                    type: string
                    format: uuid
                    description: The unique identifier of the customer this invoice bills.
                  paymentAccountId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the customer payment account used
                      as the billing account for this invoice.
                  contractId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the contract that generated this
                      invoice. Null for invoices not generated from a contract
                      (e.g. one-off and imported invoices).
                  contractInvoiceSequence:
                    type: integer
                    minimum: 1
                    nullable: true
                    description: >-
                      The number of the invoice within its contract, in the
                      order that Aira created the contract's invoices: 1 for the
                      first, 2 for the next, and so on. Every invoice gets its
                      own number, including each invoice of a split across
                      payment accounts and the replacement of a reopened
                      invoice, and a number never changes and is never reused.
                      Null for invoices without a contract.
                  issuingAccount:
                    type: object
                    description: >-
                      Snapshot of the legal entity issuing the invoice (the
                      seller), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  billingAccount:
                    type: object
                    description: >-
                      Snapshot of the billed party (the legal entity behind the
                      customer payment account), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How the originating contract distributes charges across
                      payment accounts: single bills a single payment account;
                      percent_split divides the total between payment accounts
                      by configured percentages; subsidiary_usage_split divides
                      it according to each subsidiary's usage.
                  lastCalculatedAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When the invoice amounts were last computed by the billing
                      engine. Null when the invoice has never been calculated.
                  invoiceNumber:
                    type: string
                    description: >-
                      Human-readable invoice number, built from the customer's
                      invoice prefix plus a sequential counter.
                    example: ACMEI-0042
                  invoiceDate:
                    type: string
                    format: date
                    description: >-
                      The date of the invoice. On a contract invoice it is the
                      date of its billing act: the first day of the first
                      billing cycle that the contract invoices for an activation
                      invoice, and the last day of the billing cycle for a
                      closing invoice. Its line items state the periods that it
                      bills. On a one-off or imported invoice it is the date
                      given when the invoice was created.
                  memo:
                    type: string
                    nullable: true
                    description: >-
                      Free-form memo attached to the invoice. On contract
                      invoices, it reads "Período <start> a <end>" with the
                      period of the line item that bills most often, such as the
                      month when a monthly fee is billed with an annual fee.
                      When two line items bill equally often, it uses the
                      earlier period. Null when absent.
                    example: Período 01/11/2026 a 30/11/2026
                  subtotalAmount:
                    type: number
                    description: >-
                      Sum of the line item subtotals before adjustments, in
                      cents.
                  adjustmentAmount:
                    type: number
                    description: >-
                      Net amount of all adjustments applied to the invoice line
                      items (discounts and allocation offsets), in cents.
                      Negative when adjustments reduce the amount owed.
                  totalAmount:
                    type: number
                    description: >-
                      Final invoice amount, in cents: subtotalAmount +
                      adjustmentAmount.
                  discountAmount:
                    type: number
                    description: >-
                      The discount portion of adjustmentAmount, in cents (sum of
                      monetary discount adjustments only). Negative when
                      discounts were applied.
                  status:
                    type: string
                    enum:
                      - open
                      - in_review
                      - issued
                      - synced
                      - pending
                      - paid
                      - overdue
                      - canceled
                      - failed
                    description: >-
                      Current status of the invoice lifecycle: open
                      (accumulating charges, editable), in_review (flagged for
                      manual review before issuing), issued (finalized and
                      issued to the customer), synced (registered in the
                      external ERP/payment provider), pending (a payment was
                      initiated and awaits settlement), paid, overdue (unpaid
                      past the due date), canceled, or failed (an issue/sync
                      attempt failed and needs attention).
                  isLocked:
                    type: boolean
                    description: >-
                      Whether the invoice contents are locked against edits.
                      Aira locks an invoice when it issues or cancels it,
                      together with the other invoices of its allocation group,
                      except when it cancels the invoice because its payment
                      account left the allocation of the contract, which locks
                      only that invoice. A locked invoice stays locked, also
                      when its status later moves to failed.
                  failureReason:
                    type: string
                    nullable: true
                    description: >-
                      Reason for the most recent failure on the invoice (e.g. an
                      ERP sync or payment issue). Null when the invoice has no
                      active failure.
                    example: contract_sync_not_found
                  source:
                    type: string
                    enum:
                      - contract
                      - one_off
                      - import
                    description: >-
                      How the invoice originated: contract (generated by a
                      contract billing cycle), one_off (created manually or
                      through the API), or import (ingested from an external
                      system).
                  autoIssue:
                    type: boolean
                    description: >-
                      Whether the invoice is issued automatically when its
                      billing cycle closes, without manual review.
                  amountDue:
                    type: number
                    nullable: true
                    description: >-
                      Outstanding amount due on the invoice, in cents. Null when
                      not tracked.
                  dueDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Payment due date of the invoice. Null when no due date is
                      set (e.g. before the invoice is issued).
                  lineItemGroups:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a line item group: a container that
                        gathers the line items generated from one plan instance
                        (or created as a group on one-off invoices). Monetary
                        amounts are integers in cents.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item group in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the group within the
                            invoice. Supplied by the caller for one-off groups;
                            generated by the billing engine otherwise.
                          example: servicos-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this group bills.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this group
                            belongs to.
                        planId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan whose instance
                            generated this group. Null for groups not generated
                            from a plan (e.g. on one-off invoices).
                        planInstanceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan instance that
                            generated this group. Null for groups not generated
                            from a plan instance.
                        name:
                          type: string
                          description: >-
                            Display name of the group as it appears on the
                            invoice, typically the plan or product name.
                          example: Plano Entregas
                        startDate:
                          type: string
                          format: date
                          description: >-
                            Start of the period that the group shows. On
                            contract invoices, it is the period of the group's
                            line item that bills most often, such as the month
                            when a monthly fee is billed with an annual fee.
                            When two line items bill equally often, it is the
                            earlier period.
                        endDate:
                          type: string
                          format: date
                          description: >-
                            End of the period that the group shows, which
                            `startDate` describes.
                        subtotalAmount:
                          type: number
                          description: >-
                            Sum of the group's line item subtotals before
                            adjustments, in cents.
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to the group's
                            line items (discounts and allocation offsets), in
                            cents. Negative when adjustments reduce the amount
                            owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final group amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        lineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              One amount on an invoice, such as a plan charge,
                              the contract minimum, a tax gross-up (the withheld
                              ISS, the municipal service tax, added on top), a
                              one-off amount or an additional charge.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the line item in our
                                  system.
                              idempotencyKey:
                                type: string
                                description: >-
                                  A unique key that identifies the line item
                                  within the invoice. Supplied by the caller for
                                  one-off line items; generated by the billing
                                  engine otherwise.
                                example: entrega-novembro
                              customerId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the customer whose
                                  consumption this line item bills. On split or
                                  consolidated invoices it may be a subsidiary
                                  of the invoice's customer.
                              productId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the product this line
                                  item belongs to.
                              itemId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the catalog item this
                                  line bills. Null for line items not backed by
                                  a catalog item.
                              resourceId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the metered resource
                                  behind a usage_based line item. Null for line
                                  items not driven by resource usage.
                              licenseId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the license behind a
                                  license_based line item. Null for line items
                                  not driven by a license count.
                              lineItemGroupId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the line item group
                                  containing this line item. Null for standalone
                                  line items.
                              name:
                                type: string
                                description: >-
                                  Display name of the line item as it appears on
                                  the invoice.
                                example: Entregas
                              scope:
                                type: string
                                enum:
                                  - credit_purchase
                                  - contract_minimum_commitment
                                  - minimum_commitment
                                  - fixed
                                  - usage_based
                                  - license_based
                                  - custom
                                  - additional_charge
                                  - one_off
                                  - tax_gross_up
                                description: >-
                                  What the line item charges for: usage_based
                                  (metered resource consumption), license_based
                                  (a license's reported count billed in full),
                                  fixed (recurring fixed charge of a plan),
                                  custom (custom plan charge, priced by a
                                  calculator that Aira writes for you),
                                  minimum_commitment (plan-level minimum
                                  top-up), contract_minimum_commitment
                                  (contract-level minimum top-up),
                                  credit_purchase (credit pool top-up),
                                  additional_charge (extra charge added
                                  manually), one_off (line item of a one-off
                                  invoice), or tax_gross_up (tax gross-up
                                  charge).
                              startDate:
                                type: string
                                format: date
                                description: Start of the period covered by this line item.
                              endDate:
                                type: string
                                format: date
                                description: End of the period covered by this line item.
                              totalUsage:
                                type: number
                                nullable: true
                                description: >-
                                  Total usage billed by the line item, in the
                                  unit given by usageFormat. Null for line items
                                  without a single usage (e.g. fixed charges
                                  without a quantity, and custom line items
                                  whose calculator returns no total).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read totalUsage, and the usage of each
                                  sub-line item that has no usageFormat of its
                                  own: unit means a count of resource units or a
                                  fixed charge quantity; currency means a
                                  monetary base amount in cents. Null when the
                                  line item has no single usage, as a custom
                                  line item whose sub-line items bill different
                                  kinds of volume, each with its own
                                  usageFormat.
                              subtotalAmount:
                                type: number
                                description: >-
                                  Line item amount before adjustments, in cents
                                  (sum of its sub-line item amounts).
                              adjustmentAmount:
                                type: number
                                description: >-
                                  Net amount of the adjustments applied to this
                                  line item (discounts and allocation offsets),
                                  in cents. Negative when adjustments reduce the
                                  amount owed.
                              totalAmount:
                                type: number
                                description: >-
                                  Final line item amount, in cents:
                                  subtotalAmount + adjustmentAmount.
                              discountAmount:
                                type: number
                                description: >-
                                  The discount portion of adjustmentAmount, in
                                  cents (sum of monetary discount adjustments
                                  only). Negative when discounts were applied.
                              metadata:
                                description: >-
                                  Pricing metadata for the line item, where the
                                  shape is keyed by type. Always present, but
                                  null for line items without pricing metadata:
                                  credit_purchase, additional_charge, one_off,
                                  and tax_gross_up. It is populated for fixed
                                  (the billing timing), usage_based,
                                  license_based, minimum_commitment,
                                  contract_minimum_commitment, and custom (the
                                  definition and the calculation memory) line
                                  items.
                                anyOf:
                                  - title: Fixed
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed
                                        description: >-
                                          Discriminator: metadata for a fixed line
                                          item.
                                      billingTiming:
                                        type: string
                                        enum:
                                          - in_advance
                                          - in_arrears
                                        description: >-
                                          Whether the fee was billed in advance of
                                          its service period or after it.
                                    required:
                                      - type
                                      - billingTiming
                                  - title: Usage-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - usage_based
                                        description: >-
                                          Discriminator: metadata for a
                                          usage_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the metered resource accrues over
                                          the billing period: in_full bills the
                                          full usage of the period; proration
                                          weighs usage by the fraction of the
                                          period each amount was held.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          usage was divided across tiers.
                                          unique_tier prices all usage at the
                                          single tier that contains the total;
                                          progressive prices each tier's band
                                          separately. Absent for non-tiered
                                          models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item. Charges
                                          priced before pricing models existed are
                                          reported as advanced.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: License-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_based
                                        description: >-
                                          Discriminator: metadata for a
                                          license_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the license count accrues over the
                                          billing period. Always in_full: the
                                          latest reported count is billed in full.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          the license count was divided across
                                          tiers. unique_tier prices the whole
                                          count at the single tier that contains
                                          the total; progressive prices each
                                          tier's band separately. Absent for
                                          non-tiered models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: Contract minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - contract_minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a
                                          contract_minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          whole contract in the billing period, in
                                          cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the contract's consumption amounted
                                          to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a plan-level
                                          minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          plan in the billing period, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the plan's consumption amounted to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Custom
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: >-
                                          Discriminator: metadata for a custom
                                          line item.
                                      definitionKey:
                                        type: string
                                        description: >-
                                          The key of the custom charge definition
                                          whose calculator priced the charge,
                                          following the
                                          custom:charge:<slug>:<name> convention.
                                        examples:
                                          - custom:charge:padaria-central:entregas
                                      memory:
                                        type: object
                                        additionalProperties: true
                                        description: >-
                                          The full calculation memory that the
                                          calculator returned, such as every tier
                                          it evaluated and the one it billed. Its
                                          shape belongs to the definition.
                                    required:
                                      - type
                                      - definitionKey
                                      - memory
                                  - title: No metadata
                                    type: 'null'
                              subLineItems:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing a sub-line item: one
                                    priced row of a line item's breakdown. The
                                    row type dictates the shape of metadata.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the sub-line
                                        item in our system.
                                    type:
                                      type: string
                                      enum:
                                        - fixed_price
                                        - minimum_amount
                                        - price_tier_flat
                                        - price_tier_unit
                                        - price_tier_package
                                        - price_tier_percentage
                                        - proration
                                        - license_proration
                                        - license_proration_tier
                                        - unit_price
                                        - included_quantity
                                        - package_price
                                        - percentage
                                        - overage
                                        - original_amount
                                        - fixed_unit_price
                                        - custom
                                      description: >-
                                        The kind of priced row: fixed_price and
                                        minimum_amount are companions of
                                        usage-based charges; unit_price,
                                        package_price, percentage, and
                                        included_quantity break down
                                        single-model pricing; price_tier_* rows
                                        break down tiered pricing; overage bills
                                        usage beyond the last tier; proration
                                        bills per prorated interval;
                                        license_proration bills license deltas
                                        (removals are negative); original_amount
                                        surfaces the pre-adjustment amount of an
                                        adjusted line; fixed_unit_price breaks
                                        down a fixed charge billed as a quantity
                                        times a unit amount; custom bills one
                                        component of a custom plan charge.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the sub-line item as it
                                        appears on the invoice breakdown.
                                      example: '[A partir de 1] Unidades'
                                    description:
                                      type: string
                                      nullable: true
                                      description: >-
                                        Optional descriptive text for the row.
                                        Null when absent.
                                      example: 120 x 2,50
                                    usage:
                                      type: number
                                      nullable: true
                                      description: >-
                                        The usage billed by this row: a count of
                                        resource units (the quantity for a
                                        fixed_unit_price row), or a monetary
                                        base amount in cents for
                                        percentage-priced rows (see the row's
                                        usageFormat, or the line item
                                        usageFormat when the row has none). Null
                                        for rows without usage (e.g.
                                        companions).
                                    usageFormat:
                                      type: string
                                      enum:
                                        - unit
                                        - currency
                                        - null
                                      nullable: true
                                      description: >-
                                        How to read the usage of this row when
                                        the row has a format of its own, as the
                                        custom rows of a custom line item do:
                                        unit means a count, currency means an
                                        amount in cents. Null when the row reads
                                        its usage in the line item usageFormat.
                                    amount:
                                      type: number
                                      description: >-
                                        Amount billed by this row, in cents. The
                                        sum of a line item's sub-line amounts
                                        equals its subtotalAmount.
                                    metadata:
                                      description: >-
                                        Pricing details of the row, keyed by the
                                        row type (and pricingType for overage
                                        rows).
                                      anyOf:
                                        - type: object
                                          description: >-
                                            Fixed-price companion row: the charge's
                                            configured fixed amount, billed
                                            alongside the usage rows. Only rendered
                                            when configured greater than zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_price
                                              description: >-
                                                Discriminator: fixed-price companion
                                                row.
                                            fixedPrice:
                                              type: number
                                              description: >-
                                                The fixed amount configured on the
                                                charge, in cents.
                                          required:
                                            - type
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Minimum-amount companion row: tops the
                                            charge up to its configured minimum when
                                            usage alone stays below it. Only
                                            rendered when the top-up is greater than
                                            zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - minimum_amount
                                              description: >-
                                                Discriminator: minimum-amount companion
                                                row.
                                            minimumAmount:
                                              type: number
                                              description: >-
                                                The minimum amount configured on the
                                                charge, in cents.
                                            minimumAmountApplied:
                                              type: number
                                              description: >-
                                                The top-up billed by this row to reach
                                                the configured minimum, in cents.
                                          required:
                                            - type
                                            - minimumAmount
                                            - minimumAmountApplied
                                        - type: object
                                          description: >-
                                            Flat-priced tier row: usage falling in
                                            this tier band is billed at a flat
                                            amount, regardless of the exact
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_flat
                                              description: 'Discriminator: flat-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            fixedPrice:
                                              type: string
                                              description: >-
                                                The flat amount billed for the tier, as
                                                a decimal currency-unit string.
                                              examples:
                                                - '150.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Per-unit priced tier row: units
                                            attributed to this tier band are billed
                                            at the tier's unit price.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_unit
                                              description: 'Discriminator: per-unit priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            price:
                                              type: string
                                              description: >-
                                                Price per unit within the tier, as a
                                                decimal currency-unit string.
                                              examples:
                                                - '0.25'
                                            fixedPrice:
                                              type: string
                                              nullable: true
                                              description: >-
                                                Optional flat fee billed on top when the
                                                tier applies, as a decimal currency-unit
                                                string. Null when the tier has no flat
                                                fee.
                                              examples:
                                                - '10.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - price
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Package-priced tier row: units
                                            attributed to this tier band are billed
                                            per started package of packageSize
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_package
                                              description: 'Discriminator: package-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string.
                                              examples:
                                                - '45.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - packageSize
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage-priced tier row: the monetary
                                            base amount attributed to this tier band
                                            is billed at a percentage.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_percentage
                                              description: >-
                                                Discriminator: percentage-priced tier
                                                row.
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                                Null for an unbounded final tier.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount
                                                within the tier, as a decimal string
                                                from 0 to 100 (up to 6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - percentage
                                        - type: object
                                          description: >-
                                            Proration interval row: for charges on
                                            prorated resources, each interval bills
                                            the usage held during it, priced as if
                                            held for the whole cycle and scaled by
                                            the interval's share of the cycle.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - proration
                                              description: 'Discriminator: proration interval row.'
                                            intervalSize:
                                              type: number
                                              description: >-
                                                Length of the interval, in days of the
                                                billing cycle.
                                            amount:
                                              type: string
                                              description: >-
                                                The prorated amount of the interval, as
                                                a decimal currency-unit string: the
                                                interval usage priced as if held for the
                                                whole cycle, scaled by intervalSize over
                                                the cycle length.
                                              examples:
                                                - '29.0322580645'
                                            usage:
                                              type: number
                                              description: The usage held during the interval.
                                            intervalStart:
                                              type: string
                                              format: date
                                              description: First day of the interval.
                                            intervalEnd:
                                              type: string
                                              format: date
                                              description: Last day of the interval.
                                          required:
                                            - type
                                            - intervalSize
                                            - amount
                                            - usage
                                            - intervalStart
                                            - intervalEnd
                                        - type: object
                                          description: >-
                                            License proration delta row: for
                                            per_unit license charges billing under
                                            the proration model, the cycle-start row
                                            bills the starting licenses beyond the
                                            included quantity at their full-cycle
                                            price, and each change row bills the
                                            change in those licenses prorated over
                                            the days remaining in the cycle. A
                                            change that stays inside the included
                                            quantity has no row. Tiered charges use
                                            license_proration_tier instead.
                                            quantityDelta and the row's amount are
                                            signed — removals are negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration
                                              description: >-
                                                Discriminator: license proration delta
                                                row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on the cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the licenses beyond the
                                                included quantity (the starting licenses
                                                beyond it on the cycle-start row).
                                                Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity after this
                                                change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on
                                                the cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|. On a cycle-start row
                                                that bills no license, the unit price of
                                                the charge.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                        - type: object
                                          description: >-
                                            Tiered license proration delta row: one
                                            price band of a license charge billing
                                            under the proration model with
                                            tiered_per_unit pricing. The cycle-start
                                            rows bill each band's opening occupancy
                                            at its full-cycle unit price, and each
                                            change row bills that band's occupancy
                                            delta prorated over the days remaining
                                            in the cycle. quantityDelta and the
                                            row's amount are signed — removals are
                                            negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration_tier
                                              description: >-
                                                Discriminator: tiered license proration
                                                delta row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on a cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the units this band
                                                holds (the band's opening occupancy on a
                                                cycle-start row). Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity across
                                                every band after this change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on a
                                                cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                            planChargeTierId:
                                              type: string
                                              description: >-
                                                The unique identifier of the plan charge
                                                tier this row moved through.
                                              examples:
                                                - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                            from:
                                              type: number
                                              description: >-
                                                Inclusive lower bound of the band, in
                                                licenses.
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Inclusive upper bound of the band, in
                                                licenses. Null on the last, open-ended
                                                band.
                                            unitPrice:
                                              type: string
                                              description: >-
                                                The band's full-cycle price per unit, as
                                                a decimal currency-unit string.
                                                proratedUnitRate is this scaled by
                                                remainingDays over cycleDays.
                                              examples:
                                                - '25.00'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                            - planChargeTierId
                                            - from
                                            - to
                                            - unitPrice
                                        - type: object
                                          description: >-
                                            Unit-price row: billable units
                                            multiplied by a single price per unit.
                                            The row's usage holds the billable
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - unit_price
                                              description: 'Discriminator: unit-price row.'
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.25'
                                          required:
                                            - type
                                            - price
                                        - type: object
                                          description: >-
                                            Included-quantity row: the free
                                            allotment of the charge. The row's usage
                                            holds the units consumed within the
                                            allotment and its amount is always zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - included_quantity
                                              description: 'Discriminator: included-quantity row.'
                                            includedQuantity:
                                              type: number
                                              description: >-
                                                Number of resource units included at no
                                                charge before billing starts.
                                          required:
                                            - type
                                            - includedQuantity
                                        - type: object
                                          description: >-
                                            Package-price row: billable units
                                            charged per started package of
                                            packageSize units. The row's usage holds
                                            the billable units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - package_price
                                              description: 'Discriminator: package-price row.'
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '45.00'
                                            packagesBilled:
                                              type: number
                                              description: >-
                                                Number of packages billed: the billable
                                                units divided by packageSize, rounded
                                                up.
                                          required:
                                            - type
                                            - packageSize
                                            - price
                                            - packagesBilled
                                        - type: object
                                          description: >-
                                            Percentage row: a percentage applied
                                            over a monetary base amount. The row's
                                            usage holds the base amount, in cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - percentage
                                              description: 'Discriminator: percentage row.'
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount,
                                                as a decimal string from 0 to 100 (up to
                                                6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - percentage
                                        - type: object
                                          description: >-
                                            Per-unit overage row: units beyond the
                                            last tier boundary, billed at the
                                            configured excess unit price. The row's
                                            usage holds the units over the boundary.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - per_unit
                                              description: 'Discriminator: overage billed per unit.'
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                resource units.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per excess unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.30'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage overage row: the monetary
                                            base amount beyond the last tier
                                            boundary, billed at the configured
                                            excess percentage. The row's usage holds
                                            the base amount over the boundary, in
                                            cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - percentage
                                              description: >-
                                                Discriminator: overage billed as a
                                                percentage.
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                cents of the monetary base amount.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the excess base
                                                amount, as a decimal string from 0 to
                                                100 (up to 6 decimal places).
                                              examples:
                                                - '1.5'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - percentage
                                        - type: object
                                          description: >-
                                            Original-amount row: surfaces the line
                                            item's pre-adjustment amount when the
                                            line has adjustments (e.g. a discount)
                                            but no price-component rows of its own.
                                            The row's amount equals the line item's
                                            subtotalAmount.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - original_amount
                                              description: 'Discriminator: original-amount row.'
                                          required:
                                            - type
                                        - type: object
                                          description: >-
                                            Fixed unit price row: the quantity of a
                                            fixed charge multiplied by its unit
                                            amount. The row's usage holds the
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_unit_price
                                              description: 'Discriminator: fixed unit price row.'
                                            amount:
                                              type: integer
                                              minimum: 0
                                              description: Amount of one unit, in cents.
                                          required:
                                            - type
                                            - amount
                                        - type: object
                                          description: >-
                                            Custom row: one component of a custom
                                            plan charge, as its calculator billed
                                            it. The row's name, description, usage,
                                            usageFormat and amount hold the rest of
                                            the component.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - custom
                                              description: 'Discriminator: custom row.'
                                            key:
                                              type: string
                                              description: >-
                                                The key of the component in the sub-line
                                                schema of the charge's custom charge
                                                definition, such as documents_overage.
                                              examples:
                                                - documents_overage
                                          required:
                                            - type
                                            - key
                                  required:
                                    - id
                                    - type
                                    - name
                                    - description
                                    - usage
                                    - usageFormat
                                    - amount
                                    - metadata
                                  additionalProperties: false
                                description: >-
                                  Breakdown of the line item amount into priced
                                  rows (included quantities, unit/package/tier
                                  prices, prorations, companions). Empty for
                                  line items without a breakdown.
                              adjustments:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing an adjustment applied on
                                    top of a line item subtotal, such as a
                                    discount or an allocation offset.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the adjustment
                                        in our system.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the adjustment as it
                                        appears on the invoice.
                                      example: Desconto de boas-vindas
                                    type:
                                      type: string
                                      enum:
                                        - monetary_discount
                                        - allocation_offset
                                      description: >-
                                        The kind of adjustment:
                                        monetary_discount (a discount applied to
                                        the line item) or allocation_offset (the
                                        share of the amount moved to another
                                        payment account's invoice under a split
                                        allocation strategy).
                                    amount:
                                      type: number
                                      description: >-
                                        Amount of the adjustment, in cents.
                                        Negative when the adjustment reduces the
                                        line item total.
                                  required:
                                    - id
                                    - name
                                    - type
                                    - amount
                                  additionalProperties: false
                                description: >-
                                  Adjustments applied on top of the line item
                                  subtotal, such as discounts and allocation
                                  offsets.
                            required:
                              - id
                              - idempotencyKey
                              - customerId
                              - productId
                              - resourceId
                              - licenseId
                              - lineItemGroupId
                              - name
                              - scope
                              - startDate
                              - endDate
                              - totalUsage
                              - usageFormat
                              - subtotalAmount
                              - adjustmentAmount
                              - totalAmount
                              - discountAmount
                              - metadata
                              - subLineItems
                              - adjustments
                            additionalProperties: false
                          description: The line items contained in this group.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - planId
                        - planInstanceId
                        - name
                        - startDate
                        - endDate
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - lineItems
                      additionalProperties: false
                    description: >-
                      Line item groups on the invoice. Each group gathers the
                      line items generated from one plan instance (or created as
                      a group on one-off invoices).
                  standaloneLineItems:
                    type: array
                    items:
                      type: object
                      description: >-
                        One amount on an invoice, such as a plan charge, the
                        contract minimum, a tax gross-up (the withheld ISS, the
                        municipal service tax, added on top), a one-off amount
                        or an additional charge.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the line item within
                            the invoice. Supplied by the caller for one-off line
                            items; generated by the billing engine otherwise.
                          example: entrega-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this line item bills. On split or
                            consolidated invoices it may be a subsidiary of the
                            invoice's customer.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this line item
                            belongs to.
                        itemId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the catalog item this line
                            bills. Null for line items not backed by a catalog
                            item.
                        resourceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the metered resource behind
                            a usage_based line item. Null for line items not
                            driven by resource usage.
                        licenseId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the license behind a
                            license_based line item. Null for line items not
                            driven by a license count.
                        lineItemGroupId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the line item group
                            containing this line item. Null for standalone line
                            items.
                        name:
                          type: string
                          description: >-
                            Display name of the line item as it appears on the
                            invoice.
                          example: Entregas
                        scope:
                          type: string
                          enum:
                            - credit_purchase
                            - contract_minimum_commitment
                            - minimum_commitment
                            - fixed
                            - usage_based
                            - license_based
                            - custom
                            - additional_charge
                            - one_off
                            - tax_gross_up
                          description: >-
                            What the line item charges for: usage_based (metered
                            resource consumption), license_based (a license's
                            reported count billed in full), fixed (recurring
                            fixed charge of a plan), custom (custom plan charge,
                            priced by a calculator that Aira writes for you),
                            minimum_commitment (plan-level minimum top-up),
                            contract_minimum_commitment (contract-level minimum
                            top-up), credit_purchase (credit pool top-up),
                            additional_charge (extra charge added manually),
                            one_off (line item of a one-off invoice), or
                            tax_gross_up (tax gross-up charge).
                        startDate:
                          type: string
                          format: date
                          description: Start of the period covered by this line item.
                        endDate:
                          type: string
                          format: date
                          description: End of the period covered by this line item.
                        totalUsage:
                          type: number
                          nullable: true
                          description: >-
                            Total usage billed by the line item, in the unit
                            given by usageFormat. Null for line items without a
                            single usage (e.g. fixed charges without a quantity,
                            and custom line items whose calculator returns no
                            total).
                        usageFormat:
                          type: string
                          enum:
                            - unit
                            - currency
                            - null
                          nullable: true
                          description: >-
                            How to read totalUsage, and the usage of each
                            sub-line item that has no usageFormat of its own:
                            unit means a count of resource units or a fixed
                            charge quantity; currency means a monetary base
                            amount in cents. Null when the line item has no
                            single usage, as a custom line item whose sub-line
                            items bill different kinds of volume, each with its
                            own usageFormat.
                        subtotalAmount:
                          type: number
                          description: >-
                            Line item amount before adjustments, in cents (sum
                            of its sub-line item amounts).
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to this line
                            item (discounts and allocation offsets), in cents.
                            Negative when adjustments reduce the amount owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final line item amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        metadata:
                          description: >-
                            Pricing metadata for the line item, where the shape
                            is keyed by type. Always present, but null for line
                            items without pricing metadata: credit_purchase,
                            additional_charge, one_off, and tax_gross_up. It is
                            populated for fixed (the billing timing),
                            usage_based, license_based, minimum_commitment,
                            contract_minimum_commitment, and custom (the
                            definition and the calculation memory) line items.
                          anyOf:
                            - title: Fixed
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed
                                  description: >-
                                    Discriminator: metadata for a fixed line
                                    item.
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    Whether the fee was billed in advance of its
                                    service period or after it.
                              required:
                                - type
                                - billingTiming
                            - title: Usage-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - usage_based
                                  description: >-
                                    Discriminator: metadata for a usage_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the metered resource accrues over the
                                    billing period: in_full bills the full usage
                                    of the period; proration weighs usage by the
                                    fraction of the period each amount was held.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how
                                    usage was divided across tiers. unique_tier
                                    prices all usage at the single tier that
                                    contains the total; progressive prices each
                                    tier's band separately. Absent for
                                    non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item. Charges priced
                                    before pricing models existed are reported
                                    as advanced.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: License-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_based
                                  description: >-
                                    Discriminator: metadata for a license_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the license count accrues over the
                                    billing period. Always in_full: the latest
                                    reported count is billed in full.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how the
                                    license count was divided across tiers.
                                    unique_tier prices the whole count at the
                                    single tier that contains the total;
                                    progressive prices each tier's band
                                    separately. Absent for non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: Contract minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - contract_minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a
                                    contract_minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the whole
                                    contract in the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the contract's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a plan-level
                                    minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the plan in
                                    the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the plan's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Custom
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - custom
                                  description: >-
                                    Discriminator: metadata for a custom line
                                    item.
                                definitionKey:
                                  type: string
                                  description: >-
                                    The key of the custom charge definition
                                    whose calculator priced the charge,
                                    following the custom:charge:<slug>:<name>
                                    convention.
                                  examples:
                                    - custom:charge:padaria-central:entregas
                                memory:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The full calculation memory that the
                                    calculator returned, such as every tier it
                                    evaluated and the one it billed. Its shape
                                    belongs to the definition.
                              required:
                                - type
                                - definitionKey
                                - memory
                            - title: No metadata
                              type: 'null'
                        subLineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing a sub-line item: one priced
                              row of a line item's breakdown. The row type
                              dictates the shape of metadata.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the sub-line item in
                                  our system.
                              type:
                                type: string
                                enum:
                                  - fixed_price
                                  - minimum_amount
                                  - price_tier_flat
                                  - price_tier_unit
                                  - price_tier_package
                                  - price_tier_percentage
                                  - proration
                                  - license_proration
                                  - license_proration_tier
                                  - unit_price
                                  - included_quantity
                                  - package_price
                                  - percentage
                                  - overage
                                  - original_amount
                                  - fixed_unit_price
                                  - custom
                                description: >-
                                  The kind of priced row: fixed_price and
                                  minimum_amount are companions of usage-based
                                  charges; unit_price, package_price,
                                  percentage, and included_quantity break down
                                  single-model pricing; price_tier_* rows break
                                  down tiered pricing; overage bills usage
                                  beyond the last tier; proration bills per
                                  prorated interval; license_proration bills
                                  license deltas (removals are negative);
                                  original_amount surfaces the pre-adjustment
                                  amount of an adjusted line; fixed_unit_price
                                  breaks down a fixed charge billed as a
                                  quantity times a unit amount; custom bills one
                                  component of a custom plan charge.
                              name:
                                type: string
                                description: >-
                                  Display name of the sub-line item as it
                                  appears on the invoice breakdown.
                                example: '[A partir de 1] Unidades'
                              description:
                                type: string
                                nullable: true
                                description: >-
                                  Optional descriptive text for the row. Null
                                  when absent.
                                example: 120 x 2,50
                              usage:
                                type: number
                                nullable: true
                                description: >-
                                  The usage billed by this row: a count of
                                  resource units (the quantity for a
                                  fixed_unit_price row), or a monetary base
                                  amount in cents for percentage-priced rows
                                  (see the row's usageFormat, or the line item
                                  usageFormat when the row has none). Null for
                                  rows without usage (e.g. companions).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read the usage of this row when the row
                                  has a format of its own, as the custom rows of
                                  a custom line item do: unit means a count,
                                  currency means an amount in cents. Null when
                                  the row reads its usage in the line item
                                  usageFormat.
                              amount:
                                type: number
                                description: >-
                                  Amount billed by this row, in cents. The sum
                                  of a line item's sub-line amounts equals its
                                  subtotalAmount.
                              metadata:
                                description: >-
                                  Pricing details of the row, keyed by the row
                                  type (and pricingType for overage rows).
                                anyOf:
                                  - type: object
                                    description: >-
                                      Fixed-price companion row: the charge's
                                      configured fixed amount, billed alongside
                                      the usage rows. Only rendered when
                                      configured greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_price
                                        description: >-
                                          Discriminator: fixed-price companion
                                          row.
                                      fixedPrice:
                                        type: number
                                        description: >-
                                          The fixed amount configured on the
                                          charge, in cents.
                                    required:
                                      - type
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Minimum-amount companion row: tops the
                                      charge up to its configured minimum when
                                      usage alone stays below it. Only rendered
                                      when the top-up is greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_amount
                                        description: >-
                                          Discriminator: minimum-amount companion
                                          row.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount configured on the
                                          charge, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up billed by this row to reach
                                          the configured minimum, in cents.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - type: object
                                    description: >-
                                      Flat-priced tier row: usage falling in
                                      this tier band is billed at a flat amount,
                                      regardless of the exact quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_flat
                                        description: 'Discriminator: flat-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      fixedPrice:
                                        type: string
                                        description: >-
                                          The flat amount billed for the tier, as
                                          a decimal currency-unit string.
                                        examples:
                                          - '150.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Per-unit priced tier row: units attributed
                                      to this tier band are billed at the tier's
                                      unit price.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_unit
                                        description: 'Discriminator: per-unit priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      price:
                                        type: string
                                        description: >-
                                          Price per unit within the tier, as a
                                          decimal currency-unit string.
                                        examples:
                                          - '0.25'
                                      fixedPrice:
                                        type: string
                                        nullable: true
                                        description: >-
                                          Optional flat fee billed on top when the
                                          tier applies, as a decimal currency-unit
                                          string. Null when the tier has no flat
                                          fee.
                                        examples:
                                          - '10.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - price
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Package-priced tier row: units attributed
                                      to this tier band are billed per started
                                      package of packageSize units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_package
                                        description: 'Discriminator: package-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string.
                                        examples:
                                          - '45.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - packageSize
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage-priced tier row: the monetary
                                      base amount attributed to this tier band
                                      is billed at a percentage.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_percentage
                                        description: >-
                                          Discriminator: percentage-priced tier
                                          row.
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                          Null for an unbounded final tier.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          within the tier, as a decimal string
                                          from 0 to 100 (up to 6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - percentage
                                  - type: object
                                    description: >-
                                      Proration interval row: for charges on
                                      prorated resources, each interval bills
                                      the usage held during it, priced as if
                                      held for the whole cycle and scaled by the
                                      interval's share of the cycle.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - proration
                                        description: 'Discriminator: proration interval row.'
                                      intervalSize:
                                        type: number
                                        description: >-
                                          Length of the interval, in days of the
                                          billing cycle.
                                      amount:
                                        type: string
                                        description: >-
                                          The prorated amount of the interval, as
                                          a decimal currency-unit string: the
                                          interval usage priced as if held for the
                                          whole cycle, scaled by intervalSize over
                                          the cycle length.
                                        examples:
                                          - '29.0322580645'
                                      usage:
                                        type: number
                                        description: The usage held during the interval.
                                      intervalStart:
                                        type: string
                                        format: date
                                        description: First day of the interval.
                                      intervalEnd:
                                        type: string
                                        format: date
                                        description: Last day of the interval.
                                    required:
                                      - type
                                      - intervalSize
                                      - amount
                                      - usage
                                      - intervalStart
                                      - intervalEnd
                                  - type: object
                                    description: >-
                                      License proration delta row: for per_unit
                                      license charges billing under the
                                      proration model, the cycle-start row bills
                                      the starting licenses beyond the included
                                      quantity at their full-cycle price, and
                                      each change row bills the change in those
                                      licenses prorated over the days remaining
                                      in the cycle. A change that stays inside
                                      the included quantity has no row. Tiered
                                      charges use license_proration_tier
                                      instead. quantityDelta and the row's
                                      amount are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration
                                        description: >-
                                          Discriminator: license proration delta
                                          row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on the cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the licenses beyond the
                                          included quantity (the starting licenses
                                          beyond it on the cycle-start row).
                                          Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity after this
                                          change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on
                                          the cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|. On a cycle-start row
                                          that bills no license, the unit price of
                                          the charge.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                  - type: object
                                    description: >-
                                      Tiered license proration delta row: one
                                      price band of a license charge billing
                                      under the proration model with
                                      tiered_per_unit pricing. The cycle-start
                                      rows bill each band's opening occupancy at
                                      its full-cycle unit price, and each change
                                      row bills that band's occupancy delta
                                      prorated over the days remaining in the
                                      cycle. quantityDelta and the row's amount
                                      are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration_tier
                                        description: >-
                                          Discriminator: tiered license proration
                                          delta row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on a cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the units this band
                                          holds (the band's opening occupancy on a
                                          cycle-start row). Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity across
                                          every band after this change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on a
                                          cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                      planChargeTierId:
                                        type: string
                                        description: >-
                                          The unique identifier of the plan charge
                                          tier this row moved through.
                                        examples:
                                          - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                      from:
                                        type: number
                                        description: >-
                                          Inclusive lower bound of the band, in
                                          licenses.
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Inclusive upper bound of the band, in
                                          licenses. Null on the last, open-ended
                                          band.
                                      unitPrice:
                                        type: string
                                        description: >-
                                          The band's full-cycle price per unit, as
                                          a decimal currency-unit string.
                                          proratedUnitRate is this scaled by
                                          remainingDays over cycleDays.
                                        examples:
                                          - '25.00'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                      - planChargeTierId
                                      - from
                                      - to
                                      - unitPrice
                                  - type: object
                                    description: >-
                                      Unit-price row: billable units multiplied
                                      by a single price per unit. The row's
                                      usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - unit_price
                                        description: 'Discriminator: unit-price row.'
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.25'
                                    required:
                                      - type
                                      - price
                                  - type: object
                                    description: >-
                                      Included-quantity row: the free allotment
                                      of the charge. The row's usage holds the
                                      units consumed within the allotment and
                                      its amount is always zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - included_quantity
                                        description: 'Discriminator: included-quantity row.'
                                      includedQuantity:
                                        type: number
                                        description: >-
                                          Number of resource units included at no
                                          charge before billing starts.
                                    required:
                                      - type
                                      - includedQuantity
                                  - type: object
                                    description: >-
                                      Package-price row: billable units charged
                                      per started package of packageSize units.
                                      The row's usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - package_price
                                        description: 'Discriminator: package-price row.'
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '45.00'
                                      packagesBilled:
                                        type: number
                                        description: >-
                                          Number of packages billed: the billable
                                          units divided by packageSize, rounded
                                          up.
                                    required:
                                      - type
                                      - packageSize
                                      - price
                                      - packagesBilled
                                  - type: object
                                    description: >-
                                      Percentage row: a percentage applied over
                                      a monetary base amount. The row's usage
                                      holds the base amount, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - percentage
                                        description: 'Discriminator: percentage row.'
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount,
                                          as a decimal string from 0 to 100 (up to
                                          6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - percentage
                                  - type: object
                                    description: >-
                                      Per-unit overage row: units beyond the
                                      last tier boundary, billed at the
                                      configured excess unit price. The row's
                                      usage holds the units over the boundary.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - per_unit
                                        description: 'Discriminator: overage billed per unit.'
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          resource units.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per excess unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage overage row: the monetary base
                                      amount beyond the last tier boundary,
                                      billed at the configured excess
                                      percentage. The row's usage holds the base
                                      amount over the boundary, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - percentage
                                        description: >-
                                          Discriminator: overage billed as a
                                          percentage.
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          cents of the monetary base amount.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the excess base
                                          amount, as a decimal string from 0 to
                                          100 (up to 6 decimal places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - percentage
                                  - type: object
                                    description: >-
                                      Original-amount row: surfaces the line
                                      item's pre-adjustment amount when the line
                                      has adjustments (e.g. a discount) but no
                                      price-component rows of its own. The row's
                                      amount equals the line item's
                                      subtotalAmount.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - original_amount
                                        description: 'Discriminator: original-amount row.'
                                    required:
                                      - type
                                  - type: object
                                    description: >-
                                      Fixed unit price row: the quantity of a
                                      fixed charge multiplied by its unit
                                      amount. The row's usage holds the
                                      quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_unit_price
                                        description: 'Discriminator: fixed unit price row.'
                                      amount:
                                        type: integer
                                        minimum: 0
                                        description: Amount of one unit, in cents.
                                    required:
                                      - type
                                      - amount
                                  - type: object
                                    description: >-
                                      Custom row: one component of a custom plan
                                      charge, as its calculator billed it. The
                                      row's name, description, usage,
                                      usageFormat and amount hold the rest of
                                      the component.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: 'Discriminator: custom row.'
                                      key:
                                        type: string
                                        description: >-
                                          The key of the component in the sub-line
                                          schema of the charge's custom charge
                                          definition, such as documents_overage.
                                        examples:
                                          - documents_overage
                                    required:
                                      - type
                                      - key
                            required:
                              - id
                              - type
                              - name
                              - description
                              - usage
                              - usageFormat
                              - amount
                              - metadata
                            additionalProperties: false
                          description: >-
                            Breakdown of the line item amount into priced rows
                            (included quantities, unit/package/tier prices,
                            prorations, companions). Empty for line items
                            without a breakdown.
                        adjustments:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing an adjustment applied on top
                              of a line item subtotal, such as a discount or an
                              allocation offset.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the adjustment in our
                                  system.
                              name:
                                type: string
                                description: >-
                                  Display name of the adjustment as it appears
                                  on the invoice.
                                example: Desconto de boas-vindas
                              type:
                                type: string
                                enum:
                                  - monetary_discount
                                  - allocation_offset
                                description: >-
                                  The kind of adjustment: monetary_discount (a
                                  discount applied to the line item) or
                                  allocation_offset (the share of the amount
                                  moved to another payment account's invoice
                                  under a split allocation strategy).
                              amount:
                                type: number
                                description: >-
                                  Amount of the adjustment, in cents. Negative
                                  when the adjustment reduces the line item
                                  total.
                            required:
                              - id
                              - name
                              - type
                              - amount
                            additionalProperties: false
                          description: >-
                            Adjustments applied on top of the line item
                            subtotal, such as discounts and allocation offsets.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - resourceId
                        - licenseId
                        - lineItemGroupId
                        - name
                        - scope
                        - startDate
                        - endDate
                        - totalUsage
                        - usageFormat
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - metadata
                        - subLineItems
                        - adjustments
                      additionalProperties: false
                    description: >-
                      Line items that do not belong to any line item group (e.g.
                      contract-level minimum commitments, additional charges,
                      and ungrouped one-off items).
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of invoices, keyed by the
                      key of each custom field. The object is empty when the
                      invoice holds no value. A user edits them in the billing
                      app, and `PUT /v1/invoices/{id}/custom-fields` replaces
                      the whole set, in any status of the invoice.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  sentAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When Aira last sent the invoice by e-mail to its invoice
                      recipients, in an invoice delivery. Null when Aira has not
                      sent it.
                  replaceReason:
                    type: string
                    enum:
                      - contract_allocation_changed
                      - manually_reopened
                      - null
                    nullable: true
                    description: >-
                      Why one invoice of the same invoice slot replaced another,
                      on both invoices of the replacement: manually_reopened for
                      a reopening, and contract_allocation_changed when a change
                      to the contract allocation canceled the invoice and a
                      later billing of its billing act replaced it. Null when
                      the invoice replaces no invoice and no invoice replaces
                      it.
                  replacesInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the canceled invoice that this
                      invoice replaces in its invoice slot. Null when the
                      invoice replaces no invoice.
                  replacedByInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the invoice that replaces this
                      canceled invoice in its invoice slot. Null when no invoice
                      replaces it.
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - paymentAccountId
                  - contractId
                  - contractInvoiceSequence
                  - issuingAccount
                  - billingAccount
                  - invoiceAllocationStrategy
                  - lastCalculatedAt
                  - invoiceNumber
                  - invoiceDate
                  - memo
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - status
                  - isLocked
                  - failureReason
                  - source
                  - autoIssue
                  - amountDue
                  - dueDate
                  - lineItemGroups
                  - standaloneLineItems
                  - customFields
                  - sentAt
                  - replaceReason
                  - replacesInvoiceId
                  - replacedByInvoiceId
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `payment_integration_not_enabled`: the payments module is off.

            - `invoice_cannot_be_updated`: the invoice is open, in review,
            failed or canceled, or it has more than one payment that is created
            or pending.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - payment_integration_not_enabled
                      - invoice_cannot_be_updated
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
                payment_integration_not_enabled:
                  value:
                    message: payment integration not enabled
                    code: payment_integration_not_enabled
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `invoiceId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
  /v1/invoices/recalculate:
    post:
      summary: Recalculate invoices
      tags:
        - Invoices
      description: >-
        Enqueues the recalculation of the invoices that `invoiceIds` names, as
        the billing app does, or of each invoice whose invoice date falls inside
        the period of `invoiceDate`. Aira skips a locked invoice, an invoice
        without a billing cycle, such as a one-off or an imported invoice, and
        an id that names no invoice. It enqueues one recalculation for the
        invoices of one invoice allocation group, because they recalculate
        together. Use `GET /invoices` with its filters to find the ids of the
        invoices to recalculate.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                invoiceIds:
                  type: array
                  items:
                    type: string
                    format: uuid
                  minItems: 1
                  maxItems: 10000
                  uniqueItems: true
                  description: >-
                    The unique identifiers of the invoices to recalculate, from
                    1 to 10000, each one once.
                invoiceDate:
                  type: object
                  description: >-
                    The invoice date period to recalculate. The period cannot
                    span more than 1 month.
                  properties:
                    gte:
                      type: string
                      format: date
                      description: >-
                        Only recalculate invoices whose invoice date is on or
                        after this date.
                    lte:
                      type: string
                      format: date
                      description: >-
                        Only recalculate invoices whose invoice date is on or
                        before this date.
                  required:
                    - gte
                    - lte
                  additionalProperties: false
              allOf:
                - oneOf:
                    - required:
                        - invoiceIds
                    - required:
                        - invoiceDate
                  errorMessage: must have exactly one of invoiceIds and invoiceDate
              additionalProperties: false
        description: >-
          The invoices to recalculate: exactly one of `invoiceIds`, which names
          them, and `invoiceDate`, which selects them by their invoice date.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_period_range
          when: >-
            the `invoiceDate.lte` is before the `invoiceDate.gte`, or the period
            spans more than 1 month
      x-required-roles: *ref_8
      responses:
        '202':
          description: The recalculation has been enqueued.
          content:
            application/json:
              schema:
                type: object
                properties:
                  total:
                    type: number
                    description: >-
                      How many invoices were enqueued for recalculation. It
                      leaves out a locked invoice, an invoice without a billing
                      cycle, an id that names no invoice, and each invoice of an
                      invoice allocation group after the first.
                  capped:
                    type: boolean
                    description: >-
                      Whether Aira enqueued only part of the invoices. It is
                      always false for `invoiceIds`, because the request names
                      at most 10000 invoices. With `invoiceDate`, it is true
                      when the period holds more than 10000 invoices that Aira
                      can recalculate, because Aira then enqueues only the first
                      10000, and the rest need a narrower period.
                required:
                  - total
                  - capped
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `invalid_period_range`: the `invoiceDate.lte` is before the
            `invoiceDate.gte`, or the period spans more than 1 month.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_period_range
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: body must be object
                    code: json_schema_validation_error
                invalid_period_range:
                  value:
                    message: occurredAt.gte must not be after occurredAt.lte
                    code: invalid_period_range
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
  /v1/invoices/{invoiceId}/line-item-groups:
    post:
      summary: Create invoice line item group
      tags:
        - Invoices
      description: >-
        Creates a line item group on a one-off invoice. The group is created
        empty; group amounts are derived from child line items. Empty groups are
        allowed.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                idempotencyKey:
                  type: string
                  minLength: 1
                  pattern: ^[a-zA-Z0-9_-]+$
                  description: >-
                    A unique idempotency key for this group, scoped to the
                    invoice.
                  example: servicos-novembro
                productId:
                  type: string
                  format: uuid
                  description: The product to associate with this group.
                name:
                  type: string
                  nullable: true
                  description: Optional group name; defaults to the product name when null.
                  example: Plano Entregas
                startDate:
                  type: string
                  format: date
                  description: Start of the period covered by the group.
                endDate:
                  type: string
                  format: date
                  description: End of the period covered by the group.
              required:
                - idempotencyKey
                - productId
                - startDate
                - endDate
              additionalProperties: false
        required: true
        description: >-
          Schema for creating a line item group container for an existing
          one-off invoice. The group is created empty; line items are added via
          the line-items endpoint. Empty groups are allowed.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice to add the line item group to.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: >-
            the invoice is not a one-off invoice, or it is locked, because it
            was issued or canceled
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - status: 404
          code: product_not_found
          when: the `name` is null or left out, and no product has the `productId`
        - status: 409
          code: line_item_group_idempotency_key_conflict
          when: a line item group of the invoice already has the `idempotencyKey`
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            Schema representing a line item group: a container that gathers the
            line items generated from one plan instance (or created as a group
            on one-off invoices). Monetary amounts are integers in cents.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the line item group in our
                      system.
                  idempotencyKey:
                    type: string
                    description: >-
                      A unique key that identifies the group within the invoice.
                      Supplied by the caller for one-off groups; generated by
                      the billing engine otherwise.
                    example: servicos-novembro
                  customerId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the customer whose consumption
                      this group bills.
                  productId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the product this group belongs
                      to.
                  planId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the plan whose instance generated
                      this group. Null for groups not generated from a plan
                      (e.g. on one-off invoices).
                  planInstanceId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the plan instance that generated
                      this group. Null for groups not generated from a plan
                      instance.
                  name:
                    type: string
                    description: >-
                      Display name of the group as it appears on the invoice,
                      typically the plan or product name.
                    example: Plano Entregas
                  startDate:
                    type: string
                    format: date
                    description: >-
                      Start of the period that the group shows. On contract
                      invoices, it is the period of the group's line item that
                      bills most often, such as the month when a monthly fee is
                      billed with an annual fee. When two line items bill
                      equally often, it is the earlier period.
                  endDate:
                    type: string
                    format: date
                    description: >-
                      End of the period that the group shows, which `startDate`
                      describes.
                  subtotalAmount:
                    type: number
                    description: >-
                      Sum of the group's line item subtotals before adjustments,
                      in cents.
                  adjustmentAmount:
                    type: number
                    description: >-
                      Net amount of the adjustments applied to the group's line
                      items (discounts and allocation offsets), in cents.
                      Negative when adjustments reduce the amount owed.
                  totalAmount:
                    type: number
                    description: >-
                      Final group amount, in cents: subtotalAmount +
                      adjustmentAmount.
                  discountAmount:
                    type: number
                    description: >-
                      The discount portion of adjustmentAmount, in cents (sum of
                      monetary discount adjustments only). Negative when
                      discounts were applied.
                  lineItems:
                    type: array
                    items:
                      type: object
                      description: >-
                        One amount on an invoice, such as a plan charge, the
                        contract minimum, a tax gross-up (the withheld ISS, the
                        municipal service tax, added on top), a one-off amount
                        or an additional charge.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the line item within
                            the invoice. Supplied by the caller for one-off line
                            items; generated by the billing engine otherwise.
                          example: entrega-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this line item bills. On split or
                            consolidated invoices it may be a subsidiary of the
                            invoice's customer.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this line item
                            belongs to.
                        itemId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the catalog item this line
                            bills. Null for line items not backed by a catalog
                            item.
                        resourceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the metered resource behind
                            a usage_based line item. Null for line items not
                            driven by resource usage.
                        licenseId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the license behind a
                            license_based line item. Null for line items not
                            driven by a license count.
                        lineItemGroupId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the line item group
                            containing this line item. Null for standalone line
                            items.
                        name:
                          type: string
                          description: >-
                            Display name of the line item as it appears on the
                            invoice.
                          example: Entregas
                        scope:
                          type: string
                          enum:
                            - credit_purchase
                            - contract_minimum_commitment
                            - minimum_commitment
                            - fixed
                            - usage_based
                            - license_based
                            - custom
                            - additional_charge
                            - one_off
                            - tax_gross_up
                          description: >-
                            What the line item charges for: usage_based (metered
                            resource consumption), license_based (a license's
                            reported count billed in full), fixed (recurring
                            fixed charge of a plan), custom (custom plan charge,
                            priced by a calculator that Aira writes for you),
                            minimum_commitment (plan-level minimum top-up),
                            contract_minimum_commitment (contract-level minimum
                            top-up), credit_purchase (credit pool top-up),
                            additional_charge (extra charge added manually),
                            one_off (line item of a one-off invoice), or
                            tax_gross_up (tax gross-up charge).
                        startDate:
                          type: string
                          format: date
                          description: Start of the period covered by this line item.
                        endDate:
                          type: string
                          format: date
                          description: End of the period covered by this line item.
                        totalUsage:
                          type: number
                          nullable: true
                          description: >-
                            Total usage billed by the line item, in the unit
                            given by usageFormat. Null for line items without a
                            single usage (e.g. fixed charges without a quantity,
                            and custom line items whose calculator returns no
                            total).
                        usageFormat:
                          type: string
                          enum:
                            - unit
                            - currency
                            - null
                          nullable: true
                          description: >-
                            How to read totalUsage, and the usage of each
                            sub-line item that has no usageFormat of its own:
                            unit means a count of resource units or a fixed
                            charge quantity; currency means a monetary base
                            amount in cents. Null when the line item has no
                            single usage, as a custom line item whose sub-line
                            items bill different kinds of volume, each with its
                            own usageFormat.
                        subtotalAmount:
                          type: number
                          description: >-
                            Line item amount before adjustments, in cents (sum
                            of its sub-line item amounts).
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to this line
                            item (discounts and allocation offsets), in cents.
                            Negative when adjustments reduce the amount owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final line item amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        metadata:
                          description: >-
                            Pricing metadata for the line item, where the shape
                            is keyed by type. Always present, but null for line
                            items without pricing metadata: credit_purchase,
                            additional_charge, one_off, and tax_gross_up. It is
                            populated for fixed (the billing timing),
                            usage_based, license_based, minimum_commitment,
                            contract_minimum_commitment, and custom (the
                            definition and the calculation memory) line items.
                          anyOf:
                            - title: Fixed
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed
                                  description: >-
                                    Discriminator: metadata for a fixed line
                                    item.
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    Whether the fee was billed in advance of its
                                    service period or after it.
                              required:
                                - type
                                - billingTiming
                            - title: Usage-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - usage_based
                                  description: >-
                                    Discriminator: metadata for a usage_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the metered resource accrues over the
                                    billing period: in_full bills the full usage
                                    of the period; proration weighs usage by the
                                    fraction of the period each amount was held.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how
                                    usage was divided across tiers. unique_tier
                                    prices all usage at the single tier that
                                    contains the total; progressive prices each
                                    tier's band separately. Absent for
                                    non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item. Charges priced
                                    before pricing models existed are reported
                                    as advanced.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: License-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_based
                                  description: >-
                                    Discriminator: metadata for a license_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the license count accrues over the
                                    billing period. Always in_full: the latest
                                    reported count is billed in full.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how the
                                    license count was divided across tiers.
                                    unique_tier prices the whole count at the
                                    single tier that contains the total;
                                    progressive prices each tier's band
                                    separately. Absent for non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: Contract minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - contract_minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a
                                    contract_minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the whole
                                    contract in the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the contract's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a plan-level
                                    minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the plan in
                                    the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the plan's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Custom
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - custom
                                  description: >-
                                    Discriminator: metadata for a custom line
                                    item.
                                definitionKey:
                                  type: string
                                  description: >-
                                    The key of the custom charge definition
                                    whose calculator priced the charge,
                                    following the custom:charge:<slug>:<name>
                                    convention.
                                  examples:
                                    - custom:charge:padaria-central:entregas
                                memory:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The full calculation memory that the
                                    calculator returned, such as every tier it
                                    evaluated and the one it billed. Its shape
                                    belongs to the definition.
                              required:
                                - type
                                - definitionKey
                                - memory
                            - title: No metadata
                              type: 'null'
                        subLineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing a sub-line item: one priced
                              row of a line item's breakdown. The row type
                              dictates the shape of metadata.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the sub-line item in
                                  our system.
                              type:
                                type: string
                                enum:
                                  - fixed_price
                                  - minimum_amount
                                  - price_tier_flat
                                  - price_tier_unit
                                  - price_tier_package
                                  - price_tier_percentage
                                  - proration
                                  - license_proration
                                  - license_proration_tier
                                  - unit_price
                                  - included_quantity
                                  - package_price
                                  - percentage
                                  - overage
                                  - original_amount
                                  - fixed_unit_price
                                  - custom
                                description: >-
                                  The kind of priced row: fixed_price and
                                  minimum_amount are companions of usage-based
                                  charges; unit_price, package_price,
                                  percentage, and included_quantity break down
                                  single-model pricing; price_tier_* rows break
                                  down tiered pricing; overage bills usage
                                  beyond the last tier; proration bills per
                                  prorated interval; license_proration bills
                                  license deltas (removals are negative);
                                  original_amount surfaces the pre-adjustment
                                  amount of an adjusted line; fixed_unit_price
                                  breaks down a fixed charge billed as a
                                  quantity times a unit amount; custom bills one
                                  component of a custom plan charge.
                              name:
                                type: string
                                description: >-
                                  Display name of the sub-line item as it
                                  appears on the invoice breakdown.
                                example: '[A partir de 1] Unidades'
                              description:
                                type: string
                                nullable: true
                                description: >-
                                  Optional descriptive text for the row. Null
                                  when absent.
                                example: 120 x 2,50
                              usage:
                                type: number
                                nullable: true
                                description: >-
                                  The usage billed by this row: a count of
                                  resource units (the quantity for a
                                  fixed_unit_price row), or a monetary base
                                  amount in cents for percentage-priced rows
                                  (see the row's usageFormat, or the line item
                                  usageFormat when the row has none). Null for
                                  rows without usage (e.g. companions).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read the usage of this row when the row
                                  has a format of its own, as the custom rows of
                                  a custom line item do: unit means a count,
                                  currency means an amount in cents. Null when
                                  the row reads its usage in the line item
                                  usageFormat.
                              amount:
                                type: number
                                description: >-
                                  Amount billed by this row, in cents. The sum
                                  of a line item's sub-line amounts equals its
                                  subtotalAmount.
                              metadata:
                                description: >-
                                  Pricing details of the row, keyed by the row
                                  type (and pricingType for overage rows).
                                anyOf:
                                  - type: object
                                    description: >-
                                      Fixed-price companion row: the charge's
                                      configured fixed amount, billed alongside
                                      the usage rows. Only rendered when
                                      configured greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_price
                                        description: >-
                                          Discriminator: fixed-price companion
                                          row.
                                      fixedPrice:
                                        type: number
                                        description: >-
                                          The fixed amount configured on the
                                          charge, in cents.
                                    required:
                                      - type
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Minimum-amount companion row: tops the
                                      charge up to its configured minimum when
                                      usage alone stays below it. Only rendered
                                      when the top-up is greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_amount
                                        description: >-
                                          Discriminator: minimum-amount companion
                                          row.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount configured on the
                                          charge, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up billed by this row to reach
                                          the configured minimum, in cents.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - type: object
                                    description: >-
                                      Flat-priced tier row: usage falling in
                                      this tier band is billed at a flat amount,
                                      regardless of the exact quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_flat
                                        description: 'Discriminator: flat-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      fixedPrice:
                                        type: string
                                        description: >-
                                          The flat amount billed for the tier, as
                                          a decimal currency-unit string.
                                        examples:
                                          - '150.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Per-unit priced tier row: units attributed
                                      to this tier band are billed at the tier's
                                      unit price.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_unit
                                        description: 'Discriminator: per-unit priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      price:
                                        type: string
                                        description: >-
                                          Price per unit within the tier, as a
                                          decimal currency-unit string.
                                        examples:
                                          - '0.25'
                                      fixedPrice:
                                        type: string
                                        nullable: true
                                        description: >-
                                          Optional flat fee billed on top when the
                                          tier applies, as a decimal currency-unit
                                          string. Null when the tier has no flat
                                          fee.
                                        examples:
                                          - '10.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - price
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Package-priced tier row: units attributed
                                      to this tier band are billed per started
                                      package of packageSize units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_package
                                        description: 'Discriminator: package-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string.
                                        examples:
                                          - '45.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - packageSize
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage-priced tier row: the monetary
                                      base amount attributed to this tier band
                                      is billed at a percentage.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_percentage
                                        description: >-
                                          Discriminator: percentage-priced tier
                                          row.
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                          Null for an unbounded final tier.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          within the tier, as a decimal string
                                          from 0 to 100 (up to 6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - percentage
                                  - type: object
                                    description: >-
                                      Proration interval row: for charges on
                                      prorated resources, each interval bills
                                      the usage held during it, priced as if
                                      held for the whole cycle and scaled by the
                                      interval's share of the cycle.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - proration
                                        description: 'Discriminator: proration interval row.'
                                      intervalSize:
                                        type: number
                                        description: >-
                                          Length of the interval, in days of the
                                          billing cycle.
                                      amount:
                                        type: string
                                        description: >-
                                          The prorated amount of the interval, as
                                          a decimal currency-unit string: the
                                          interval usage priced as if held for the
                                          whole cycle, scaled by intervalSize over
                                          the cycle length.
                                        examples:
                                          - '29.0322580645'
                                      usage:
                                        type: number
                                        description: The usage held during the interval.
                                      intervalStart:
                                        type: string
                                        format: date
                                        description: First day of the interval.
                                      intervalEnd:
                                        type: string
                                        format: date
                                        description: Last day of the interval.
                                    required:
                                      - type
                                      - intervalSize
                                      - amount
                                      - usage
                                      - intervalStart
                                      - intervalEnd
                                  - type: object
                                    description: >-
                                      License proration delta row: for per_unit
                                      license charges billing under the
                                      proration model, the cycle-start row bills
                                      the starting licenses beyond the included
                                      quantity at their full-cycle price, and
                                      each change row bills the change in those
                                      licenses prorated over the days remaining
                                      in the cycle. A change that stays inside
                                      the included quantity has no row. Tiered
                                      charges use license_proration_tier
                                      instead. quantityDelta and the row's
                                      amount are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration
                                        description: >-
                                          Discriminator: license proration delta
                                          row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on the cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the licenses beyond the
                                          included quantity (the starting licenses
                                          beyond it on the cycle-start row).
                                          Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity after this
                                          change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on
                                          the cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|. On a cycle-start row
                                          that bills no license, the unit price of
                                          the charge.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                  - type: object
                                    description: >-
                                      Tiered license proration delta row: one
                                      price band of a license charge billing
                                      under the proration model with
                                      tiered_per_unit pricing. The cycle-start
                                      rows bill each band's opening occupancy at
                                      its full-cycle unit price, and each change
                                      row bills that band's occupancy delta
                                      prorated over the days remaining in the
                                      cycle. quantityDelta and the row's amount
                                      are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration_tier
                                        description: >-
                                          Discriminator: tiered license proration
                                          delta row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on a cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the units this band
                                          holds (the band's opening occupancy on a
                                          cycle-start row). Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity across
                                          every band after this change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on a
                                          cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                      planChargeTierId:
                                        type: string
                                        description: >-
                                          The unique identifier of the plan charge
                                          tier this row moved through.
                                        examples:
                                          - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                      from:
                                        type: number
                                        description: >-
                                          Inclusive lower bound of the band, in
                                          licenses.
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Inclusive upper bound of the band, in
                                          licenses. Null on the last, open-ended
                                          band.
                                      unitPrice:
                                        type: string
                                        description: >-
                                          The band's full-cycle price per unit, as
                                          a decimal currency-unit string.
                                          proratedUnitRate is this scaled by
                                          remainingDays over cycleDays.
                                        examples:
                                          - '25.00'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                      - planChargeTierId
                                      - from
                                      - to
                                      - unitPrice
                                  - type: object
                                    description: >-
                                      Unit-price row: billable units multiplied
                                      by a single price per unit. The row's
                                      usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - unit_price
                                        description: 'Discriminator: unit-price row.'
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.25'
                                    required:
                                      - type
                                      - price
                                  - type: object
                                    description: >-
                                      Included-quantity row: the free allotment
                                      of the charge. The row's usage holds the
                                      units consumed within the allotment and
                                      its amount is always zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - included_quantity
                                        description: 'Discriminator: included-quantity row.'
                                      includedQuantity:
                                        type: number
                                        description: >-
                                          Number of resource units included at no
                                          charge before billing starts.
                                    required:
                                      - type
                                      - includedQuantity
                                  - type: object
                                    description: >-
                                      Package-price row: billable units charged
                                      per started package of packageSize units.
                                      The row's usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - package_price
                                        description: 'Discriminator: package-price row.'
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '45.00'
                                      packagesBilled:
                                        type: number
                                        description: >-
                                          Number of packages billed: the billable
                                          units divided by packageSize, rounded
                                          up.
                                    required:
                                      - type
                                      - packageSize
                                      - price
                                      - packagesBilled
                                  - type: object
                                    description: >-
                                      Percentage row: a percentage applied over
                                      a monetary base amount. The row's usage
                                      holds the base amount, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - percentage
                                        description: 'Discriminator: percentage row.'
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount,
                                          as a decimal string from 0 to 100 (up to
                                          6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - percentage
                                  - type: object
                                    description: >-
                                      Per-unit overage row: units beyond the
                                      last tier boundary, billed at the
                                      configured excess unit price. The row's
                                      usage holds the units over the boundary.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - per_unit
                                        description: 'Discriminator: overage billed per unit.'
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          resource units.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per excess unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage overage row: the monetary base
                                      amount beyond the last tier boundary,
                                      billed at the configured excess
                                      percentage. The row's usage holds the base
                                      amount over the boundary, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - percentage
                                        description: >-
                                          Discriminator: overage billed as a
                                          percentage.
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          cents of the monetary base amount.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the excess base
                                          amount, as a decimal string from 0 to
                                          100 (up to 6 decimal places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - percentage
                                  - type: object
                                    description: >-
                                      Original-amount row: surfaces the line
                                      item's pre-adjustment amount when the line
                                      has adjustments (e.g. a discount) but no
                                      price-component rows of its own. The row's
                                      amount equals the line item's
                                      subtotalAmount.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - original_amount
                                        description: 'Discriminator: original-amount row.'
                                    required:
                                      - type
                                  - type: object
                                    description: >-
                                      Fixed unit price row: the quantity of a
                                      fixed charge multiplied by its unit
                                      amount. The row's usage holds the
                                      quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_unit_price
                                        description: 'Discriminator: fixed unit price row.'
                                      amount:
                                        type: integer
                                        minimum: 0
                                        description: Amount of one unit, in cents.
                                    required:
                                      - type
                                      - amount
                                  - type: object
                                    description: >-
                                      Custom row: one component of a custom plan
                                      charge, as its calculator billed it. The
                                      row's name, description, usage,
                                      usageFormat and amount hold the rest of
                                      the component.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: 'Discriminator: custom row.'
                                      key:
                                        type: string
                                        description: >-
                                          The key of the component in the sub-line
                                          schema of the charge's custom charge
                                          definition, such as documents_overage.
                                        examples:
                                          - documents_overage
                                    required:
                                      - type
                                      - key
                            required:
                              - id
                              - type
                              - name
                              - description
                              - usage
                              - usageFormat
                              - amount
                              - metadata
                            additionalProperties: false
                          description: >-
                            Breakdown of the line item amount into priced rows
                            (included quantities, unit/package/tier prices,
                            prorations, companions). Empty for line items
                            without a breakdown.
                        adjustments:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing an adjustment applied on top
                              of a line item subtotal, such as a discount or an
                              allocation offset.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the adjustment in our
                                  system.
                              name:
                                type: string
                                description: >-
                                  Display name of the adjustment as it appears
                                  on the invoice.
                                example: Desconto de boas-vindas
                              type:
                                type: string
                                enum:
                                  - monetary_discount
                                  - allocation_offset
                                description: >-
                                  The kind of adjustment: monetary_discount (a
                                  discount applied to the line item) or
                                  allocation_offset (the share of the amount
                                  moved to another payment account's invoice
                                  under a split allocation strategy).
                              amount:
                                type: number
                                description: >-
                                  Amount of the adjustment, in cents. Negative
                                  when the adjustment reduces the line item
                                  total.
                            required:
                              - id
                              - name
                              - type
                              - amount
                            additionalProperties: false
                          description: >-
                            Adjustments applied on top of the line item
                            subtotal, such as discounts and allocation offsets.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - resourceId
                        - licenseId
                        - lineItemGroupId
                        - name
                        - scope
                        - startDate
                        - endDate
                        - totalUsage
                        - usageFormat
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - metadata
                        - subLineItems
                        - adjustments
                      additionalProperties: false
                    description: The line items contained in this group.
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - productId
                  - planId
                  - planInstanceId
                  - name
                  - startDate
                  - endDate
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - lineItems
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is not a one-off invoice,
            or it is locked, because it was issued or canceled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''idempotencyKey'' is required'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `invoiceId`.

            - `product_not_found`: the `name` is null or left out, and no
            product has the `productId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - product_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                product_not_found:
                  value:
                    message: default product not found
                    code: product_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `line_item_group_idempotency_key_conflict`: a line item group of
            the invoice already has the `idempotencyKey`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - line_item_group_idempotency_key_conflict
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                line_item_group_idempotency_key_conflict:
                  value:
                    message: >-
                      line item group with this idempotency key already exists
                      for this invoice
                    code: line_item_group_idempotency_key_conflict
  /v1/invoices/{invoiceId}/line-item-groups/{lineItemGroupId}:
    put:
      summary: Update invoice line item group
      tags:
        - Invoices
      description: >-
        Updates the name, start date, and end date of a line item group on a
        one-off invoice.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  nullable: true
                  description: Optional group name; defaults to the product name when null.
                  example: Plano Entregas
                startDate:
                  type: string
                  format: date
                  description: Start of the period covered by the group.
                endDate:
                  type: string
                  format: date
                  description: End of the period covered by the group.
              required:
                - startDate
                - endDate
              additionalProperties: false
        required: true
        description: >-
          Schema for updating an invoice line item group. Updates name, start
          date, and end date.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice the group belongs to.
        - schema:
            type: string
            format: uuid
          in: path
          name: lineItemGroupId
          required: true
          description: The unique identifier of the line item group to update.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: >-
            the invoice is not a one-off invoice, or it is locked, because it
            was issued or canceled
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - status: 404
          code: line_item_group_not_found
          when: no line item group of the invoice has the `lineItemGroupId`
        - status: 404
          code: product_not_found
          when: >-
            the `name` is null or left out, and no product has the `productId`
            of the line item group
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            Schema representing a line item group: a container that gathers the
            line items generated from one plan instance (or created as a group
            on one-off invoices). Monetary amounts are integers in cents.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the line item group in our
                      system.
                  idempotencyKey:
                    type: string
                    description: >-
                      A unique key that identifies the group within the invoice.
                      Supplied by the caller for one-off groups; generated by
                      the billing engine otherwise.
                    example: servicos-novembro
                  customerId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the customer whose consumption
                      this group bills.
                  productId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the product this group belongs
                      to.
                  planId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the plan whose instance generated
                      this group. Null for groups not generated from a plan
                      (e.g. on one-off invoices).
                  planInstanceId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the plan instance that generated
                      this group. Null for groups not generated from a plan
                      instance.
                  name:
                    type: string
                    description: >-
                      Display name of the group as it appears on the invoice,
                      typically the plan or product name.
                    example: Plano Entregas
                  startDate:
                    type: string
                    format: date
                    description: >-
                      Start of the period that the group shows. On contract
                      invoices, it is the period of the group's line item that
                      bills most often, such as the month when a monthly fee is
                      billed with an annual fee. When two line items bill
                      equally often, it is the earlier period.
                  endDate:
                    type: string
                    format: date
                    description: >-
                      End of the period that the group shows, which `startDate`
                      describes.
                  subtotalAmount:
                    type: number
                    description: >-
                      Sum of the group's line item subtotals before adjustments,
                      in cents.
                  adjustmentAmount:
                    type: number
                    description: >-
                      Net amount of the adjustments applied to the group's line
                      items (discounts and allocation offsets), in cents.
                      Negative when adjustments reduce the amount owed.
                  totalAmount:
                    type: number
                    description: >-
                      Final group amount, in cents: subtotalAmount +
                      adjustmentAmount.
                  discountAmount:
                    type: number
                    description: >-
                      The discount portion of adjustmentAmount, in cents (sum of
                      monetary discount adjustments only). Negative when
                      discounts were applied.
                  lineItems:
                    type: array
                    items:
                      type: object
                      description: >-
                        One amount on an invoice, such as a plan charge, the
                        contract minimum, a tax gross-up (the withheld ISS, the
                        municipal service tax, added on top), a one-off amount
                        or an additional charge.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the line item within
                            the invoice. Supplied by the caller for one-off line
                            items; generated by the billing engine otherwise.
                          example: entrega-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this line item bills. On split or
                            consolidated invoices it may be a subsidiary of the
                            invoice's customer.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this line item
                            belongs to.
                        itemId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the catalog item this line
                            bills. Null for line items not backed by a catalog
                            item.
                        resourceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the metered resource behind
                            a usage_based line item. Null for line items not
                            driven by resource usage.
                        licenseId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the license behind a
                            license_based line item. Null for line items not
                            driven by a license count.
                        lineItemGroupId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the line item group
                            containing this line item. Null for standalone line
                            items.
                        name:
                          type: string
                          description: >-
                            Display name of the line item as it appears on the
                            invoice.
                          example: Entregas
                        scope:
                          type: string
                          enum:
                            - credit_purchase
                            - contract_minimum_commitment
                            - minimum_commitment
                            - fixed
                            - usage_based
                            - license_based
                            - custom
                            - additional_charge
                            - one_off
                            - tax_gross_up
                          description: >-
                            What the line item charges for: usage_based (metered
                            resource consumption), license_based (a license's
                            reported count billed in full), fixed (recurring
                            fixed charge of a plan), custom (custom plan charge,
                            priced by a calculator that Aira writes for you),
                            minimum_commitment (plan-level minimum top-up),
                            contract_minimum_commitment (contract-level minimum
                            top-up), credit_purchase (credit pool top-up),
                            additional_charge (extra charge added manually),
                            one_off (line item of a one-off invoice), or
                            tax_gross_up (tax gross-up charge).
                        startDate:
                          type: string
                          format: date
                          description: Start of the period covered by this line item.
                        endDate:
                          type: string
                          format: date
                          description: End of the period covered by this line item.
                        totalUsage:
                          type: number
                          nullable: true
                          description: >-
                            Total usage billed by the line item, in the unit
                            given by usageFormat. Null for line items without a
                            single usage (e.g. fixed charges without a quantity,
                            and custom line items whose calculator returns no
                            total).
                        usageFormat:
                          type: string
                          enum:
                            - unit
                            - currency
                            - null
                          nullable: true
                          description: >-
                            How to read totalUsage, and the usage of each
                            sub-line item that has no usageFormat of its own:
                            unit means a count of resource units or a fixed
                            charge quantity; currency means a monetary base
                            amount in cents. Null when the line item has no
                            single usage, as a custom line item whose sub-line
                            items bill different kinds of volume, each with its
                            own usageFormat.
                        subtotalAmount:
                          type: number
                          description: >-
                            Line item amount before adjustments, in cents (sum
                            of its sub-line item amounts).
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to this line
                            item (discounts and allocation offsets), in cents.
                            Negative when adjustments reduce the amount owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final line item amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        metadata:
                          description: >-
                            Pricing metadata for the line item, where the shape
                            is keyed by type. Always present, but null for line
                            items without pricing metadata: credit_purchase,
                            additional_charge, one_off, and tax_gross_up. It is
                            populated for fixed (the billing timing),
                            usage_based, license_based, minimum_commitment,
                            contract_minimum_commitment, and custom (the
                            definition and the calculation memory) line items.
                          anyOf:
                            - title: Fixed
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed
                                  description: >-
                                    Discriminator: metadata for a fixed line
                                    item.
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    Whether the fee was billed in advance of its
                                    service period or after it.
                              required:
                                - type
                                - billingTiming
                            - title: Usage-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - usage_based
                                  description: >-
                                    Discriminator: metadata for a usage_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the metered resource accrues over the
                                    billing period: in_full bills the full usage
                                    of the period; proration weighs usage by the
                                    fraction of the period each amount was held.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how
                                    usage was divided across tiers. unique_tier
                                    prices all usage at the single tier that
                                    contains the total; progressive prices each
                                    tier's band separately. Absent for
                                    non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item. Charges priced
                                    before pricing models existed are reported
                                    as advanced.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: License-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_based
                                  description: >-
                                    Discriminator: metadata for a license_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the license count accrues over the
                                    billing period. Always in_full: the latest
                                    reported count is billed in full.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how the
                                    license count was divided across tiers.
                                    unique_tier prices the whole count at the
                                    single tier that contains the total;
                                    progressive prices each tier's band
                                    separately. Absent for non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: Contract minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - contract_minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a
                                    contract_minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the whole
                                    contract in the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the contract's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a plan-level
                                    minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the plan in
                                    the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the plan's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Custom
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - custom
                                  description: >-
                                    Discriminator: metadata for a custom line
                                    item.
                                definitionKey:
                                  type: string
                                  description: >-
                                    The key of the custom charge definition
                                    whose calculator priced the charge,
                                    following the custom:charge:<slug>:<name>
                                    convention.
                                  examples:
                                    - custom:charge:padaria-central:entregas
                                memory:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The full calculation memory that the
                                    calculator returned, such as every tier it
                                    evaluated and the one it billed. Its shape
                                    belongs to the definition.
                              required:
                                - type
                                - definitionKey
                                - memory
                            - title: No metadata
                              type: 'null'
                        subLineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing a sub-line item: one priced
                              row of a line item's breakdown. The row type
                              dictates the shape of metadata.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the sub-line item in
                                  our system.
                              type:
                                type: string
                                enum:
                                  - fixed_price
                                  - minimum_amount
                                  - price_tier_flat
                                  - price_tier_unit
                                  - price_tier_package
                                  - price_tier_percentage
                                  - proration
                                  - license_proration
                                  - license_proration_tier
                                  - unit_price
                                  - included_quantity
                                  - package_price
                                  - percentage
                                  - overage
                                  - original_amount
                                  - fixed_unit_price
                                  - custom
                                description: >-
                                  The kind of priced row: fixed_price and
                                  minimum_amount are companions of usage-based
                                  charges; unit_price, package_price,
                                  percentage, and included_quantity break down
                                  single-model pricing; price_tier_* rows break
                                  down tiered pricing; overage bills usage
                                  beyond the last tier; proration bills per
                                  prorated interval; license_proration bills
                                  license deltas (removals are negative);
                                  original_amount surfaces the pre-adjustment
                                  amount of an adjusted line; fixed_unit_price
                                  breaks down a fixed charge billed as a
                                  quantity times a unit amount; custom bills one
                                  component of a custom plan charge.
                              name:
                                type: string
                                description: >-
                                  Display name of the sub-line item as it
                                  appears on the invoice breakdown.
                                example: '[A partir de 1] Unidades'
                              description:
                                type: string
                                nullable: true
                                description: >-
                                  Optional descriptive text for the row. Null
                                  when absent.
                                example: 120 x 2,50
                              usage:
                                type: number
                                nullable: true
                                description: >-
                                  The usage billed by this row: a count of
                                  resource units (the quantity for a
                                  fixed_unit_price row), or a monetary base
                                  amount in cents for percentage-priced rows
                                  (see the row's usageFormat, or the line item
                                  usageFormat when the row has none). Null for
                                  rows without usage (e.g. companions).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read the usage of this row when the row
                                  has a format of its own, as the custom rows of
                                  a custom line item do: unit means a count,
                                  currency means an amount in cents. Null when
                                  the row reads its usage in the line item
                                  usageFormat.
                              amount:
                                type: number
                                description: >-
                                  Amount billed by this row, in cents. The sum
                                  of a line item's sub-line amounts equals its
                                  subtotalAmount.
                              metadata:
                                description: >-
                                  Pricing details of the row, keyed by the row
                                  type (and pricingType for overage rows).
                                anyOf:
                                  - type: object
                                    description: >-
                                      Fixed-price companion row: the charge's
                                      configured fixed amount, billed alongside
                                      the usage rows. Only rendered when
                                      configured greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_price
                                        description: >-
                                          Discriminator: fixed-price companion
                                          row.
                                      fixedPrice:
                                        type: number
                                        description: >-
                                          The fixed amount configured on the
                                          charge, in cents.
                                    required:
                                      - type
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Minimum-amount companion row: tops the
                                      charge up to its configured minimum when
                                      usage alone stays below it. Only rendered
                                      when the top-up is greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_amount
                                        description: >-
                                          Discriminator: minimum-amount companion
                                          row.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount configured on the
                                          charge, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up billed by this row to reach
                                          the configured minimum, in cents.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - type: object
                                    description: >-
                                      Flat-priced tier row: usage falling in
                                      this tier band is billed at a flat amount,
                                      regardless of the exact quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_flat
                                        description: 'Discriminator: flat-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      fixedPrice:
                                        type: string
                                        description: >-
                                          The flat amount billed for the tier, as
                                          a decimal currency-unit string.
                                        examples:
                                          - '150.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Per-unit priced tier row: units attributed
                                      to this tier band are billed at the tier's
                                      unit price.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_unit
                                        description: 'Discriminator: per-unit priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      price:
                                        type: string
                                        description: >-
                                          Price per unit within the tier, as a
                                          decimal currency-unit string.
                                        examples:
                                          - '0.25'
                                      fixedPrice:
                                        type: string
                                        nullable: true
                                        description: >-
                                          Optional flat fee billed on top when the
                                          tier applies, as a decimal currency-unit
                                          string. Null when the tier has no flat
                                          fee.
                                        examples:
                                          - '10.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - price
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Package-priced tier row: units attributed
                                      to this tier band are billed per started
                                      package of packageSize units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_package
                                        description: 'Discriminator: package-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string.
                                        examples:
                                          - '45.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - packageSize
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage-priced tier row: the monetary
                                      base amount attributed to this tier band
                                      is billed at a percentage.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_percentage
                                        description: >-
                                          Discriminator: percentage-priced tier
                                          row.
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                          Null for an unbounded final tier.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          within the tier, as a decimal string
                                          from 0 to 100 (up to 6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - percentage
                                  - type: object
                                    description: >-
                                      Proration interval row: for charges on
                                      prorated resources, each interval bills
                                      the usage held during it, priced as if
                                      held for the whole cycle and scaled by the
                                      interval's share of the cycle.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - proration
                                        description: 'Discriminator: proration interval row.'
                                      intervalSize:
                                        type: number
                                        description: >-
                                          Length of the interval, in days of the
                                          billing cycle.
                                      amount:
                                        type: string
                                        description: >-
                                          The prorated amount of the interval, as
                                          a decimal currency-unit string: the
                                          interval usage priced as if held for the
                                          whole cycle, scaled by intervalSize over
                                          the cycle length.
                                        examples:
                                          - '29.0322580645'
                                      usage:
                                        type: number
                                        description: The usage held during the interval.
                                      intervalStart:
                                        type: string
                                        format: date
                                        description: First day of the interval.
                                      intervalEnd:
                                        type: string
                                        format: date
                                        description: Last day of the interval.
                                    required:
                                      - type
                                      - intervalSize
                                      - amount
                                      - usage
                                      - intervalStart
                                      - intervalEnd
                                  - type: object
                                    description: >-
                                      License proration delta row: for per_unit
                                      license charges billing under the
                                      proration model, the cycle-start row bills
                                      the starting licenses beyond the included
                                      quantity at their full-cycle price, and
                                      each change row bills the change in those
                                      licenses prorated over the days remaining
                                      in the cycle. A change that stays inside
                                      the included quantity has no row. Tiered
                                      charges use license_proration_tier
                                      instead. quantityDelta and the row's
                                      amount are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration
                                        description: >-
                                          Discriminator: license proration delta
                                          row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on the cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the licenses beyond the
                                          included quantity (the starting licenses
                                          beyond it on the cycle-start row).
                                          Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity after this
                                          change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on
                                          the cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|. On a cycle-start row
                                          that bills no license, the unit price of
                                          the charge.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                  - type: object
                                    description: >-
                                      Tiered license proration delta row: one
                                      price band of a license charge billing
                                      under the proration model with
                                      tiered_per_unit pricing. The cycle-start
                                      rows bill each band's opening occupancy at
                                      its full-cycle unit price, and each change
                                      row bills that band's occupancy delta
                                      prorated over the days remaining in the
                                      cycle. quantityDelta and the row's amount
                                      are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration_tier
                                        description: >-
                                          Discriminator: tiered license proration
                                          delta row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on a cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the units this band
                                          holds (the band's opening occupancy on a
                                          cycle-start row). Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity across
                                          every band after this change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on a
                                          cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                      planChargeTierId:
                                        type: string
                                        description: >-
                                          The unique identifier of the plan charge
                                          tier this row moved through.
                                        examples:
                                          - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                      from:
                                        type: number
                                        description: >-
                                          Inclusive lower bound of the band, in
                                          licenses.
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Inclusive upper bound of the band, in
                                          licenses. Null on the last, open-ended
                                          band.
                                      unitPrice:
                                        type: string
                                        description: >-
                                          The band's full-cycle price per unit, as
                                          a decimal currency-unit string.
                                          proratedUnitRate is this scaled by
                                          remainingDays over cycleDays.
                                        examples:
                                          - '25.00'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                      - planChargeTierId
                                      - from
                                      - to
                                      - unitPrice
                                  - type: object
                                    description: >-
                                      Unit-price row: billable units multiplied
                                      by a single price per unit. The row's
                                      usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - unit_price
                                        description: 'Discriminator: unit-price row.'
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.25'
                                    required:
                                      - type
                                      - price
                                  - type: object
                                    description: >-
                                      Included-quantity row: the free allotment
                                      of the charge. The row's usage holds the
                                      units consumed within the allotment and
                                      its amount is always zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - included_quantity
                                        description: 'Discriminator: included-quantity row.'
                                      includedQuantity:
                                        type: number
                                        description: >-
                                          Number of resource units included at no
                                          charge before billing starts.
                                    required:
                                      - type
                                      - includedQuantity
                                  - type: object
                                    description: >-
                                      Package-price row: billable units charged
                                      per started package of packageSize units.
                                      The row's usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - package_price
                                        description: 'Discriminator: package-price row.'
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '45.00'
                                      packagesBilled:
                                        type: number
                                        description: >-
                                          Number of packages billed: the billable
                                          units divided by packageSize, rounded
                                          up.
                                    required:
                                      - type
                                      - packageSize
                                      - price
                                      - packagesBilled
                                  - type: object
                                    description: >-
                                      Percentage row: a percentage applied over
                                      a monetary base amount. The row's usage
                                      holds the base amount, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - percentage
                                        description: 'Discriminator: percentage row.'
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount,
                                          as a decimal string from 0 to 100 (up to
                                          6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - percentage
                                  - type: object
                                    description: >-
                                      Per-unit overage row: units beyond the
                                      last tier boundary, billed at the
                                      configured excess unit price. The row's
                                      usage holds the units over the boundary.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - per_unit
                                        description: 'Discriminator: overage billed per unit.'
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          resource units.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per excess unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage overage row: the monetary base
                                      amount beyond the last tier boundary,
                                      billed at the configured excess
                                      percentage. The row's usage holds the base
                                      amount over the boundary, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - percentage
                                        description: >-
                                          Discriminator: overage billed as a
                                          percentage.
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          cents of the monetary base amount.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the excess base
                                          amount, as a decimal string from 0 to
                                          100 (up to 6 decimal places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - percentage
                                  - type: object
                                    description: >-
                                      Original-amount row: surfaces the line
                                      item's pre-adjustment amount when the line
                                      has adjustments (e.g. a discount) but no
                                      price-component rows of its own. The row's
                                      amount equals the line item's
                                      subtotalAmount.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - original_amount
                                        description: 'Discriminator: original-amount row.'
                                    required:
                                      - type
                                  - type: object
                                    description: >-
                                      Fixed unit price row: the quantity of a
                                      fixed charge multiplied by its unit
                                      amount. The row's usage holds the
                                      quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_unit_price
                                        description: 'Discriminator: fixed unit price row.'
                                      amount:
                                        type: integer
                                        minimum: 0
                                        description: Amount of one unit, in cents.
                                    required:
                                      - type
                                      - amount
                                  - type: object
                                    description: >-
                                      Custom row: one component of a custom plan
                                      charge, as its calculator billed it. The
                                      row's name, description, usage,
                                      usageFormat and amount hold the rest of
                                      the component.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: 'Discriminator: custom row.'
                                      key:
                                        type: string
                                        description: >-
                                          The key of the component in the sub-line
                                          schema of the charge's custom charge
                                          definition, such as documents_overage.
                                        examples:
                                          - documents_overage
                                    required:
                                      - type
                                      - key
                            required:
                              - id
                              - type
                              - name
                              - description
                              - usage
                              - usageFormat
                              - amount
                              - metadata
                            additionalProperties: false
                          description: >-
                            Breakdown of the line item amount into priced rows
                            (included quantities, unit/package/tier prices,
                            prorations, companions). Empty for line items
                            without a breakdown.
                        adjustments:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing an adjustment applied on top
                              of a line item subtotal, such as a discount or an
                              allocation offset.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the adjustment in our
                                  system.
                              name:
                                type: string
                                description: >-
                                  Display name of the adjustment as it appears
                                  on the invoice.
                                example: Desconto de boas-vindas
                              type:
                                type: string
                                enum:
                                  - monetary_discount
                                  - allocation_offset
                                description: >-
                                  The kind of adjustment: monetary_discount (a
                                  discount applied to the line item) or
                                  allocation_offset (the share of the amount
                                  moved to another payment account's invoice
                                  under a split allocation strategy).
                              amount:
                                type: number
                                description: >-
                                  Amount of the adjustment, in cents. Negative
                                  when the adjustment reduces the line item
                                  total.
                            required:
                              - id
                              - name
                              - type
                              - amount
                            additionalProperties: false
                          description: >-
                            Adjustments applied on top of the line item
                            subtotal, such as discounts and allocation offsets.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - resourceId
                        - licenseId
                        - lineItemGroupId
                        - name
                        - scope
                        - startDate
                        - endDate
                        - totalUsage
                        - usageFormat
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - metadata
                        - subLineItems
                        - adjustments
                      additionalProperties: false
                    description: The line items contained in this group.
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - productId
                  - planId
                  - planInstanceId
                  - name
                  - startDate
                  - endDate
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - lineItems
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is not a one-off invoice,
            or it is locked, because it was issued or canceled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''startDate'' is required'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `invoiceId`.

            - `line_item_group_not_found`: no line item group of the invoice has
            the `lineItemGroupId`.

            - `product_not_found`: the `name` is null or left out, and no
            product has the `productId` of the line item group.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - line_item_group_not_found
                      - product_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                line_item_group_not_found:
                  value:
                    message: line item group not found on this invoice
                    code: line_item_group_not_found
                product_not_found:
                  value:
                    message: default product not found
                    code: product_not_found
    delete:
      summary: Delete invoice line item group
      tags:
        - Invoices
      description: >-
        Deletes a line item group from a one-off invoice. Deleting a group also
        deletes all line items (and their sub-items and adjustments) it
        contains.


        Requires the role `invoices:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice the group belongs to.
        - schema:
            type: string
            format: uuid
          in: path
          name: lineItemGroupId
          required: true
          description: The unique identifier of the line item group to delete.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: >-
            the invoice is not a one-off invoice, or it is locked, because it
            was issued or canceled
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - status: 404
          code: line_item_group_not_found
          when: no line item group of the invoice has the `lineItemGroupId`
      x-required-roles: *ref_8
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is not a one-off invoice,
            or it is locked, because it was issued or canceled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `invoiceId`.

            - `line_item_group_not_found`: no line item group of the invoice has
            the `lineItemGroupId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - line_item_group_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                line_item_group_not_found:
                  value:
                    message: line item group not found on this invoice
                    code: line_item_group_not_found
  /v1/invoices/{invoiceId}/line-items:
    post:
      summary: Create invoice line item
      tags:
        - Invoices
      description: >-
        Creates a line item on a one-off invoice, optionally with sub-line
        items. When sub-line items are provided, their amounts must sum to the
        line item amount.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                idempotencyKey:
                  type: string
                  minLength: 1
                  pattern: ^[a-zA-Z0-9_-]+$
                  description: >-
                    A unique idempotency key for this line item, scoped to the
                    invoice.
                  example: entrega-novembro
                productId:
                  type: string
                  format: uuid
                  description: >-
                    The unique identifier of the product this line item belongs
                    to.
                itemId:
                  type: string
                  format: uuid
                  description: >-
                    The unique identifier of the catalog item this line item
                    bills.
                name:
                  type: string
                  nullable: true
                  description: >-
                    Optional line item name; defaults to the item name (or
                    product name as fallback) when null.
                  example: Entregas
                startDate:
                  type: string
                  format: date
                  description: Start of the period covered by the line item.
                endDate:
                  type: string
                  format: date
                  description: End of the period covered by the line item.
                lineItemGroupId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    Optional line item group to attach this line item to. The
                    group must belong to the same invoice.
                amount:
                  type: number
                  description: Amount billed by the line item, in cents.
                subLineItems:
                  type: array
                  description: >-
                    Optional breakdown of the line item amount into sub-line
                    items. The sum of usage × price (rounded to whole cents per
                    row) must equal amount.
                  items:
                    type: object
                    properties:
                      usage:
                        type: number
                        multipleOf: 1
                        description: >-
                          Number of units billed by the sub-line item, as a
                          whole number.
                      price:
                        type: string
                        pattern: ^\d+(\.\d{1,6})?$
                        description: >-
                          Unit price as a decimal currency-unit string (up to 6
                          decimal places).
                        example: '2.50'
                    required:
                      - usage
                      - price
                    additionalProperties: false
                  default: []
              required:
                - idempotencyKey
                - productId
                - itemId
                - startDate
                - endDate
                - amount
              additionalProperties: false
        required: true
        description: >-
          Schema for creating a one-off line item on an existing one-off
          invoice. When subLineItems is provided, the sum of usage × price
          (rounded to whole cents per row) must equal amount.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice to add the line item to.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: >-
            the invoice is not a one-off invoice, or it is locked, because it
            was issued or canceled
        - status: 400
          code: line_item_amount_inconsistent
          when: >-
            the `subLineItems` are not empty, and the sum of their `usage` times
            `price`, rounded to cents on each row, differs from the `amount`
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - status: 404
          code: product_not_found
          when: >-
            the `name` is null or left out, no item has the `itemId`, and no
            product has the `productId`
        - status: 404
          code: line_item_group_not_found
          when: no line item group of the invoice has the `lineItemGroupId`
        - status: 409
          code: line_item_idempotency_key_conflict
          when: a line item of the invoice already has the `idempotencyKey`
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            One amount on an invoice, such as a plan charge, the contract
            minimum, a tax gross-up (the withheld ISS, the municipal service
            tax, added on top), a one-off amount or an additional charge.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the line item in our system.
                  idempotencyKey:
                    type: string
                    description: >-
                      A unique key that identifies the line item within the
                      invoice. Supplied by the caller for one-off line items;
                      generated by the billing engine otherwise.
                    example: entrega-novembro
                  customerId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the customer whose consumption
                      this line item bills. On split or consolidated invoices it
                      may be a subsidiary of the invoice's customer.
                  productId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the product this line item
                      belongs to.
                  itemId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the catalog item this line bills.
                      Null for line items not backed by a catalog item.
                  resourceId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the metered resource behind a
                      usage_based line item. Null for line items not driven by
                      resource usage.
                  licenseId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the license behind a
                      license_based line item. Null for line items not driven by
                      a license count.
                  lineItemGroupId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the line item group containing
                      this line item. Null for standalone line items.
                  name:
                    type: string
                    description: >-
                      Display name of the line item as it appears on the
                      invoice.
                    example: Entregas
                  scope:
                    type: string
                    enum:
                      - credit_purchase
                      - contract_minimum_commitment
                      - minimum_commitment
                      - fixed
                      - usage_based
                      - license_based
                      - custom
                      - additional_charge
                      - one_off
                      - tax_gross_up
                    description: >-
                      What the line item charges for: usage_based (metered
                      resource consumption), license_based (a license's reported
                      count billed in full), fixed (recurring fixed charge of a
                      plan), custom (custom plan charge, priced by a calculator
                      that Aira writes for you), minimum_commitment (plan-level
                      minimum top-up), contract_minimum_commitment
                      (contract-level minimum top-up), credit_purchase (credit
                      pool top-up), additional_charge (extra charge added
                      manually), one_off (line item of a one-off invoice), or
                      tax_gross_up (tax gross-up charge).
                  startDate:
                    type: string
                    format: date
                    description: Start of the period covered by this line item.
                  endDate:
                    type: string
                    format: date
                    description: End of the period covered by this line item.
                  totalUsage:
                    type: number
                    nullable: true
                    description: >-
                      Total usage billed by the line item, in the unit given by
                      usageFormat. Null for line items without a single usage
                      (e.g. fixed charges without a quantity, and custom line
                      items whose calculator returns no total).
                  usageFormat:
                    type: string
                    enum:
                      - unit
                      - currency
                      - null
                    nullable: true
                    description: >-
                      How to read totalUsage, and the usage of each sub-line
                      item that has no usageFormat of its own: unit means a
                      count of resource units or a fixed charge quantity;
                      currency means a monetary base amount in cents. Null when
                      the line item has no single usage, as a custom line item
                      whose sub-line items bill different kinds of volume, each
                      with its own usageFormat.
                  subtotalAmount:
                    type: number
                    description: >-
                      Line item amount before adjustments, in cents (sum of its
                      sub-line item amounts).
                  adjustmentAmount:
                    type: number
                    description: >-
                      Net amount of the adjustments applied to this line item
                      (discounts and allocation offsets), in cents. Negative
                      when adjustments reduce the amount owed.
                  totalAmount:
                    type: number
                    description: >-
                      Final line item amount, in cents: subtotalAmount +
                      adjustmentAmount.
                  discountAmount:
                    type: number
                    description: >-
                      The discount portion of adjustmentAmount, in cents (sum of
                      monetary discount adjustments only). Negative when
                      discounts were applied.
                  metadata:
                    description: >-
                      Pricing metadata for the line item, where the shape is
                      keyed by type. Always present, but null for line items
                      without pricing metadata: credit_purchase,
                      additional_charge, one_off, and tax_gross_up. It is
                      populated for fixed (the billing timing), usage_based,
                      license_based, minimum_commitment,
                      contract_minimum_commitment, and custom (the definition
                      and the calculation memory) line items.
                    anyOf:
                      - title: Fixed
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - fixed
                            description: 'Discriminator: metadata for a fixed line item.'
                          billingTiming:
                            type: string
                            enum:
                              - in_advance
                              - in_arrears
                            description: >-
                              Whether the fee was billed in advance of its
                              service period or after it.
                        required:
                          - type
                          - billingTiming
                      - title: Usage-based
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - usage_based
                            description: >-
                              Discriminator: metadata for a usage_based line
                              item.
                          billingModel:
                            type: string
                            enum:
                              - in_full
                              - proration
                            description: >-
                              How the metered resource accrues over the billing
                              period: in_full bills the full usage of the
                              period; proration weighs usage by the fraction of
                              the period each amount was held.
                          priceTierDivision:
                            type: string
                            enum:
                              - unique_tier
                              - progressive
                            description: >-
                              For tier-based pricing models only: how usage was
                              divided across tiers. unique_tier prices all usage
                              at the single tier that contains the total;
                              progressive prices each tier's band separately.
                              Absent for non-tiered models.
                          pricingModel:
                            type: string
                            enum:
                              - fixed
                              - per_unit
                              - per_package
                              - percentage
                              - tiered_per_unit
                              - tiered_percentage
                              - tiered_fixed
                              - advanced
                              - custom
                            description: >-
                              The pricing model of the plan charge that produced
                              this line item. Charges priced before pricing
                              models existed are reported as advanced.
                        required:
                          - type
                          - billingModel
                          - pricingModel
                      - title: License-based
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - license_based
                            description: >-
                              Discriminator: metadata for a license_based line
                              item.
                          billingModel:
                            type: string
                            enum:
                              - in_full
                              - proration
                            description: >-
                              How the license count accrues over the billing
                              period. Always in_full: the latest reported count
                              is billed in full.
                          priceTierDivision:
                            type: string
                            enum:
                              - unique_tier
                              - progressive
                            description: >-
                              For tier-based pricing models only: how the
                              license count was divided across tiers.
                              unique_tier prices the whole count at the single
                              tier that contains the total; progressive prices
                              each tier's band separately. Absent for non-tiered
                              models.
                          pricingModel:
                            type: string
                            enum:
                              - fixed
                              - per_unit
                              - per_package
                              - percentage
                              - tiered_per_unit
                              - tiered_percentage
                              - tiered_fixed
                              - advanced
                              - custom
                            description: >-
                              The pricing model of the plan charge that produced
                              this line item.
                        required:
                          - type
                          - billingModel
                          - pricingModel
                      - title: Contract minimum commitment
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - contract_minimum_commitment
                            description: >-
                              Discriminator: metadata for a
                              contract_minimum_commitment line item.
                          minimumAmount:
                            type: number
                            description: >-
                              The minimum amount committed for the whole
                              contract in the billing period, in cents.
                          minimumAmountApplied:
                            type: number
                            description: >-
                              The top-up charged by this line item to reach the
                              committed minimum, in cents: the difference
                              between minimumAmount and what the contract's
                              consumption amounted to.
                        required:
                          - type
                          - minimumAmount
                          - minimumAmountApplied
                      - title: Minimum commitment
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - minimum_commitment
                            description: >-
                              Discriminator: metadata for a plan-level
                              minimum_commitment line item.
                          minimumAmount:
                            type: number
                            description: >-
                              The minimum amount committed for the plan in the
                              billing period, in cents.
                          minimumAmountApplied:
                            type: number
                            description: >-
                              The top-up charged by this line item to reach the
                              committed minimum, in cents: the difference
                              between minimumAmount and what the plan's
                              consumption amounted to.
                        required:
                          - type
                          - minimumAmount
                          - minimumAmountApplied
                      - title: Custom
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - custom
                            description: 'Discriminator: metadata for a custom line item.'
                          definitionKey:
                            type: string
                            description: >-
                              The key of the custom charge definition whose
                              calculator priced the charge, following the
                              custom:charge:<slug>:<name> convention.
                            examples:
                              - custom:charge:padaria-central:entregas
                          memory:
                            type: object
                            additionalProperties: true
                            description: >-
                              The full calculation memory that the calculator
                              returned, such as every tier it evaluated and the
                              one it billed. Its shape belongs to the
                              definition.
                        required:
                          - type
                          - definitionKey
                          - memory
                      - title: No metadata
                        type: 'null'
                  subLineItems:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a sub-line item: one priced row of a
                        line item's breakdown. The row type dictates the shape
                        of metadata.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the sub-line item in our
                            system.
                        type:
                          type: string
                          enum:
                            - fixed_price
                            - minimum_amount
                            - price_tier_flat
                            - price_tier_unit
                            - price_tier_package
                            - price_tier_percentage
                            - proration
                            - license_proration
                            - license_proration_tier
                            - unit_price
                            - included_quantity
                            - package_price
                            - percentage
                            - overage
                            - original_amount
                            - fixed_unit_price
                            - custom
                          description: >-
                            The kind of priced row: fixed_price and
                            minimum_amount are companions of usage-based
                            charges; unit_price, package_price, percentage, and
                            included_quantity break down single-model pricing;
                            price_tier_* rows break down tiered pricing; overage
                            bills usage beyond the last tier; proration bills
                            per prorated interval; license_proration bills
                            license deltas (removals are negative);
                            original_amount surfaces the pre-adjustment amount
                            of an adjusted line; fixed_unit_price breaks down a
                            fixed charge billed as a quantity times a unit
                            amount; custom bills one component of a custom plan
                            charge.
                        name:
                          type: string
                          description: >-
                            Display name of the sub-line item as it appears on
                            the invoice breakdown.
                          example: '[A partir de 1] Unidades'
                        description:
                          type: string
                          nullable: true
                          description: >-
                            Optional descriptive text for the row. Null when
                            absent.
                          example: 120 x 2,50
                        usage:
                          type: number
                          nullable: true
                          description: >-
                            The usage billed by this row: a count of resource
                            units (the quantity for a fixed_unit_price row), or
                            a monetary base amount in cents for
                            percentage-priced rows (see the row's usageFormat,
                            or the line item usageFormat when the row has none).
                            Null for rows without usage (e.g. companions).
                        usageFormat:
                          type: string
                          enum:
                            - unit
                            - currency
                            - null
                          nullable: true
                          description: >-
                            How to read the usage of this row when the row has a
                            format of its own, as the custom rows of a custom
                            line item do: unit means a count, currency means an
                            amount in cents. Null when the row reads its usage
                            in the line item usageFormat.
                        amount:
                          type: number
                          description: >-
                            Amount billed by this row, in cents. The sum of a
                            line item's sub-line amounts equals its
                            subtotalAmount.
                        metadata:
                          description: >-
                            Pricing details of the row, keyed by the row type
                            (and pricingType for overage rows).
                          anyOf:
                            - type: object
                              description: >-
                                Fixed-price companion row: the charge's
                                configured fixed amount, billed alongside the
                                usage rows. Only rendered when configured
                                greater than zero.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed_price
                                  description: 'Discriminator: fixed-price companion row.'
                                fixedPrice:
                                  type: number
                                  description: >-
                                    The fixed amount configured on the charge,
                                    in cents.
                              required:
                                - type
                                - fixedPrice
                            - type: object
                              description: >-
                                Minimum-amount companion row: tops the charge up
                                to its configured minimum when usage alone stays
                                below it. Only rendered when the top-up is
                                greater than zero.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_amount
                                  description: 'Discriminator: minimum-amount companion row.'
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount configured on the charge,
                                    in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up billed by this row to reach the
                                    configured minimum, in cents.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - type: object
                              description: >-
                                Flat-priced tier row: usage falling in this tier
                                band is billed at a flat amount, regardless of
                                the exact quantity.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - price_tier_flat
                                  description: 'Discriminator: flat-priced tier row.'
                                from:
                                  type: number
                                  description: >-
                                    Lower bound of the tier band, in resource
                                    units (inclusive).
                                to:
                                  type: number
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band, in resource
                                    units (inclusive). Null for an unbounded
                                    final tier.
                                fixedPrice:
                                  type: string
                                  description: >-
                                    The flat amount billed for the tier, as a
                                    decimal currency-unit string.
                                  examples:
                                    - '150.00'
                              required:
                                - type
                                - from
                                - to
                                - fixedPrice
                            - type: object
                              description: >-
                                Per-unit priced tier row: units attributed to
                                this tier band are billed at the tier's unit
                                price.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - price_tier_unit
                                  description: 'Discriminator: per-unit priced tier row.'
                                from:
                                  type: number
                                  description: >-
                                    Lower bound of the tier band, in resource
                                    units (inclusive).
                                to:
                                  type: number
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band, in resource
                                    units (inclusive). Null for an unbounded
                                    final tier.
                                price:
                                  type: string
                                  description: >-
                                    Price per unit within the tier, as a decimal
                                    currency-unit string.
                                  examples:
                                    - '0.25'
                                fixedPrice:
                                  type: string
                                  nullable: true
                                  description: >-
                                    Optional flat fee billed on top when the
                                    tier applies, as a decimal currency-unit
                                    string. Null when the tier has no flat fee.
                                  examples:
                                    - '10.00'
                              required:
                                - type
                                - from
                                - to
                                - price
                                - fixedPrice
                            - type: object
                              description: >-
                                Package-priced tier row: units attributed to
                                this tier band are billed per started package of
                                packageSize units.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - price_tier_package
                                  description: 'Discriminator: package-priced tier row.'
                                from:
                                  type: number
                                  description: >-
                                    Lower bound of the tier band, in resource
                                    units (inclusive).
                                to:
                                  type: number
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band, in resource
                                    units (inclusive). Null for an unbounded
                                    final tier.
                                packageSize:
                                  type: number
                                  description: Number of resource units per package.
                                price:
                                  type: string
                                  description: >-
                                    Price per package, as a decimal
                                    currency-unit string.
                                  examples:
                                    - '45.00'
                              required:
                                - type
                                - from
                                - to
                                - packageSize
                                - price
                            - type: object
                              description: >-
                                Percentage-priced tier row: the monetary base
                                amount attributed to this tier band is billed at
                                a percentage.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - price_tier_percentage
                                  description: 'Discriminator: percentage-priced tier row.'
                                from:
                                  type: number
                                  description: >-
                                    Lower bound of the tier band, in cents of
                                    the monetary base amount (inclusive).
                                to:
                                  type: number
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band, in cents of
                                    the monetary base amount (inclusive). Null
                                    for an unbounded final tier.
                                percentage:
                                  type: string
                                  pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                  description: >-
                                    Percentage applied to the base amount within
                                    the tier, as a decimal string from 0 to 100
                                    (up to 6 decimal places).
                                  examples:
                                    - '2.5'
                              required:
                                - type
                                - from
                                - to
                                - percentage
                            - type: object
                              description: >-
                                Proration interval row: for charges on prorated
                                resources, each interval bills the usage held
                                during it, priced as if held for the whole cycle
                                and scaled by the interval's share of the cycle.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - proration
                                  description: 'Discriminator: proration interval row.'
                                intervalSize:
                                  type: number
                                  description: >-
                                    Length of the interval, in days of the
                                    billing cycle.
                                amount:
                                  type: string
                                  description: >-
                                    The prorated amount of the interval, as a
                                    decimal currency-unit string: the interval
                                    usage priced as if held for the whole cycle,
                                    scaled by intervalSize over the cycle
                                    length.
                                  examples:
                                    - '29.0322580645'
                                usage:
                                  type: number
                                  description: The usage held during the interval.
                                intervalStart:
                                  type: string
                                  format: date
                                  description: First day of the interval.
                                intervalEnd:
                                  type: string
                                  format: date
                                  description: Last day of the interval.
                              required:
                                - type
                                - intervalSize
                                - amount
                                - usage
                                - intervalStart
                                - intervalEnd
                            - type: object
                              description: >-
                                License proration delta row: for per_unit
                                license charges billing under the proration
                                model, the cycle-start row bills the starting
                                licenses beyond the included quantity at their
                                full-cycle price, and each change row bills the
                                change in those licenses prorated over the days
                                remaining in the cycle. A change that stays
                                inside the included quantity has no row. Tiered
                                charges use license_proration_tier instead.
                                quantityDelta and the row's amount are signed —
                                removals are negative.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_proration
                                  description: 'Discriminator: license proration delta row.'
                                changeDate:
                                  type: string
                                  format: date
                                  nullable: true
                                  description: >-
                                    The day the combined license quantity
                                    changed. Null on the cycle-start row.
                                quantityDelta:
                                  type: number
                                  description: >-
                                    Signed change in the licenses beyond the
                                    included quantity (the starting licenses
                                    beyond it on the cycle-start row). Negative
                                    for removals.
                                quantity:
                                  type: number
                                  description: >-
                                    The combined license quantity after this
                                    change.
                                remainingDays:
                                  type: number
                                  description: >-
                                    Days from the change (inclusive) to the end
                                    of the cycle. Equals cycleDays on the
                                    cycle-start row.
                                cycleDays:
                                  type: number
                                  description: Length of the billing cycle, in days.
                                proratedUnitRate:
                                  type: string
                                  description: >-
                                    Absolute effective per-unit rate of the row
                                    over the remaining window, as a decimal
                                    currency-unit string: |amount| /
                                    |quantityDelta|. On a cycle-start row that
                                    bills no license, the unit price of the
                                    charge.
                                  examples:
                                    - '16.1290322581'
                                amount:
                                  type: string
                                  description: >-
                                    The signed prorated amount of the row, as a
                                    decimal currency-unit string.
                                  examples:
                                    - '48.3870967742'
                              required:
                                - type
                                - changeDate
                                - quantityDelta
                                - quantity
                                - remainingDays
                                - cycleDays
                                - proratedUnitRate
                                - amount
                            - type: object
                              description: >-
                                Tiered license proration delta row: one price
                                band of a license charge billing under the
                                proration model with tiered_per_unit pricing.
                                The cycle-start rows bill each band's opening
                                occupancy at its full-cycle unit price, and each
                                change row bills that band's occupancy delta
                                prorated over the days remaining in the cycle.
                                quantityDelta and the row's amount are signed —
                                removals are negative.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_proration_tier
                                  description: >-
                                    Discriminator: tiered license proration
                                    delta row.
                                changeDate:
                                  type: string
                                  format: date
                                  nullable: true
                                  description: >-
                                    The day the combined license quantity
                                    changed. Null on a cycle-start row.
                                quantityDelta:
                                  type: number
                                  description: >-
                                    Signed change in the units this band holds
                                    (the band's opening occupancy on a
                                    cycle-start row). Negative for removals.
                                quantity:
                                  type: number
                                  description: >-
                                    The combined license quantity across every
                                    band after this change.
                                remainingDays:
                                  type: number
                                  description: >-
                                    Days from the change (inclusive) to the end
                                    of the cycle. Equals cycleDays on a
                                    cycle-start row.
                                cycleDays:
                                  type: number
                                  description: Length of the billing cycle, in days.
                                proratedUnitRate:
                                  type: string
                                  description: >-
                                    Absolute effective per-unit rate of the row
                                    over the remaining window, as a decimal
                                    currency-unit string: |amount| /
                                    |quantityDelta|.
                                  examples:
                                    - '16.1290322581'
                                amount:
                                  type: string
                                  description: >-
                                    The signed prorated amount of the row, as a
                                    decimal currency-unit string.
                                  examples:
                                    - '48.3870967742'
                                planChargeTierId:
                                  type: string
                                  description: >-
                                    The unique identifier of the plan charge
                                    tier this row moved through.
                                  examples:
                                    - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                from:
                                  type: number
                                  description: >-
                                    Inclusive lower bound of the band, in
                                    licenses.
                                to:
                                  type: number
                                  nullable: true
                                  description: >-
                                    Inclusive upper bound of the band, in
                                    licenses. Null on the last, open-ended band.
                                unitPrice:
                                  type: string
                                  description: >-
                                    The band's full-cycle price per unit, as a
                                    decimal currency-unit string.
                                    proratedUnitRate is this scaled by
                                    remainingDays over cycleDays.
                                  examples:
                                    - '25.00'
                              required:
                                - type
                                - changeDate
                                - quantityDelta
                                - quantity
                                - remainingDays
                                - cycleDays
                                - proratedUnitRate
                                - amount
                                - planChargeTierId
                                - from
                                - to
                                - unitPrice
                            - type: object
                              description: >-
                                Unit-price row: billable units multiplied by a
                                single price per unit. The row's usage holds the
                                billable units.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - unit_price
                                  description: 'Discriminator: unit-price row.'
                                price:
                                  type: string
                                  pattern: ^\d+(\.\d{1,6})?$
                                  description: >-
                                    Price per unit, as a decimal currency-unit
                                    string (up to 6 decimal places).
                                  examples:
                                    - '0.25'
                              required:
                                - type
                                - price
                            - type: object
                              description: >-
                                Included-quantity row: the free allotment of the
                                charge. The row's usage holds the units consumed
                                within the allotment and its amount is always
                                zero.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - included_quantity
                                  description: 'Discriminator: included-quantity row.'
                                includedQuantity:
                                  type: number
                                  description: >-
                                    Number of resource units included at no
                                    charge before billing starts.
                              required:
                                - type
                                - includedQuantity
                            - type: object
                              description: >-
                                Package-price row: billable units charged per
                                started package of packageSize units. The row's
                                usage holds the billable units.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - package_price
                                  description: 'Discriminator: package-price row.'
                                packageSize:
                                  type: number
                                  description: Number of resource units per package.
                                price:
                                  type: string
                                  pattern: ^\d+(\.\d{1,6})?$
                                  description: >-
                                    Price per package, as a decimal
                                    currency-unit string (up to 6 decimal
                                    places).
                                  examples:
                                    - '45.00'
                                packagesBilled:
                                  type: number
                                  description: >-
                                    Number of packages billed: the billable
                                    units divided by packageSize, rounded up.
                              required:
                                - type
                                - packageSize
                                - price
                                - packagesBilled
                            - type: object
                              description: >-
                                Percentage row: a percentage applied over a
                                monetary base amount. The row's usage holds the
                                base amount, in cents.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - percentage
                                  description: 'Discriminator: percentage row.'
                                percentage:
                                  type: string
                                  pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                  description: >-
                                    Percentage applied to the base amount, as a
                                    decimal string from 0 to 100 (up to 6
                                    decimal places).
                                  examples:
                                    - '2.5'
                              required:
                                - type
                                - percentage
                            - type: object
                              description: >-
                                Per-unit overage row: units beyond the last tier
                                boundary, billed at the configured excess unit
                                price. The row's usage holds the units over the
                                boundary.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - overage
                                  description: 'Discriminator: overage row.'
                                pricingType:
                                  type: string
                                  enum:
                                    - per_unit
                                  description: 'Discriminator: overage billed per unit.'
                                from:
                                  type: number
                                  description: >-
                                    The boundary the overage starts from: the
                                    upper bound of the last tier, in resource
                                    units.
                                price:
                                  type: string
                                  pattern: ^\d+(\.\d{1,6})?$
                                  description: >-
                                    Price per excess unit, as a decimal
                                    currency-unit string (up to 6 decimal
                                    places).
                                  examples:
                                    - '0.30'
                              required:
                                - type
                                - pricingType
                                - from
                                - price
                            - type: object
                              description: >-
                                Percentage overage row: the monetary base amount
                                beyond the last tier boundary, billed at the
                                configured excess percentage. The row's usage
                                holds the base amount over the boundary, in
                                cents.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - overage
                                  description: 'Discriminator: overage row.'
                                pricingType:
                                  type: string
                                  enum:
                                    - percentage
                                  description: >-
                                    Discriminator: overage billed as a
                                    percentage.
                                from:
                                  type: number
                                  description: >-
                                    The boundary the overage starts from: the
                                    upper bound of the last tier, in cents of
                                    the monetary base amount.
                                percentage:
                                  type: string
                                  pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                  description: >-
                                    Percentage applied to the excess base
                                    amount, as a decimal string from 0 to 100
                                    (up to 6 decimal places).
                                  examples:
                                    - '1.5'
                              required:
                                - type
                                - pricingType
                                - from
                                - percentage
                            - type: object
                              description: >-
                                Original-amount row: surfaces the line item's
                                pre-adjustment amount when the line has
                                adjustments (e.g. a discount) but no
                                price-component rows of its own. The row's
                                amount equals the line item's subtotalAmount.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - original_amount
                                  description: 'Discriminator: original-amount row.'
                              required:
                                - type
                            - type: object
                              description: >-
                                Fixed unit price row: the quantity of a fixed
                                charge multiplied by its unit amount. The row's
                                usage holds the quantity.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed_unit_price
                                  description: 'Discriminator: fixed unit price row.'
                                amount:
                                  type: integer
                                  minimum: 0
                                  description: Amount of one unit, in cents.
                              required:
                                - type
                                - amount
                            - type: object
                              description: >-
                                Custom row: one component of a custom plan
                                charge, as its calculator billed it. The row's
                                name, description, usage, usageFormat and amount
                                hold the rest of the component.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - custom
                                  description: 'Discriminator: custom row.'
                                key:
                                  type: string
                                  description: >-
                                    The key of the component in the sub-line
                                    schema of the charge's custom charge
                                    definition, such as documents_overage.
                                  examples:
                                    - documents_overage
                              required:
                                - type
                                - key
                      required:
                        - id
                        - type
                        - name
                        - description
                        - usage
                        - usageFormat
                        - amount
                        - metadata
                      additionalProperties: false
                    description: >-
                      Breakdown of the line item amount into priced rows
                      (included quantities, unit/package/tier prices,
                      prorations, companions). Empty for line items without a
                      breakdown.
                  adjustments:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing an adjustment applied on top of a
                        line item subtotal, such as a discount or an allocation
                        offset.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the adjustment in our
                            system.
                        name:
                          type: string
                          description: >-
                            Display name of the adjustment as it appears on the
                            invoice.
                          example: Desconto de boas-vindas
                        type:
                          type: string
                          enum:
                            - monetary_discount
                            - allocation_offset
                          description: >-
                            The kind of adjustment: monetary_discount (a
                            discount applied to the line item) or
                            allocation_offset (the share of the amount moved to
                            another payment account's invoice under a split
                            allocation strategy).
                        amount:
                          type: number
                          description: >-
                            Amount of the adjustment, in cents. Negative when
                            the adjustment reduces the line item total.
                      required:
                        - id
                        - name
                        - type
                        - amount
                      additionalProperties: false
                    description: >-
                      Adjustments applied on top of the line item subtotal, such
                      as discounts and allocation offsets.
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - productId
                  - resourceId
                  - licenseId
                  - lineItemGroupId
                  - name
                  - scope
                  - startDate
                  - endDate
                  - totalUsage
                  - usageFormat
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - metadata
                  - subLineItems
                  - adjustments
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is not a one-off invoice,
            or it is locked, because it was issued or canceled.

            - `line_item_amount_inconsistent`: the `subLineItems` are not empty,
            and the sum of their `usage` times `price`, rounded to cents on each
            row, differs from the `amount`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                      - line_item_amount_inconsistent
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''idempotencyKey'' is required'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
                line_item_amount_inconsistent:
                  value:
                    message: >-
                      sum of subLineItems usage x price (in rounded cents) must
                      equal amount
                    code: line_item_amount_inconsistent
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `invoiceId`.

            - `product_not_found`: the `name` is null or left out, no item has
            the `itemId`, and no product has the `productId`.

            - `line_item_group_not_found`: no line item group of the invoice has
            the `lineItemGroupId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - product_not_found
                      - line_item_group_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                product_not_found:
                  value:
                    message: default product not found
                    code: product_not_found
                line_item_group_not_found:
                  value:
                    message: line item group not found on this invoice
                    code: line_item_group_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `line_item_idempotency_key_conflict`: a line item of the invoice
            already has the `idempotencyKey`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - line_item_idempotency_key_conflict
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                line_item_idempotency_key_conflict:
                  value:
                    message: >-
                      line item with this idempotency key already exists for
                      this invoice
                    code: line_item_idempotency_key_conflict
  /v1/invoices/{invoiceId}/line-items/{lineItemId}:
    put:
      summary: Update invoice line item
      tags:
        - Invoices
      description: >-
        Updates a line item on a one-off invoice. When subLineItems is provided,
        the existing sub-line items are replaced.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  nullable: true
                  description: >-
                    Optional line item name; defaults to the item name (or
                    product name as fallback) when null.
                  example: Entregas
                startDate:
                  type: string
                  format: date
                  description: Start of the period covered by the line item.
                endDate:
                  type: string
                  format: date
                  description: End of the period covered by the line item.
                amount:
                  type: number
                  description: Amount billed by the line item, in cents.
                subLineItems:
                  type: array
                  description: >-
                    When provided, existing sub-items are replaced. When
                    non-empty, the sum of usage × price (rounded to whole cents
                    per row) must equal amount. When empty, the line item keeps
                    no sub-items, except that a line item with an adjustment
                    gets a derived original_amount sub-item carrying amount.
                  items:
                    type: object
                    properties:
                      usage:
                        type: number
                        multipleOf: 1
                        description: >-
                          Number of units billed by the sub-line item, as a
                          whole number.
                      price:
                        type: string
                        pattern: ^\d+(\.\d{1,6})?$
                        description: >-
                          Unit price as a decimal currency-unit string (up to 6
                          decimal places).
                        example: '2.50'
                    required:
                      - usage
                      - price
                    additionalProperties: false
              required:
                - startDate
                - endDate
                - amount
              additionalProperties: false
        required: true
        description: >-
          Schema for updating a line item on a one-off invoice. When
          subLineItems is provided, existing sub-items are replaced, and when it
          is non-empty, the sum of usage × price (rounded to whole cents per
          row) must equal amount. When subLineItems is omitted, the sub-items
          other than original_amount, which Aira derives from amount, are left
          untouched, and amount must equal their sum when the line item has any.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice the line item belongs to.
        - schema:
            type: string
            format: uuid
          in: path
          name: lineItemId
          required: true
          description: The unique identifier of the line item to update.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: >-
            the invoice is not a one-off invoice, or it is locked, because it
            was issued or canceled
        - status: 400
          code: line_item_amount_inconsistent
          when: >-
            the `subLineItems` are not empty, and the sum of their `usage` times
            `price`, rounded to cents on each row, differs from the `amount`
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - status: 404
          code: line_item_not_found
          when: no line item of the invoice has the `lineItemId`
        - status: 409
          code: line_item_amount_inconsistent
          when: >-
            the body leaves `subLineItems` out, and the `amount` differs from
            the sum of the sub-line items that the line item keeps
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            One amount on an invoice, such as a plan charge, the contract
            minimum, a tax gross-up (the withheld ISS, the municipal service
            tax, added on top), a one-off amount or an additional charge.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the line item in our system.
                  idempotencyKey:
                    type: string
                    description: >-
                      A unique key that identifies the line item within the
                      invoice. Supplied by the caller for one-off line items;
                      generated by the billing engine otherwise.
                    example: entrega-novembro
                  customerId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the customer whose consumption
                      this line item bills. On split or consolidated invoices it
                      may be a subsidiary of the invoice's customer.
                  productId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the product this line item
                      belongs to.
                  itemId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the catalog item this line bills.
                      Null for line items not backed by a catalog item.
                  resourceId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the metered resource behind a
                      usage_based line item. Null for line items not driven by
                      resource usage.
                  licenseId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the license behind a
                      license_based line item. Null for line items not driven by
                      a license count.
                  lineItemGroupId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the line item group containing
                      this line item. Null for standalone line items.
                  name:
                    type: string
                    description: >-
                      Display name of the line item as it appears on the
                      invoice.
                    example: Entregas
                  scope:
                    type: string
                    enum:
                      - credit_purchase
                      - contract_minimum_commitment
                      - minimum_commitment
                      - fixed
                      - usage_based
                      - license_based
                      - custom
                      - additional_charge
                      - one_off
                      - tax_gross_up
                    description: >-
                      What the line item charges for: usage_based (metered
                      resource consumption), license_based (a license's reported
                      count billed in full), fixed (recurring fixed charge of a
                      plan), custom (custom plan charge, priced by a calculator
                      that Aira writes for you), minimum_commitment (plan-level
                      minimum top-up), contract_minimum_commitment
                      (contract-level minimum top-up), credit_purchase (credit
                      pool top-up), additional_charge (extra charge added
                      manually), one_off (line item of a one-off invoice), or
                      tax_gross_up (tax gross-up charge).
                  startDate:
                    type: string
                    format: date
                    description: Start of the period covered by this line item.
                  endDate:
                    type: string
                    format: date
                    description: End of the period covered by this line item.
                  totalUsage:
                    type: number
                    nullable: true
                    description: >-
                      Total usage billed by the line item, in the unit given by
                      usageFormat. Null for line items without a single usage
                      (e.g. fixed charges without a quantity, and custom line
                      items whose calculator returns no total).
                  usageFormat:
                    type: string
                    enum:
                      - unit
                      - currency
                      - null
                    nullable: true
                    description: >-
                      How to read totalUsage, and the usage of each sub-line
                      item that has no usageFormat of its own: unit means a
                      count of resource units or a fixed charge quantity;
                      currency means a monetary base amount in cents. Null when
                      the line item has no single usage, as a custom line item
                      whose sub-line items bill different kinds of volume, each
                      with its own usageFormat.
                  subtotalAmount:
                    type: number
                    description: >-
                      Line item amount before adjustments, in cents (sum of its
                      sub-line item amounts).
                  adjustmentAmount:
                    type: number
                    description: >-
                      Net amount of the adjustments applied to this line item
                      (discounts and allocation offsets), in cents. Negative
                      when adjustments reduce the amount owed.
                  totalAmount:
                    type: number
                    description: >-
                      Final line item amount, in cents: subtotalAmount +
                      adjustmentAmount.
                  discountAmount:
                    type: number
                    description: >-
                      The discount portion of adjustmentAmount, in cents (sum of
                      monetary discount adjustments only). Negative when
                      discounts were applied.
                  metadata:
                    description: >-
                      Pricing metadata for the line item, where the shape is
                      keyed by type. Always present, but null for line items
                      without pricing metadata: credit_purchase,
                      additional_charge, one_off, and tax_gross_up. It is
                      populated for fixed (the billing timing), usage_based,
                      license_based, minimum_commitment,
                      contract_minimum_commitment, and custom (the definition
                      and the calculation memory) line items.
                    anyOf:
                      - title: Fixed
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - fixed
                            description: 'Discriminator: metadata for a fixed line item.'
                          billingTiming:
                            type: string
                            enum:
                              - in_advance
                              - in_arrears
                            description: >-
                              Whether the fee was billed in advance of its
                              service period or after it.
                        required:
                          - type
                          - billingTiming
                      - title: Usage-based
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - usage_based
                            description: >-
                              Discriminator: metadata for a usage_based line
                              item.
                          billingModel:
                            type: string
                            enum:
                              - in_full
                              - proration
                            description: >-
                              How the metered resource accrues over the billing
                              period: in_full bills the full usage of the
                              period; proration weighs usage by the fraction of
                              the period each amount was held.
                          priceTierDivision:
                            type: string
                            enum:
                              - unique_tier
                              - progressive
                            description: >-
                              For tier-based pricing models only: how usage was
                              divided across tiers. unique_tier prices all usage
                              at the single tier that contains the total;
                              progressive prices each tier's band separately.
                              Absent for non-tiered models.
                          pricingModel:
                            type: string
                            enum:
                              - fixed
                              - per_unit
                              - per_package
                              - percentage
                              - tiered_per_unit
                              - tiered_percentage
                              - tiered_fixed
                              - advanced
                              - custom
                            description: >-
                              The pricing model of the plan charge that produced
                              this line item. Charges priced before pricing
                              models existed are reported as advanced.
                        required:
                          - type
                          - billingModel
                          - pricingModel
                      - title: License-based
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - license_based
                            description: >-
                              Discriminator: metadata for a license_based line
                              item.
                          billingModel:
                            type: string
                            enum:
                              - in_full
                              - proration
                            description: >-
                              How the license count accrues over the billing
                              period. Always in_full: the latest reported count
                              is billed in full.
                          priceTierDivision:
                            type: string
                            enum:
                              - unique_tier
                              - progressive
                            description: >-
                              For tier-based pricing models only: how the
                              license count was divided across tiers.
                              unique_tier prices the whole count at the single
                              tier that contains the total; progressive prices
                              each tier's band separately. Absent for non-tiered
                              models.
                          pricingModel:
                            type: string
                            enum:
                              - fixed
                              - per_unit
                              - per_package
                              - percentage
                              - tiered_per_unit
                              - tiered_percentage
                              - tiered_fixed
                              - advanced
                              - custom
                            description: >-
                              The pricing model of the plan charge that produced
                              this line item.
                        required:
                          - type
                          - billingModel
                          - pricingModel
                      - title: Contract minimum commitment
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - contract_minimum_commitment
                            description: >-
                              Discriminator: metadata for a
                              contract_minimum_commitment line item.
                          minimumAmount:
                            type: number
                            description: >-
                              The minimum amount committed for the whole
                              contract in the billing period, in cents.
                          minimumAmountApplied:
                            type: number
                            description: >-
                              The top-up charged by this line item to reach the
                              committed minimum, in cents: the difference
                              between minimumAmount and what the contract's
                              consumption amounted to.
                        required:
                          - type
                          - minimumAmount
                          - minimumAmountApplied
                      - title: Minimum commitment
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - minimum_commitment
                            description: >-
                              Discriminator: metadata for a plan-level
                              minimum_commitment line item.
                          minimumAmount:
                            type: number
                            description: >-
                              The minimum amount committed for the plan in the
                              billing period, in cents.
                          minimumAmountApplied:
                            type: number
                            description: >-
                              The top-up charged by this line item to reach the
                              committed minimum, in cents: the difference
                              between minimumAmount and what the plan's
                              consumption amounted to.
                        required:
                          - type
                          - minimumAmount
                          - minimumAmountApplied
                      - title: Custom
                        type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - custom
                            description: 'Discriminator: metadata for a custom line item.'
                          definitionKey:
                            type: string
                            description: >-
                              The key of the custom charge definition whose
                              calculator priced the charge, following the
                              custom:charge:<slug>:<name> convention.
                            examples:
                              - custom:charge:padaria-central:entregas
                          memory:
                            type: object
                            additionalProperties: true
                            description: >-
                              The full calculation memory that the calculator
                              returned, such as every tier it evaluated and the
                              one it billed. Its shape belongs to the
                              definition.
                        required:
                          - type
                          - definitionKey
                          - memory
                      - title: No metadata
                        type: 'null'
                  subLineItems:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a sub-line item: one priced row of a
                        line item's breakdown. The row type dictates the shape
                        of metadata.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the sub-line item in our
                            system.
                        type:
                          type: string
                          enum:
                            - fixed_price
                            - minimum_amount
                            - price_tier_flat
                            - price_tier_unit
                            - price_tier_package
                            - price_tier_percentage
                            - proration
                            - license_proration
                            - license_proration_tier
                            - unit_price
                            - included_quantity
                            - package_price
                            - percentage
                            - overage
                            - original_amount
                            - fixed_unit_price
                            - custom
                          description: >-
                            The kind of priced row: fixed_price and
                            minimum_amount are companions of usage-based
                            charges; unit_price, package_price, percentage, and
                            included_quantity break down single-model pricing;
                            price_tier_* rows break down tiered pricing; overage
                            bills usage beyond the last tier; proration bills
                            per prorated interval; license_proration bills
                            license deltas (removals are negative);
                            original_amount surfaces the pre-adjustment amount
                            of an adjusted line; fixed_unit_price breaks down a
                            fixed charge billed as a quantity times a unit
                            amount; custom bills one component of a custom plan
                            charge.
                        name:
                          type: string
                          description: >-
                            Display name of the sub-line item as it appears on
                            the invoice breakdown.
                          example: '[A partir de 1] Unidades'
                        description:
                          type: string
                          nullable: true
                          description: >-
                            Optional descriptive text for the row. Null when
                            absent.
                          example: 120 x 2,50
                        usage:
                          type: number
                          nullable: true
                          description: >-
                            The usage billed by this row: a count of resource
                            units (the quantity for a fixed_unit_price row), or
                            a monetary base amount in cents for
                            percentage-priced rows (see the row's usageFormat,
                            or the line item usageFormat when the row has none).
                            Null for rows without usage (e.g. companions).
                        usageFormat:
                          type: string
                          enum:
                            - unit
                            - currency
                            - null
                          nullable: true
                          description: >-
                            How to read the usage of this row when the row has a
                            format of its own, as the custom rows of a custom
                            line item do: unit means a count, currency means an
                            amount in cents. Null when the row reads its usage
                            in the line item usageFormat.
                        amount:
                          type: number
                          description: >-
                            Amount billed by this row, in cents. The sum of a
                            line item's sub-line amounts equals its
                            subtotalAmount.
                        metadata:
                          description: >-
                            Pricing details of the row, keyed by the row type
                            (and pricingType for overage rows).
                          anyOf:
                            - type: object
                              description: >-
                                Fixed-price companion row: the charge's
                                configured fixed amount, billed alongside the
                                usage rows. Only rendered when configured
                                greater than zero.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed_price
                                  description: 'Discriminator: fixed-price companion row.'
                                fixedPrice:
                                  type: number
                                  description: >-
                                    The fixed amount configured on the charge,
                                    in cents.
                              required:
                                - type
                                - fixedPrice
                            - type: object
                              description: >-
                                Minimum-amount companion row: tops the charge up
                                to its configured minimum when usage alone stays
                                below it. Only rendered when the top-up is
                                greater than zero.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_amount
                                  description: 'Discriminator: minimum-amount companion row.'
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount configured on the charge,
                                    in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up billed by this row to reach the
                                    configured minimum, in cents.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - type: object
                              description: >-
                                Flat-priced tier row: usage falling in this tier
                                band is billed at a flat amount, regardless of
                                the exact quantity.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - price_tier_flat
                                  description: 'Discriminator: flat-priced tier row.'
                                from:
                                  type: number
                                  description: >-
                                    Lower bound of the tier band, in resource
                                    units (inclusive).
                                to:
                                  type: number
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band, in resource
                                    units (inclusive). Null for an unbounded
                                    final tier.
                                fixedPrice:
                                  type: string
                                  description: >-
                                    The flat amount billed for the tier, as a
                                    decimal currency-unit string.
                                  examples:
                                    - '150.00'
                              required:
                                - type
                                - from
                                - to
                                - fixedPrice
                            - type: object
                              description: >-
                                Per-unit priced tier row: units attributed to
                                this tier band are billed at the tier's unit
                                price.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - price_tier_unit
                                  description: 'Discriminator: per-unit priced tier row.'
                                from:
                                  type: number
                                  description: >-
                                    Lower bound of the tier band, in resource
                                    units (inclusive).
                                to:
                                  type: number
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band, in resource
                                    units (inclusive). Null for an unbounded
                                    final tier.
                                price:
                                  type: string
                                  description: >-
                                    Price per unit within the tier, as a decimal
                                    currency-unit string.
                                  examples:
                                    - '0.25'
                                fixedPrice:
                                  type: string
                                  nullable: true
                                  description: >-
                                    Optional flat fee billed on top when the
                                    tier applies, as a decimal currency-unit
                                    string. Null when the tier has no flat fee.
                                  examples:
                                    - '10.00'
                              required:
                                - type
                                - from
                                - to
                                - price
                                - fixedPrice
                            - type: object
                              description: >-
                                Package-priced tier row: units attributed to
                                this tier band are billed per started package of
                                packageSize units.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - price_tier_package
                                  description: 'Discriminator: package-priced tier row.'
                                from:
                                  type: number
                                  description: >-
                                    Lower bound of the tier band, in resource
                                    units (inclusive).
                                to:
                                  type: number
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band, in resource
                                    units (inclusive). Null for an unbounded
                                    final tier.
                                packageSize:
                                  type: number
                                  description: Number of resource units per package.
                                price:
                                  type: string
                                  description: >-
                                    Price per package, as a decimal
                                    currency-unit string.
                                  examples:
                                    - '45.00'
                              required:
                                - type
                                - from
                                - to
                                - packageSize
                                - price
                            - type: object
                              description: >-
                                Percentage-priced tier row: the monetary base
                                amount attributed to this tier band is billed at
                                a percentage.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - price_tier_percentage
                                  description: 'Discriminator: percentage-priced tier row.'
                                from:
                                  type: number
                                  description: >-
                                    Lower bound of the tier band, in cents of
                                    the monetary base amount (inclusive).
                                to:
                                  type: number
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band, in cents of
                                    the monetary base amount (inclusive). Null
                                    for an unbounded final tier.
                                percentage:
                                  type: string
                                  pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                  description: >-
                                    Percentage applied to the base amount within
                                    the tier, as a decimal string from 0 to 100
                                    (up to 6 decimal places).
                                  examples:
                                    - '2.5'
                              required:
                                - type
                                - from
                                - to
                                - percentage
                            - type: object
                              description: >-
                                Proration interval row: for charges on prorated
                                resources, each interval bills the usage held
                                during it, priced as if held for the whole cycle
                                and scaled by the interval's share of the cycle.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - proration
                                  description: 'Discriminator: proration interval row.'
                                intervalSize:
                                  type: number
                                  description: >-
                                    Length of the interval, in days of the
                                    billing cycle.
                                amount:
                                  type: string
                                  description: >-
                                    The prorated amount of the interval, as a
                                    decimal currency-unit string: the interval
                                    usage priced as if held for the whole cycle,
                                    scaled by intervalSize over the cycle
                                    length.
                                  examples:
                                    - '29.0322580645'
                                usage:
                                  type: number
                                  description: The usage held during the interval.
                                intervalStart:
                                  type: string
                                  format: date
                                  description: First day of the interval.
                                intervalEnd:
                                  type: string
                                  format: date
                                  description: Last day of the interval.
                              required:
                                - type
                                - intervalSize
                                - amount
                                - usage
                                - intervalStart
                                - intervalEnd
                            - type: object
                              description: >-
                                License proration delta row: for per_unit
                                license charges billing under the proration
                                model, the cycle-start row bills the starting
                                licenses beyond the included quantity at their
                                full-cycle price, and each change row bills the
                                change in those licenses prorated over the days
                                remaining in the cycle. A change that stays
                                inside the included quantity has no row. Tiered
                                charges use license_proration_tier instead.
                                quantityDelta and the row's amount are signed —
                                removals are negative.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_proration
                                  description: 'Discriminator: license proration delta row.'
                                changeDate:
                                  type: string
                                  format: date
                                  nullable: true
                                  description: >-
                                    The day the combined license quantity
                                    changed. Null on the cycle-start row.
                                quantityDelta:
                                  type: number
                                  description: >-
                                    Signed change in the licenses beyond the
                                    included quantity (the starting licenses
                                    beyond it on the cycle-start row). Negative
                                    for removals.
                                quantity:
                                  type: number
                                  description: >-
                                    The combined license quantity after this
                                    change.
                                remainingDays:
                                  type: number
                                  description: >-
                                    Days from the change (inclusive) to the end
                                    of the cycle. Equals cycleDays on the
                                    cycle-start row.
                                cycleDays:
                                  type: number
                                  description: Length of the billing cycle, in days.
                                proratedUnitRate:
                                  type: string
                                  description: >-
                                    Absolute effective per-unit rate of the row
                                    over the remaining window, as a decimal
                                    currency-unit string: |amount| /
                                    |quantityDelta|. On a cycle-start row that
                                    bills no license, the unit price of the
                                    charge.
                                  examples:
                                    - '16.1290322581'
                                amount:
                                  type: string
                                  description: >-
                                    The signed prorated amount of the row, as a
                                    decimal currency-unit string.
                                  examples:
                                    - '48.3870967742'
                              required:
                                - type
                                - changeDate
                                - quantityDelta
                                - quantity
                                - remainingDays
                                - cycleDays
                                - proratedUnitRate
                                - amount
                            - type: object
                              description: >-
                                Tiered license proration delta row: one price
                                band of a license charge billing under the
                                proration model with tiered_per_unit pricing.
                                The cycle-start rows bill each band's opening
                                occupancy at its full-cycle unit price, and each
                                change row bills that band's occupancy delta
                                prorated over the days remaining in the cycle.
                                quantityDelta and the row's amount are signed —
                                removals are negative.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_proration_tier
                                  description: >-
                                    Discriminator: tiered license proration
                                    delta row.
                                changeDate:
                                  type: string
                                  format: date
                                  nullable: true
                                  description: >-
                                    The day the combined license quantity
                                    changed. Null on a cycle-start row.
                                quantityDelta:
                                  type: number
                                  description: >-
                                    Signed change in the units this band holds
                                    (the band's opening occupancy on a
                                    cycle-start row). Negative for removals.
                                quantity:
                                  type: number
                                  description: >-
                                    The combined license quantity across every
                                    band after this change.
                                remainingDays:
                                  type: number
                                  description: >-
                                    Days from the change (inclusive) to the end
                                    of the cycle. Equals cycleDays on a
                                    cycle-start row.
                                cycleDays:
                                  type: number
                                  description: Length of the billing cycle, in days.
                                proratedUnitRate:
                                  type: string
                                  description: >-
                                    Absolute effective per-unit rate of the row
                                    over the remaining window, as a decimal
                                    currency-unit string: |amount| /
                                    |quantityDelta|.
                                  examples:
                                    - '16.1290322581'
                                amount:
                                  type: string
                                  description: >-
                                    The signed prorated amount of the row, as a
                                    decimal currency-unit string.
                                  examples:
                                    - '48.3870967742'
                                planChargeTierId:
                                  type: string
                                  description: >-
                                    The unique identifier of the plan charge
                                    tier this row moved through.
                                  examples:
                                    - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                from:
                                  type: number
                                  description: >-
                                    Inclusive lower bound of the band, in
                                    licenses.
                                to:
                                  type: number
                                  nullable: true
                                  description: >-
                                    Inclusive upper bound of the band, in
                                    licenses. Null on the last, open-ended band.
                                unitPrice:
                                  type: string
                                  description: >-
                                    The band's full-cycle price per unit, as a
                                    decimal currency-unit string.
                                    proratedUnitRate is this scaled by
                                    remainingDays over cycleDays.
                                  examples:
                                    - '25.00'
                              required:
                                - type
                                - changeDate
                                - quantityDelta
                                - quantity
                                - remainingDays
                                - cycleDays
                                - proratedUnitRate
                                - amount
                                - planChargeTierId
                                - from
                                - to
                                - unitPrice
                            - type: object
                              description: >-
                                Unit-price row: billable units multiplied by a
                                single price per unit. The row's usage holds the
                                billable units.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - unit_price
                                  description: 'Discriminator: unit-price row.'
                                price:
                                  type: string
                                  pattern: ^\d+(\.\d{1,6})?$
                                  description: >-
                                    Price per unit, as a decimal currency-unit
                                    string (up to 6 decimal places).
                                  examples:
                                    - '0.25'
                              required:
                                - type
                                - price
                            - type: object
                              description: >-
                                Included-quantity row: the free allotment of the
                                charge. The row's usage holds the units consumed
                                within the allotment and its amount is always
                                zero.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - included_quantity
                                  description: 'Discriminator: included-quantity row.'
                                includedQuantity:
                                  type: number
                                  description: >-
                                    Number of resource units included at no
                                    charge before billing starts.
                              required:
                                - type
                                - includedQuantity
                            - type: object
                              description: >-
                                Package-price row: billable units charged per
                                started package of packageSize units. The row's
                                usage holds the billable units.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - package_price
                                  description: 'Discriminator: package-price row.'
                                packageSize:
                                  type: number
                                  description: Number of resource units per package.
                                price:
                                  type: string
                                  pattern: ^\d+(\.\d{1,6})?$
                                  description: >-
                                    Price per package, as a decimal
                                    currency-unit string (up to 6 decimal
                                    places).
                                  examples:
                                    - '45.00'
                                packagesBilled:
                                  type: number
                                  description: >-
                                    Number of packages billed: the billable
                                    units divided by packageSize, rounded up.
                              required:
                                - type
                                - packageSize
                                - price
                                - packagesBilled
                            - type: object
                              description: >-
                                Percentage row: a percentage applied over a
                                monetary base amount. The row's usage holds the
                                base amount, in cents.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - percentage
                                  description: 'Discriminator: percentage row.'
                                percentage:
                                  type: string
                                  pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                  description: >-
                                    Percentage applied to the base amount, as a
                                    decimal string from 0 to 100 (up to 6
                                    decimal places).
                                  examples:
                                    - '2.5'
                              required:
                                - type
                                - percentage
                            - type: object
                              description: >-
                                Per-unit overage row: units beyond the last tier
                                boundary, billed at the configured excess unit
                                price. The row's usage holds the units over the
                                boundary.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - overage
                                  description: 'Discriminator: overage row.'
                                pricingType:
                                  type: string
                                  enum:
                                    - per_unit
                                  description: 'Discriminator: overage billed per unit.'
                                from:
                                  type: number
                                  description: >-
                                    The boundary the overage starts from: the
                                    upper bound of the last tier, in resource
                                    units.
                                price:
                                  type: string
                                  pattern: ^\d+(\.\d{1,6})?$
                                  description: >-
                                    Price per excess unit, as a decimal
                                    currency-unit string (up to 6 decimal
                                    places).
                                  examples:
                                    - '0.30'
                              required:
                                - type
                                - pricingType
                                - from
                                - price
                            - type: object
                              description: >-
                                Percentage overage row: the monetary base amount
                                beyond the last tier boundary, billed at the
                                configured excess percentage. The row's usage
                                holds the base amount over the boundary, in
                                cents.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - overage
                                  description: 'Discriminator: overage row.'
                                pricingType:
                                  type: string
                                  enum:
                                    - percentage
                                  description: >-
                                    Discriminator: overage billed as a
                                    percentage.
                                from:
                                  type: number
                                  description: >-
                                    The boundary the overage starts from: the
                                    upper bound of the last tier, in cents of
                                    the monetary base amount.
                                percentage:
                                  type: string
                                  pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                  description: >-
                                    Percentage applied to the excess base
                                    amount, as a decimal string from 0 to 100
                                    (up to 6 decimal places).
                                  examples:
                                    - '1.5'
                              required:
                                - type
                                - pricingType
                                - from
                                - percentage
                            - type: object
                              description: >-
                                Original-amount row: surfaces the line item's
                                pre-adjustment amount when the line has
                                adjustments (e.g. a discount) but no
                                price-component rows of its own. The row's
                                amount equals the line item's subtotalAmount.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - original_amount
                                  description: 'Discriminator: original-amount row.'
                              required:
                                - type
                            - type: object
                              description: >-
                                Fixed unit price row: the quantity of a fixed
                                charge multiplied by its unit amount. The row's
                                usage holds the quantity.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed_unit_price
                                  description: 'Discriminator: fixed unit price row.'
                                amount:
                                  type: integer
                                  minimum: 0
                                  description: Amount of one unit, in cents.
                              required:
                                - type
                                - amount
                            - type: object
                              description: >-
                                Custom row: one component of a custom plan
                                charge, as its calculator billed it. The row's
                                name, description, usage, usageFormat and amount
                                hold the rest of the component.
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - custom
                                  description: 'Discriminator: custom row.'
                                key:
                                  type: string
                                  description: >-
                                    The key of the component in the sub-line
                                    schema of the charge's custom charge
                                    definition, such as documents_overage.
                                  examples:
                                    - documents_overage
                              required:
                                - type
                                - key
                      required:
                        - id
                        - type
                        - name
                        - description
                        - usage
                        - usageFormat
                        - amount
                        - metadata
                      additionalProperties: false
                    description: >-
                      Breakdown of the line item amount into priced rows
                      (included quantities, unit/package/tier prices,
                      prorations, companions). Empty for line items without a
                      breakdown.
                  adjustments:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing an adjustment applied on top of a
                        line item subtotal, such as a discount or an allocation
                        offset.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the adjustment in our
                            system.
                        name:
                          type: string
                          description: >-
                            Display name of the adjustment as it appears on the
                            invoice.
                          example: Desconto de boas-vindas
                        type:
                          type: string
                          enum:
                            - monetary_discount
                            - allocation_offset
                          description: >-
                            The kind of adjustment: monetary_discount (a
                            discount applied to the line item) or
                            allocation_offset (the share of the amount moved to
                            another payment account's invoice under a split
                            allocation strategy).
                        amount:
                          type: number
                          description: >-
                            Amount of the adjustment, in cents. Negative when
                            the adjustment reduces the line item total.
                      required:
                        - id
                        - name
                        - type
                        - amount
                      additionalProperties: false
                    description: >-
                      Adjustments applied on top of the line item subtotal, such
                      as discounts and allocation offsets.
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - productId
                  - resourceId
                  - licenseId
                  - lineItemGroupId
                  - name
                  - scope
                  - startDate
                  - endDate
                  - totalUsage
                  - usageFormat
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - metadata
                  - subLineItems
                  - adjustments
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is not a one-off invoice,
            or it is locked, because it was issued or canceled.

            - `line_item_amount_inconsistent`: the `subLineItems` are not empty,
            and the sum of their `usage` times `price`, rounded to cents on each
            row, differs from the `amount`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                      - line_item_amount_inconsistent
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''startDate'' is required'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
                line_item_amount_inconsistent:
                  value:
                    message: >-
                      sum of subLineItems usage x price (in rounded cents) must
                      equal amount
                    code: line_item_amount_inconsistent
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `invoiceId`.

            - `line_item_not_found`: no line item of the invoice has the
            `lineItemId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - line_item_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                line_item_not_found:
                  value:
                    message: Failed to create invoice line item
                    code: line_item_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `line_item_amount_inconsistent`: the body leaves `subLineItems`
            out, and the `amount` differs from the sum of the sub-line items
            that the line item keeps.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - line_item_amount_inconsistent
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                line_item_amount_inconsistent:
                  value:
                    message: >-
                      sum of subLineItems usage x price (in rounded cents) must
                      equal amount
                    code: line_item_amount_inconsistent
    delete:
      summary: Delete invoice line item
      tags:
        - Invoices
      description: |-
        Deletes a line item from a one-off invoice.

        Requires the role `invoices:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice the line item belongs to.
        - schema:
            type: string
            format: uuid
          in: path
          name: lineItemId
          required: true
          description: The unique identifier of the line item to delete.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: >-
            the invoice is not a one-off invoice, or it is locked, because it
            was issued or canceled
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - status: 404
          code: line_item_not_found
          when: no line item of the invoice has the `lineItemId`
      x-required-roles: *ref_8
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is not a one-off invoice,
            or it is locked, because it was issued or canceled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `invoiceId`.

            - `line_item_not_found`: no line item of the invoice has the
            `lineItemId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - line_item_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                line_item_not_found:
                  value:
                    message: Failed to create invoice line item
                    code: line_item_not_found
  /v1/invoices/{invoiceId}/discounts/{discountId}:
    put:
      summary: Update invoice discount
      tags:
        - Invoices
      description: >-
        Updates a discount on an invoice. The discount origin (reason) is
        preserved and cannot be changed via the API.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                target:
                  type: string
                  enum:
                    - invoice
                    - line_item_group
                    - line_item
                  description: >-
                    What the invoice discount takes off from: `invoice` for the
                    whole invoice, `line_item_group` for one line item group, or
                    `line_item` for one line item.
                targetIdempotencyKey:
                  type: string
                  description: >-
                    The idempotency key of the invoice, the line item group or
                    the line item that `target` names.
                  example: plan:3c90c3cc-0d44-4b50-8888-8dd25736052a
                method:
                  type: string
                  enum:
                    - fixed
                    - percentage
                  description: >-
                    How to read `amount`: `fixed` takes off an amount in cents,
                    and `percentage` takes off a percentage of the target.
                description:
                  type: string
                  minLength: 1
                  description: The text of the invoice discount on the invoice.
                  example: Desconto de boas-vindas
                amount:
                  type: number
                  multipleOf: 1
                  minimum: 1
                  description: >-
                    The value of the invoice discount, as a positive integer:
                    cents when `method` is `fixed`, or basis points when
                    `method` is `percentage`, where 100 basis points are 1% and
                    10000 are 100%.
                customFields:
                  type: object
                  description: >-
                    The values of the custom fields of invoice discounts on the
                    invoice discount, keyed by the key of each custom field.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
              required:
                - target
                - targetIdempotencyKey
                - method
                - description
                - amount
              additionalProperties: false
        required: true
        description: >-
          An invoice discount: an amount that an invoice takes off, from the
          whole invoice, from one of its line item groups or from one of its
          line items. It is a manual discount, a recurring discount or the
          contract proration, which takes off the part of the first cycle that a
          late contract start skips. Only an active invoice discount counts in
          the totals of the invoice.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice of the invoice discount.
        - schema:
            type: string
            format: uuid
          in: path
          name: discountId
          required: true
          description: The unique identifier of the invoice discount.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: the invoice is locked, because it was issued or canceled
        - status: 400
          code: invoice_not_found
          when: >-
            the `target` is `invoice`, and the `targetIdempotencyKey` is not the
            idempotency key of the invoice
        - status: 400
          code: line_item_group_not_found_for_invoice
          when: >-
            the `target` is `line_item_group`, and no line item group of the
            invoice has the `targetIdempotencyKey`
        - status: 400
          code: line_item_not_found_for_invoice
          when: >-
            the `target` is `line_item`, and no line item of the invoice has the
            `targetIdempotencyKey`
        - status: 400
          code: invalid_invoice_discount_amount
          when: the `method` is `percentage` and the `amount` is over 10000
        - status: 400
          code: invalid_custom_fields
          when: >-
            the body carries `customFields` that leave out a required custom
            field of invoice discounts, name a key that is not one, or hold a
            value that its custom field does not take
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - status: 404
          code: invoice_discount_not_found
          when: no active invoice discount of the invoice has the `discountId`
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            An invoice discount: an amount that an invoice takes off, from the
            whole invoice, from one of its line item groups or from one of its
            line items. It is a manual discount, a recurring discount or the
            contract proration, which takes off the part of the first cycle that
            a late contract start skips. Only an active invoice discount counts
            in the totals of the invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the invoice discount.
                  target:
                    type: string
                    enum:
                      - invoice
                      - line_item_group
                      - line_item
                    description: >-
                      What the invoice discount takes off from: `invoice` for
                      the whole invoice, `line_item_group` for one line item
                      group, or `line_item` for one line item.
                  targetIdempotencyKey:
                    type: string
                    description: >-
                      The idempotency key of the invoice, the line item group or
                      the line item that `target` names.
                    example: plan:3c90c3cc-0d44-4b50-8888-8dd25736052a
                  method:
                    type: string
                    enum:
                      - fixed
                      - percentage
                    description: >-
                      How to read `amount`: `fixed` takes off an amount in
                      cents, and `percentage` takes off a percentage of the
                      target.
                  reason:
                    type: string
                    enum:
                      - manual_discount
                      - contract_proration
                      - contract_recurring
                    description: >-
                      Why the invoice discount exists: `manual_discount` for a
                      discount that a user or a system created,
                      `contract_proration` for the contract proration, or
                      `contract_recurring` for a recurring discount of the
                      contract.
                  description:
                    type: string
                    minLength: 1
                    description: The text of the invoice discount on the invoice.
                    example: Desconto de boas-vindas
                  amount:
                    type: number
                    multipleOf: 1
                    minimum: 1
                    description: >-
                      The value of the invoice discount, as a positive integer:
                      cents when `method` is `fixed`, or basis points when
                      `method` is `percentage`, where 100 basis points are 1%
                      and 10000 are 100%.
                  isActive:
                    type: boolean
                    description: >-
                      Whether the invoice discount counts in the totals of the
                      invoice. Aira keeps an inactive invoice discount for its
                      history, with no effect on the amounts.
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of invoice discounts on
                      the invoice discount, keyed by the key of each custom
                      field.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                required:
                  - id
                  - target
                  - targetIdempotencyKey
                  - method
                  - reason
                  - description
                  - amount
                  - isActive
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is locked, because it was
            issued or canceled.

            - `invoice_not_found`: the `target` is `invoice`, and the
            `targetIdempotencyKey` is not the idempotency key of the invoice.

            - `line_item_group_not_found_for_invoice`: the `target` is
            `line_item_group`, and no line item group of the invoice has the
            `targetIdempotencyKey`.

            - `line_item_not_found_for_invoice`: the `target` is `line_item`,
            and no line item of the invoice has the `targetIdempotencyKey`.

            - `invalid_invoice_discount_amount`: the `method` is `percentage`
            and the `amount` is over 10000.

            - `invalid_custom_fields`: the body carries `customFields` that
            leave out a required custom field of invoice discounts, name a key
            that is not one, or hold a value that its custom field does not
            take.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                      - invoice_not_found
                      - line_item_group_not_found_for_invoice
                      - line_item_not_found_for_invoice
                      - invalid_invoice_discount_amount
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''target'' is required'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                line_item_group_not_found_for_invoice:
                  value:
                    message: line item group not found for the given invoice
                    code: line_item_group_not_found_for_invoice
                line_item_not_found_for_invoice:
                  value:
                    message: line item not found for the given invoice
                    code: line_item_not_found_for_invoice
                invalid_invoice_discount_amount:
                  value:
                    message: invoice discount amount must be a positive integer
                    code: invalid_invoice_discount_amount
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `invoiceId`.

            - `invoice_discount_not_found`: no active invoice discount of the
            invoice has the `discountId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - invoice_discount_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                invoice_discount_not_found:
                  value:
                    message: invoice discount not found
                    code: invoice_discount_not_found
    delete:
      summary: Delete invoice discount
      tags:
        - Invoices
      description: |-
        Deletes a discount from an invoice.

        Requires the role `invoices:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice of the invoice discount.
        - schema:
            type: string
            format: uuid
          in: path
          name: discountId
          required: true
          description: The unique identifier of the invoice discount.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: the invoice is locked, because it was issued or canceled
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - status: 404
          code: invoice_discount_not_found
          when: no invoice discount of the invoice has the `discountId`
      x-required-roles: *ref_8
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is locked, because it was
            issued or canceled.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `invoiceId`.

            - `invoice_discount_not_found`: no invoice discount of the invoice
            has the `discountId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - invoice_discount_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                invoice_discount_not_found:
                  value:
                    message: invoice discount not found
                    code: invoice_discount_not_found
  /v1/invoices/{id}/unpay:
    post:
      summary: Undo a manual mark as paid
      tags:
        - Invoices
      description: >-
        Undoes the manual mark as paid of an invoice, which returns to the
        status that it held before: issued, synced, pending or overdue.


        Requires the role `invoices:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the invoice in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: >-
            the invoice is not paid, one of its payments is paid, its last move
            to paid did not come from a manual mark as paid, or it was not
            issued, synced, pending or overdue before that move
        - status: 400
          code: payment_integration_not_enabled
          when: the payments module is off
        - status: 404
          code: invoice_not_found
          when: no invoice has the `id`
      x-required-roles: *ref_8
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is not paid, one of its
            payments is paid, its last move to paid did not come from a manual
            mark as paid, or it was not issued, synced, pending or overdue
            before that move.

            - `payment_integration_not_enabled`: the payments module is off.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                      - payment_integration_not_enabled
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
                payment_integration_not_enabled:
                  value:
                    message: payment integration not enabled
                    code: payment_integration_not_enabled
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
  /v1/invoices/{id}/reopen:
    post:
      summary: Reopen an invoice
      tags:
        - Invoices
      description: >-
        Reopens a contract invoice: Aira cancels it and creates the invoice that
        replaces it in its invoice slot, with the additional charges and the
        manual discounts of the reopened invoice, and answers the replacement.
        Answers 204 with no body when the contract allocation no longer names
        the payment account of the invoice, because Aira then cancels the
        invoice with no replacement.


        Requires the role `invoices:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the invoice in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: >-
            the invoice is not an invoice of a contract, its contract is
            completed, it is open, in review or paid, it is dated more than four
            months ago, another invoice already replaced it, its contract or a
            change of the contract allocation canceled it, or an invoice of its
            invoice allocation group is paid or has a pending invoice sync
        - status: 400
          code: invalid_license_proration_allocation
          when: >-
            the contract of the invoice splits its invoices by the usage of its
            subsidiaries and bills a license-based charge whose billing model is
            proration
        - status: 404
          code: invoice_not_found
          when: no invoice has the `id`
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            The invoice that replaces the reopened invoice in its invoice slot.
            Monetary amounts are integers in cents.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the invoice in our system.
                  idempotencyKey:
                    type: string
                    description: >-
                      A unique key that identifies the invoice for idempotent
                      creation. Supplied by the caller for one-off invoices;
                      generated by the billing engine for contract invoices.
                    example: padaria-central-2026-11
                  customerId:
                    type: string
                    format: uuid
                    description: The unique identifier of the customer this invoice bills.
                  paymentAccountId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the customer payment account used
                      as the billing account for this invoice.
                  contractId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the contract that generated this
                      invoice. Null for invoices not generated from a contract
                      (e.g. one-off and imported invoices).
                  contractInvoiceSequence:
                    type: integer
                    minimum: 1
                    nullable: true
                    description: >-
                      The number of the invoice within its contract, in the
                      order that Aira created the contract's invoices: 1 for the
                      first, 2 for the next, and so on. Every invoice gets its
                      own number, including each invoice of a split across
                      payment accounts and the replacement of a reopened
                      invoice, and a number never changes and is never reused.
                      Null for invoices without a contract.
                  issuingAccount:
                    type: object
                    description: >-
                      Snapshot of the legal entity issuing the invoice (the
                      seller), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  billingAccount:
                    type: object
                    description: >-
                      Snapshot of the billed party (the legal entity behind the
                      customer payment account), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How the originating contract distributes charges across
                      payment accounts: single bills a single payment account;
                      percent_split divides the total between payment accounts
                      by configured percentages; subsidiary_usage_split divides
                      it according to each subsidiary's usage.
                  lastCalculatedAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When the invoice amounts were last computed by the billing
                      engine. Null when the invoice has never been calculated.
                  invoiceNumber:
                    type: string
                    description: >-
                      Human-readable invoice number, built from the customer's
                      invoice prefix plus a sequential counter.
                    example: ACMEI-0042
                  invoiceDate:
                    type: string
                    format: date
                    description: >-
                      The date of the invoice. On a contract invoice it is the
                      date of its billing act: the first day of the first
                      billing cycle that the contract invoices for an activation
                      invoice, and the last day of the billing cycle for a
                      closing invoice. Its line items state the periods that it
                      bills. On a one-off or imported invoice it is the date
                      given when the invoice was created.
                  memo:
                    type: string
                    nullable: true
                    description: >-
                      Free-form memo attached to the invoice. On contract
                      invoices, it reads "Período <start> a <end>" with the
                      period of the line item that bills most often, such as the
                      month when a monthly fee is billed with an annual fee.
                      When two line items bill equally often, it uses the
                      earlier period. Null when absent.
                    example: Período 01/11/2026 a 30/11/2026
                  subtotalAmount:
                    type: number
                    description: >-
                      Sum of the line item subtotals before adjustments, in
                      cents.
                  adjustmentAmount:
                    type: number
                    description: >-
                      Net amount of all adjustments applied to the invoice line
                      items (discounts and allocation offsets), in cents.
                      Negative when adjustments reduce the amount owed.
                  totalAmount:
                    type: number
                    description: >-
                      Final invoice amount, in cents: subtotalAmount +
                      adjustmentAmount.
                  discountAmount:
                    type: number
                    description: >-
                      The discount portion of adjustmentAmount, in cents (sum of
                      monetary discount adjustments only). Negative when
                      discounts were applied.
                  status:
                    type: string
                    enum:
                      - open
                      - in_review
                      - issued
                      - synced
                      - pending
                      - paid
                      - overdue
                      - canceled
                      - failed
                    description: >-
                      Current status of the invoice lifecycle: open
                      (accumulating charges, editable), in_review (flagged for
                      manual review before issuing), issued (finalized and
                      issued to the customer), synced (registered in the
                      external ERP/payment provider), pending (a payment was
                      initiated and awaits settlement), paid, overdue (unpaid
                      past the due date), canceled, or failed (an issue/sync
                      attempt failed and needs attention).
                  isLocked:
                    type: boolean
                    description: >-
                      Whether the invoice contents are locked against edits.
                      Aira locks an invoice when it issues or cancels it,
                      together with the other invoices of its allocation group,
                      except when it cancels the invoice because its payment
                      account left the allocation of the contract, which locks
                      only that invoice. A locked invoice stays locked, also
                      when its status later moves to failed.
                  failureReason:
                    type: string
                    nullable: true
                    description: >-
                      Reason for the most recent failure on the invoice (e.g. an
                      ERP sync or payment issue). Null when the invoice has no
                      active failure.
                    example: contract_sync_not_found
                  source:
                    type: string
                    enum:
                      - contract
                      - one_off
                      - import
                    description: >-
                      How the invoice originated: contract (generated by a
                      contract billing cycle), one_off (created manually or
                      through the API), or import (ingested from an external
                      system).
                  autoIssue:
                    type: boolean
                    description: >-
                      Whether the invoice is issued automatically when its
                      billing cycle closes, without manual review.
                  amountDue:
                    type: number
                    nullable: true
                    description: >-
                      Outstanding amount due on the invoice, in cents. Null when
                      not tracked.
                  dueDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Payment due date of the invoice. Null when no due date is
                      set (e.g. before the invoice is issued).
                  lineItemGroups:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a line item group: a container that
                        gathers the line items generated from one plan instance
                        (or created as a group on one-off invoices). Monetary
                        amounts are integers in cents.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item group in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the group within the
                            invoice. Supplied by the caller for one-off groups;
                            generated by the billing engine otherwise.
                          example: servicos-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this group bills.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this group
                            belongs to.
                        planId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan whose instance
                            generated this group. Null for groups not generated
                            from a plan (e.g. on one-off invoices).
                        planInstanceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan instance that
                            generated this group. Null for groups not generated
                            from a plan instance.
                        name:
                          type: string
                          description: >-
                            Display name of the group as it appears on the
                            invoice, typically the plan or product name.
                          example: Plano Entregas
                        startDate:
                          type: string
                          format: date
                          description: >-
                            Start of the period that the group shows. On
                            contract invoices, it is the period of the group's
                            line item that bills most often, such as the month
                            when a monthly fee is billed with an annual fee.
                            When two line items bill equally often, it is the
                            earlier period.
                        endDate:
                          type: string
                          format: date
                          description: >-
                            End of the period that the group shows, which
                            `startDate` describes.
                        subtotalAmount:
                          type: number
                          description: >-
                            Sum of the group's line item subtotals before
                            adjustments, in cents.
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to the group's
                            line items (discounts and allocation offsets), in
                            cents. Negative when adjustments reduce the amount
                            owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final group amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        lineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              One amount on an invoice, such as a plan charge,
                              the contract minimum, a tax gross-up (the withheld
                              ISS, the municipal service tax, added on top), a
                              one-off amount or an additional charge.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the line item in our
                                  system.
                              idempotencyKey:
                                type: string
                                description: >-
                                  A unique key that identifies the line item
                                  within the invoice. Supplied by the caller for
                                  one-off line items; generated by the billing
                                  engine otherwise.
                                example: entrega-novembro
                              customerId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the customer whose
                                  consumption this line item bills. On split or
                                  consolidated invoices it may be a subsidiary
                                  of the invoice's customer.
                              productId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the product this line
                                  item belongs to.
                              itemId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the catalog item this
                                  line bills. Null for line items not backed by
                                  a catalog item.
                              resourceId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the metered resource
                                  behind a usage_based line item. Null for line
                                  items not driven by resource usage.
                              licenseId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the license behind a
                                  license_based line item. Null for line items
                                  not driven by a license count.
                              lineItemGroupId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the line item group
                                  containing this line item. Null for standalone
                                  line items.
                              name:
                                type: string
                                description: >-
                                  Display name of the line item as it appears on
                                  the invoice.
                                example: Entregas
                              scope:
                                type: string
                                enum:
                                  - credit_purchase
                                  - contract_minimum_commitment
                                  - minimum_commitment
                                  - fixed
                                  - usage_based
                                  - license_based
                                  - custom
                                  - additional_charge
                                  - one_off
                                  - tax_gross_up
                                description: >-
                                  What the line item charges for: usage_based
                                  (metered resource consumption), license_based
                                  (a license's reported count billed in full),
                                  fixed (recurring fixed charge of a plan),
                                  custom (custom plan charge, priced by a
                                  calculator that Aira writes for you),
                                  minimum_commitment (plan-level minimum
                                  top-up), contract_minimum_commitment
                                  (contract-level minimum top-up),
                                  credit_purchase (credit pool top-up),
                                  additional_charge (extra charge added
                                  manually), one_off (line item of a one-off
                                  invoice), or tax_gross_up (tax gross-up
                                  charge).
                              startDate:
                                type: string
                                format: date
                                description: Start of the period covered by this line item.
                              endDate:
                                type: string
                                format: date
                                description: End of the period covered by this line item.
                              totalUsage:
                                type: number
                                nullable: true
                                description: >-
                                  Total usage billed by the line item, in the
                                  unit given by usageFormat. Null for line items
                                  without a single usage (e.g. fixed charges
                                  without a quantity, and custom line items
                                  whose calculator returns no total).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read totalUsage, and the usage of each
                                  sub-line item that has no usageFormat of its
                                  own: unit means a count of resource units or a
                                  fixed charge quantity; currency means a
                                  monetary base amount in cents. Null when the
                                  line item has no single usage, as a custom
                                  line item whose sub-line items bill different
                                  kinds of volume, each with its own
                                  usageFormat.
                              subtotalAmount:
                                type: number
                                description: >-
                                  Line item amount before adjustments, in cents
                                  (sum of its sub-line item amounts).
                              adjustmentAmount:
                                type: number
                                description: >-
                                  Net amount of the adjustments applied to this
                                  line item (discounts and allocation offsets),
                                  in cents. Negative when adjustments reduce the
                                  amount owed.
                              totalAmount:
                                type: number
                                description: >-
                                  Final line item amount, in cents:
                                  subtotalAmount + adjustmentAmount.
                              discountAmount:
                                type: number
                                description: >-
                                  The discount portion of adjustmentAmount, in
                                  cents (sum of monetary discount adjustments
                                  only). Negative when discounts were applied.
                              metadata:
                                description: >-
                                  Pricing metadata for the line item, where the
                                  shape is keyed by type. Always present, but
                                  null for line items without pricing metadata:
                                  credit_purchase, additional_charge, one_off,
                                  and tax_gross_up. It is populated for fixed
                                  (the billing timing), usage_based,
                                  license_based, minimum_commitment,
                                  contract_minimum_commitment, and custom (the
                                  definition and the calculation memory) line
                                  items.
                                anyOf:
                                  - title: Fixed
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed
                                        description: >-
                                          Discriminator: metadata for a fixed line
                                          item.
                                      billingTiming:
                                        type: string
                                        enum:
                                          - in_advance
                                          - in_arrears
                                        description: >-
                                          Whether the fee was billed in advance of
                                          its service period or after it.
                                    required:
                                      - type
                                      - billingTiming
                                  - title: Usage-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - usage_based
                                        description: >-
                                          Discriminator: metadata for a
                                          usage_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the metered resource accrues over
                                          the billing period: in_full bills the
                                          full usage of the period; proration
                                          weighs usage by the fraction of the
                                          period each amount was held.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          usage was divided across tiers.
                                          unique_tier prices all usage at the
                                          single tier that contains the total;
                                          progressive prices each tier's band
                                          separately. Absent for non-tiered
                                          models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item. Charges
                                          priced before pricing models existed are
                                          reported as advanced.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: License-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_based
                                        description: >-
                                          Discriminator: metadata for a
                                          license_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the license count accrues over the
                                          billing period. Always in_full: the
                                          latest reported count is billed in full.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          the license count was divided across
                                          tiers. unique_tier prices the whole
                                          count at the single tier that contains
                                          the total; progressive prices each
                                          tier's band separately. Absent for
                                          non-tiered models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: Contract minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - contract_minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a
                                          contract_minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          whole contract in the billing period, in
                                          cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the contract's consumption amounted
                                          to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a plan-level
                                          minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          plan in the billing period, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the plan's consumption amounted to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Custom
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: >-
                                          Discriminator: metadata for a custom
                                          line item.
                                      definitionKey:
                                        type: string
                                        description: >-
                                          The key of the custom charge definition
                                          whose calculator priced the charge,
                                          following the
                                          custom:charge:<slug>:<name> convention.
                                        examples:
                                          - custom:charge:padaria-central:entregas
                                      memory:
                                        type: object
                                        additionalProperties: true
                                        description: >-
                                          The full calculation memory that the
                                          calculator returned, such as every tier
                                          it evaluated and the one it billed. Its
                                          shape belongs to the definition.
                                    required:
                                      - type
                                      - definitionKey
                                      - memory
                                  - title: No metadata
                                    type: 'null'
                              subLineItems:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing a sub-line item: one
                                    priced row of a line item's breakdown. The
                                    row type dictates the shape of metadata.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the sub-line
                                        item in our system.
                                    type:
                                      type: string
                                      enum:
                                        - fixed_price
                                        - minimum_amount
                                        - price_tier_flat
                                        - price_tier_unit
                                        - price_tier_package
                                        - price_tier_percentage
                                        - proration
                                        - license_proration
                                        - license_proration_tier
                                        - unit_price
                                        - included_quantity
                                        - package_price
                                        - percentage
                                        - overage
                                        - original_amount
                                        - fixed_unit_price
                                        - custom
                                      description: >-
                                        The kind of priced row: fixed_price and
                                        minimum_amount are companions of
                                        usage-based charges; unit_price,
                                        package_price, percentage, and
                                        included_quantity break down
                                        single-model pricing; price_tier_* rows
                                        break down tiered pricing; overage bills
                                        usage beyond the last tier; proration
                                        bills per prorated interval;
                                        license_proration bills license deltas
                                        (removals are negative); original_amount
                                        surfaces the pre-adjustment amount of an
                                        adjusted line; fixed_unit_price breaks
                                        down a fixed charge billed as a quantity
                                        times a unit amount; custom bills one
                                        component of a custom plan charge.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the sub-line item as it
                                        appears on the invoice breakdown.
                                      example: '[A partir de 1] Unidades'
                                    description:
                                      type: string
                                      nullable: true
                                      description: >-
                                        Optional descriptive text for the row.
                                        Null when absent.
                                      example: 120 x 2,50
                                    usage:
                                      type: number
                                      nullable: true
                                      description: >-
                                        The usage billed by this row: a count of
                                        resource units (the quantity for a
                                        fixed_unit_price row), or a monetary
                                        base amount in cents for
                                        percentage-priced rows (see the row's
                                        usageFormat, or the line item
                                        usageFormat when the row has none). Null
                                        for rows without usage (e.g.
                                        companions).
                                    usageFormat:
                                      type: string
                                      enum:
                                        - unit
                                        - currency
                                        - null
                                      nullable: true
                                      description: >-
                                        How to read the usage of this row when
                                        the row has a format of its own, as the
                                        custom rows of a custom line item do:
                                        unit means a count, currency means an
                                        amount in cents. Null when the row reads
                                        its usage in the line item usageFormat.
                                    amount:
                                      type: number
                                      description: >-
                                        Amount billed by this row, in cents. The
                                        sum of a line item's sub-line amounts
                                        equals its subtotalAmount.
                                    metadata:
                                      description: >-
                                        Pricing details of the row, keyed by the
                                        row type (and pricingType for overage
                                        rows).
                                      anyOf:
                                        - type: object
                                          description: >-
                                            Fixed-price companion row: the charge's
                                            configured fixed amount, billed
                                            alongside the usage rows. Only rendered
                                            when configured greater than zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_price
                                              description: >-
                                                Discriminator: fixed-price companion
                                                row.
                                            fixedPrice:
                                              type: number
                                              description: >-
                                                The fixed amount configured on the
                                                charge, in cents.
                                          required:
                                            - type
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Minimum-amount companion row: tops the
                                            charge up to its configured minimum when
                                            usage alone stays below it. Only
                                            rendered when the top-up is greater than
                                            zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - minimum_amount
                                              description: >-
                                                Discriminator: minimum-amount companion
                                                row.
                                            minimumAmount:
                                              type: number
                                              description: >-
                                                The minimum amount configured on the
                                                charge, in cents.
                                            minimumAmountApplied:
                                              type: number
                                              description: >-
                                                The top-up billed by this row to reach
                                                the configured minimum, in cents.
                                          required:
                                            - type
                                            - minimumAmount
                                            - minimumAmountApplied
                                        - type: object
                                          description: >-
                                            Flat-priced tier row: usage falling in
                                            this tier band is billed at a flat
                                            amount, regardless of the exact
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_flat
                                              description: 'Discriminator: flat-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            fixedPrice:
                                              type: string
                                              description: >-
                                                The flat amount billed for the tier, as
                                                a decimal currency-unit string.
                                              examples:
                                                - '150.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Per-unit priced tier row: units
                                            attributed to this tier band are billed
                                            at the tier's unit price.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_unit
                                              description: 'Discriminator: per-unit priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            price:
                                              type: string
                                              description: >-
                                                Price per unit within the tier, as a
                                                decimal currency-unit string.
                                              examples:
                                                - '0.25'
                                            fixedPrice:
                                              type: string
                                              nullable: true
                                              description: >-
                                                Optional flat fee billed on top when the
                                                tier applies, as a decimal currency-unit
                                                string. Null when the tier has no flat
                                                fee.
                                              examples:
                                                - '10.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - price
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Package-priced tier row: units
                                            attributed to this tier band are billed
                                            per started package of packageSize
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_package
                                              description: 'Discriminator: package-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string.
                                              examples:
                                                - '45.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - packageSize
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage-priced tier row: the monetary
                                            base amount attributed to this tier band
                                            is billed at a percentage.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_percentage
                                              description: >-
                                                Discriminator: percentage-priced tier
                                                row.
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                                Null for an unbounded final tier.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount
                                                within the tier, as a decimal string
                                                from 0 to 100 (up to 6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - percentage
                                        - type: object
                                          description: >-
                                            Proration interval row: for charges on
                                            prorated resources, each interval bills
                                            the usage held during it, priced as if
                                            held for the whole cycle and scaled by
                                            the interval's share of the cycle.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - proration
                                              description: 'Discriminator: proration interval row.'
                                            intervalSize:
                                              type: number
                                              description: >-
                                                Length of the interval, in days of the
                                                billing cycle.
                                            amount:
                                              type: string
                                              description: >-
                                                The prorated amount of the interval, as
                                                a decimal currency-unit string: the
                                                interval usage priced as if held for the
                                                whole cycle, scaled by intervalSize over
                                                the cycle length.
                                              examples:
                                                - '29.0322580645'
                                            usage:
                                              type: number
                                              description: The usage held during the interval.
                                            intervalStart:
                                              type: string
                                              format: date
                                              description: First day of the interval.
                                            intervalEnd:
                                              type: string
                                              format: date
                                              description: Last day of the interval.
                                          required:
                                            - type
                                            - intervalSize
                                            - amount
                                            - usage
                                            - intervalStart
                                            - intervalEnd
                                        - type: object
                                          description: >-
                                            License proration delta row: for
                                            per_unit license charges billing under
                                            the proration model, the cycle-start row
                                            bills the starting licenses beyond the
                                            included quantity at their full-cycle
                                            price, and each change row bills the
                                            change in those licenses prorated over
                                            the days remaining in the cycle. A
                                            change that stays inside the included
                                            quantity has no row. Tiered charges use
                                            license_proration_tier instead.
                                            quantityDelta and the row's amount are
                                            signed — removals are negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration
                                              description: >-
                                                Discriminator: license proration delta
                                                row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on the cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the licenses beyond the
                                                included quantity (the starting licenses
                                                beyond it on the cycle-start row).
                                                Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity after this
                                                change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on
                                                the cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|. On a cycle-start row
                                                that bills no license, the unit price of
                                                the charge.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                        - type: object
                                          description: >-
                                            Tiered license proration delta row: one
                                            price band of a license charge billing
                                            under the proration model with
                                            tiered_per_unit pricing. The cycle-start
                                            rows bill each band's opening occupancy
                                            at its full-cycle unit price, and each
                                            change row bills that band's occupancy
                                            delta prorated over the days remaining
                                            in the cycle. quantityDelta and the
                                            row's amount are signed — removals are
                                            negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration_tier
                                              description: >-
                                                Discriminator: tiered license proration
                                                delta row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on a cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the units this band
                                                holds (the band's opening occupancy on a
                                                cycle-start row). Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity across
                                                every band after this change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on a
                                                cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                            planChargeTierId:
                                              type: string
                                              description: >-
                                                The unique identifier of the plan charge
                                                tier this row moved through.
                                              examples:
                                                - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                            from:
                                              type: number
                                              description: >-
                                                Inclusive lower bound of the band, in
                                                licenses.
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Inclusive upper bound of the band, in
                                                licenses. Null on the last, open-ended
                                                band.
                                            unitPrice:
                                              type: string
                                              description: >-
                                                The band's full-cycle price per unit, as
                                                a decimal currency-unit string.
                                                proratedUnitRate is this scaled by
                                                remainingDays over cycleDays.
                                              examples:
                                                - '25.00'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                            - planChargeTierId
                                            - from
                                            - to
                                            - unitPrice
                                        - type: object
                                          description: >-
                                            Unit-price row: billable units
                                            multiplied by a single price per unit.
                                            The row's usage holds the billable
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - unit_price
                                              description: 'Discriminator: unit-price row.'
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.25'
                                          required:
                                            - type
                                            - price
                                        - type: object
                                          description: >-
                                            Included-quantity row: the free
                                            allotment of the charge. The row's usage
                                            holds the units consumed within the
                                            allotment and its amount is always zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - included_quantity
                                              description: 'Discriminator: included-quantity row.'
                                            includedQuantity:
                                              type: number
                                              description: >-
                                                Number of resource units included at no
                                                charge before billing starts.
                                          required:
                                            - type
                                            - includedQuantity
                                        - type: object
                                          description: >-
                                            Package-price row: billable units
                                            charged per started package of
                                            packageSize units. The row's usage holds
                                            the billable units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - package_price
                                              description: 'Discriminator: package-price row.'
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '45.00'
                                            packagesBilled:
                                              type: number
                                              description: >-
                                                Number of packages billed: the billable
                                                units divided by packageSize, rounded
                                                up.
                                          required:
                                            - type
                                            - packageSize
                                            - price
                                            - packagesBilled
                                        - type: object
                                          description: >-
                                            Percentage row: a percentage applied
                                            over a monetary base amount. The row's
                                            usage holds the base amount, in cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - percentage
                                              description: 'Discriminator: percentage row.'
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount,
                                                as a decimal string from 0 to 100 (up to
                                                6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - percentage
                                        - type: object
                                          description: >-
                                            Per-unit overage row: units beyond the
                                            last tier boundary, billed at the
                                            configured excess unit price. The row's
                                            usage holds the units over the boundary.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - per_unit
                                              description: 'Discriminator: overage billed per unit.'
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                resource units.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per excess unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.30'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage overage row: the monetary
                                            base amount beyond the last tier
                                            boundary, billed at the configured
                                            excess percentage. The row's usage holds
                                            the base amount over the boundary, in
                                            cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - percentage
                                              description: >-
                                                Discriminator: overage billed as a
                                                percentage.
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                cents of the monetary base amount.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the excess base
                                                amount, as a decimal string from 0 to
                                                100 (up to 6 decimal places).
                                              examples:
                                                - '1.5'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - percentage
                                        - type: object
                                          description: >-
                                            Original-amount row: surfaces the line
                                            item's pre-adjustment amount when the
                                            line has adjustments (e.g. a discount)
                                            but no price-component rows of its own.
                                            The row's amount equals the line item's
                                            subtotalAmount.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - original_amount
                                              description: 'Discriminator: original-amount row.'
                                          required:
                                            - type
                                        - type: object
                                          description: >-
                                            Fixed unit price row: the quantity of a
                                            fixed charge multiplied by its unit
                                            amount. The row's usage holds the
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_unit_price
                                              description: 'Discriminator: fixed unit price row.'
                                            amount:
                                              type: integer
                                              minimum: 0
                                              description: Amount of one unit, in cents.
                                          required:
                                            - type
                                            - amount
                                        - type: object
                                          description: >-
                                            Custom row: one component of a custom
                                            plan charge, as its calculator billed
                                            it. The row's name, description, usage,
                                            usageFormat and amount hold the rest of
                                            the component.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - custom
                                              description: 'Discriminator: custom row.'
                                            key:
                                              type: string
                                              description: >-
                                                The key of the component in the sub-line
                                                schema of the charge's custom charge
                                                definition, such as documents_overage.
                                              examples:
                                                - documents_overage
                                          required:
                                            - type
                                            - key
                                  required:
                                    - id
                                    - type
                                    - name
                                    - description
                                    - usage
                                    - usageFormat
                                    - amount
                                    - metadata
                                  additionalProperties: false
                                description: >-
                                  Breakdown of the line item amount into priced
                                  rows (included quantities, unit/package/tier
                                  prices, prorations, companions). Empty for
                                  line items without a breakdown.
                              adjustments:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing an adjustment applied on
                                    top of a line item subtotal, such as a
                                    discount or an allocation offset.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the adjustment
                                        in our system.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the adjustment as it
                                        appears on the invoice.
                                      example: Desconto de boas-vindas
                                    type:
                                      type: string
                                      enum:
                                        - monetary_discount
                                        - allocation_offset
                                      description: >-
                                        The kind of adjustment:
                                        monetary_discount (a discount applied to
                                        the line item) or allocation_offset (the
                                        share of the amount moved to another
                                        payment account's invoice under a split
                                        allocation strategy).
                                    amount:
                                      type: number
                                      description: >-
                                        Amount of the adjustment, in cents.
                                        Negative when the adjustment reduces the
                                        line item total.
                                  required:
                                    - id
                                    - name
                                    - type
                                    - amount
                                  additionalProperties: false
                                description: >-
                                  Adjustments applied on top of the line item
                                  subtotal, such as discounts and allocation
                                  offsets.
                            required:
                              - id
                              - idempotencyKey
                              - customerId
                              - productId
                              - resourceId
                              - licenseId
                              - lineItemGroupId
                              - name
                              - scope
                              - startDate
                              - endDate
                              - totalUsage
                              - usageFormat
                              - subtotalAmount
                              - adjustmentAmount
                              - totalAmount
                              - discountAmount
                              - metadata
                              - subLineItems
                              - adjustments
                            additionalProperties: false
                          description: The line items contained in this group.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - planId
                        - planInstanceId
                        - name
                        - startDate
                        - endDate
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - lineItems
                      additionalProperties: false
                    description: >-
                      Line item groups on the invoice. Each group gathers the
                      line items generated from one plan instance (or created as
                      a group on one-off invoices).
                  standaloneLineItems:
                    type: array
                    items:
                      type: object
                      description: >-
                        One amount on an invoice, such as a plan charge, the
                        contract minimum, a tax gross-up (the withheld ISS, the
                        municipal service tax, added on top), a one-off amount
                        or an additional charge.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the line item within
                            the invoice. Supplied by the caller for one-off line
                            items; generated by the billing engine otherwise.
                          example: entrega-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this line item bills. On split or
                            consolidated invoices it may be a subsidiary of the
                            invoice's customer.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this line item
                            belongs to.
                        itemId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the catalog item this line
                            bills. Null for line items not backed by a catalog
                            item.
                        resourceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the metered resource behind
                            a usage_based line item. Null for line items not
                            driven by resource usage.
                        licenseId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the license behind a
                            license_based line item. Null for line items not
                            driven by a license count.
                        lineItemGroupId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the line item group
                            containing this line item. Null for standalone line
                            items.
                        name:
                          type: string
                          description: >-
                            Display name of the line item as it appears on the
                            invoice.
                          example: Entregas
                        scope:
                          type: string
                          enum:
                            - credit_purchase
                            - contract_minimum_commitment
                            - minimum_commitment
                            - fixed
                            - usage_based
                            - license_based
                            - custom
                            - additional_charge
                            - one_off
                            - tax_gross_up
                          description: >-
                            What the line item charges for: usage_based (metered
                            resource consumption), license_based (a license's
                            reported count billed in full), fixed (recurring
                            fixed charge of a plan), custom (custom plan charge,
                            priced by a calculator that Aira writes for you),
                            minimum_commitment (plan-level minimum top-up),
                            contract_minimum_commitment (contract-level minimum
                            top-up), credit_purchase (credit pool top-up),
                            additional_charge (extra charge added manually),
                            one_off (line item of a one-off invoice), or
                            tax_gross_up (tax gross-up charge).
                        startDate:
                          type: string
                          format: date
                          description: Start of the period covered by this line item.
                        endDate:
                          type: string
                          format: date
                          description: End of the period covered by this line item.
                        totalUsage:
                          type: number
                          nullable: true
                          description: >-
                            Total usage billed by the line item, in the unit
                            given by usageFormat. Null for line items without a
                            single usage (e.g. fixed charges without a quantity,
                            and custom line items whose calculator returns no
                            total).
                        usageFormat:
                          type: string
                          enum:
                            - unit
                            - currency
                            - null
                          nullable: true
                          description: >-
                            How to read totalUsage, and the usage of each
                            sub-line item that has no usageFormat of its own:
                            unit means a count of resource units or a fixed
                            charge quantity; currency means a monetary base
                            amount in cents. Null when the line item has no
                            single usage, as a custom line item whose sub-line
                            items bill different kinds of volume, each with its
                            own usageFormat.
                        subtotalAmount:
                          type: number
                          description: >-
                            Line item amount before adjustments, in cents (sum
                            of its sub-line item amounts).
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to this line
                            item (discounts and allocation offsets), in cents.
                            Negative when adjustments reduce the amount owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final line item amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        metadata:
                          description: >-
                            Pricing metadata for the line item, where the shape
                            is keyed by type. Always present, but null for line
                            items without pricing metadata: credit_purchase,
                            additional_charge, one_off, and tax_gross_up. It is
                            populated for fixed (the billing timing),
                            usage_based, license_based, minimum_commitment,
                            contract_minimum_commitment, and custom (the
                            definition and the calculation memory) line items.
                          anyOf:
                            - title: Fixed
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed
                                  description: >-
                                    Discriminator: metadata for a fixed line
                                    item.
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    Whether the fee was billed in advance of its
                                    service period or after it.
                              required:
                                - type
                                - billingTiming
                            - title: Usage-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - usage_based
                                  description: >-
                                    Discriminator: metadata for a usage_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the metered resource accrues over the
                                    billing period: in_full bills the full usage
                                    of the period; proration weighs usage by the
                                    fraction of the period each amount was held.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how
                                    usage was divided across tiers. unique_tier
                                    prices all usage at the single tier that
                                    contains the total; progressive prices each
                                    tier's band separately. Absent for
                                    non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item. Charges priced
                                    before pricing models existed are reported
                                    as advanced.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: License-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_based
                                  description: >-
                                    Discriminator: metadata for a license_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the license count accrues over the
                                    billing period. Always in_full: the latest
                                    reported count is billed in full.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how the
                                    license count was divided across tiers.
                                    unique_tier prices the whole count at the
                                    single tier that contains the total;
                                    progressive prices each tier's band
                                    separately. Absent for non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: Contract minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - contract_minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a
                                    contract_minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the whole
                                    contract in the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the contract's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a plan-level
                                    minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the plan in
                                    the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the plan's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Custom
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - custom
                                  description: >-
                                    Discriminator: metadata for a custom line
                                    item.
                                definitionKey:
                                  type: string
                                  description: >-
                                    The key of the custom charge definition
                                    whose calculator priced the charge,
                                    following the custom:charge:<slug>:<name>
                                    convention.
                                  examples:
                                    - custom:charge:padaria-central:entregas
                                memory:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The full calculation memory that the
                                    calculator returned, such as every tier it
                                    evaluated and the one it billed. Its shape
                                    belongs to the definition.
                              required:
                                - type
                                - definitionKey
                                - memory
                            - title: No metadata
                              type: 'null'
                        subLineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing a sub-line item: one priced
                              row of a line item's breakdown. The row type
                              dictates the shape of metadata.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the sub-line item in
                                  our system.
                              type:
                                type: string
                                enum:
                                  - fixed_price
                                  - minimum_amount
                                  - price_tier_flat
                                  - price_tier_unit
                                  - price_tier_package
                                  - price_tier_percentage
                                  - proration
                                  - license_proration
                                  - license_proration_tier
                                  - unit_price
                                  - included_quantity
                                  - package_price
                                  - percentage
                                  - overage
                                  - original_amount
                                  - fixed_unit_price
                                  - custom
                                description: >-
                                  The kind of priced row: fixed_price and
                                  minimum_amount are companions of usage-based
                                  charges; unit_price, package_price,
                                  percentage, and included_quantity break down
                                  single-model pricing; price_tier_* rows break
                                  down tiered pricing; overage bills usage
                                  beyond the last tier; proration bills per
                                  prorated interval; license_proration bills
                                  license deltas (removals are negative);
                                  original_amount surfaces the pre-adjustment
                                  amount of an adjusted line; fixed_unit_price
                                  breaks down a fixed charge billed as a
                                  quantity times a unit amount; custom bills one
                                  component of a custom plan charge.
                              name:
                                type: string
                                description: >-
                                  Display name of the sub-line item as it
                                  appears on the invoice breakdown.
                                example: '[A partir de 1] Unidades'
                              description:
                                type: string
                                nullable: true
                                description: >-
                                  Optional descriptive text for the row. Null
                                  when absent.
                                example: 120 x 2,50
                              usage:
                                type: number
                                nullable: true
                                description: >-
                                  The usage billed by this row: a count of
                                  resource units (the quantity for a
                                  fixed_unit_price row), or a monetary base
                                  amount in cents for percentage-priced rows
                                  (see the row's usageFormat, or the line item
                                  usageFormat when the row has none). Null for
                                  rows without usage (e.g. companions).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read the usage of this row when the row
                                  has a format of its own, as the custom rows of
                                  a custom line item do: unit means a count,
                                  currency means an amount in cents. Null when
                                  the row reads its usage in the line item
                                  usageFormat.
                              amount:
                                type: number
                                description: >-
                                  Amount billed by this row, in cents. The sum
                                  of a line item's sub-line amounts equals its
                                  subtotalAmount.
                              metadata:
                                description: >-
                                  Pricing details of the row, keyed by the row
                                  type (and pricingType for overage rows).
                                anyOf:
                                  - type: object
                                    description: >-
                                      Fixed-price companion row: the charge's
                                      configured fixed amount, billed alongside
                                      the usage rows. Only rendered when
                                      configured greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_price
                                        description: >-
                                          Discriminator: fixed-price companion
                                          row.
                                      fixedPrice:
                                        type: number
                                        description: >-
                                          The fixed amount configured on the
                                          charge, in cents.
                                    required:
                                      - type
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Minimum-amount companion row: tops the
                                      charge up to its configured minimum when
                                      usage alone stays below it. Only rendered
                                      when the top-up is greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_amount
                                        description: >-
                                          Discriminator: minimum-amount companion
                                          row.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount configured on the
                                          charge, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up billed by this row to reach
                                          the configured minimum, in cents.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - type: object
                                    description: >-
                                      Flat-priced tier row: usage falling in
                                      this tier band is billed at a flat amount,
                                      regardless of the exact quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_flat
                                        description: 'Discriminator: flat-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      fixedPrice:
                                        type: string
                                        description: >-
                                          The flat amount billed for the tier, as
                                          a decimal currency-unit string.
                                        examples:
                                          - '150.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Per-unit priced tier row: units attributed
                                      to this tier band are billed at the tier's
                                      unit price.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_unit
                                        description: 'Discriminator: per-unit priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      price:
                                        type: string
                                        description: >-
                                          Price per unit within the tier, as a
                                          decimal currency-unit string.
                                        examples:
                                          - '0.25'
                                      fixedPrice:
                                        type: string
                                        nullable: true
                                        description: >-
                                          Optional flat fee billed on top when the
                                          tier applies, as a decimal currency-unit
                                          string. Null when the tier has no flat
                                          fee.
                                        examples:
                                          - '10.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - price
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Package-priced tier row: units attributed
                                      to this tier band are billed per started
                                      package of packageSize units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_package
                                        description: 'Discriminator: package-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string.
                                        examples:
                                          - '45.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - packageSize
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage-priced tier row: the monetary
                                      base amount attributed to this tier band
                                      is billed at a percentage.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_percentage
                                        description: >-
                                          Discriminator: percentage-priced tier
                                          row.
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                          Null for an unbounded final tier.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          within the tier, as a decimal string
                                          from 0 to 100 (up to 6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - percentage
                                  - type: object
                                    description: >-
                                      Proration interval row: for charges on
                                      prorated resources, each interval bills
                                      the usage held during it, priced as if
                                      held for the whole cycle and scaled by the
                                      interval's share of the cycle.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - proration
                                        description: 'Discriminator: proration interval row.'
                                      intervalSize:
                                        type: number
                                        description: >-
                                          Length of the interval, in days of the
                                          billing cycle.
                                      amount:
                                        type: string
                                        description: >-
                                          The prorated amount of the interval, as
                                          a decimal currency-unit string: the
                                          interval usage priced as if held for the
                                          whole cycle, scaled by intervalSize over
                                          the cycle length.
                                        examples:
                                          - '29.0322580645'
                                      usage:
                                        type: number
                                        description: The usage held during the interval.
                                      intervalStart:
                                        type: string
                                        format: date
                                        description: First day of the interval.
                                      intervalEnd:
                                        type: string
                                        format: date
                                        description: Last day of the interval.
                                    required:
                                      - type
                                      - intervalSize
                                      - amount
                                      - usage
                                      - intervalStart
                                      - intervalEnd
                                  - type: object
                                    description: >-
                                      License proration delta row: for per_unit
                                      license charges billing under the
                                      proration model, the cycle-start row bills
                                      the starting licenses beyond the included
                                      quantity at their full-cycle price, and
                                      each change row bills the change in those
                                      licenses prorated over the days remaining
                                      in the cycle. A change that stays inside
                                      the included quantity has no row. Tiered
                                      charges use license_proration_tier
                                      instead. quantityDelta and the row's
                                      amount are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration
                                        description: >-
                                          Discriminator: license proration delta
                                          row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on the cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the licenses beyond the
                                          included quantity (the starting licenses
                                          beyond it on the cycle-start row).
                                          Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity after this
                                          change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on
                                          the cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|. On a cycle-start row
                                          that bills no license, the unit price of
                                          the charge.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                  - type: object
                                    description: >-
                                      Tiered license proration delta row: one
                                      price band of a license charge billing
                                      under the proration model with
                                      tiered_per_unit pricing. The cycle-start
                                      rows bill each band's opening occupancy at
                                      its full-cycle unit price, and each change
                                      row bills that band's occupancy delta
                                      prorated over the days remaining in the
                                      cycle. quantityDelta and the row's amount
                                      are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration_tier
                                        description: >-
                                          Discriminator: tiered license proration
                                          delta row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on a cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the units this band
                                          holds (the band's opening occupancy on a
                                          cycle-start row). Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity across
                                          every band after this change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on a
                                          cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                      planChargeTierId:
                                        type: string
                                        description: >-
                                          The unique identifier of the plan charge
                                          tier this row moved through.
                                        examples:
                                          - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                      from:
                                        type: number
                                        description: >-
                                          Inclusive lower bound of the band, in
                                          licenses.
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Inclusive upper bound of the band, in
                                          licenses. Null on the last, open-ended
                                          band.
                                      unitPrice:
                                        type: string
                                        description: >-
                                          The band's full-cycle price per unit, as
                                          a decimal currency-unit string.
                                          proratedUnitRate is this scaled by
                                          remainingDays over cycleDays.
                                        examples:
                                          - '25.00'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                      - planChargeTierId
                                      - from
                                      - to
                                      - unitPrice
                                  - type: object
                                    description: >-
                                      Unit-price row: billable units multiplied
                                      by a single price per unit. The row's
                                      usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - unit_price
                                        description: 'Discriminator: unit-price row.'
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.25'
                                    required:
                                      - type
                                      - price
                                  - type: object
                                    description: >-
                                      Included-quantity row: the free allotment
                                      of the charge. The row's usage holds the
                                      units consumed within the allotment and
                                      its amount is always zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - included_quantity
                                        description: 'Discriminator: included-quantity row.'
                                      includedQuantity:
                                        type: number
                                        description: >-
                                          Number of resource units included at no
                                          charge before billing starts.
                                    required:
                                      - type
                                      - includedQuantity
                                  - type: object
                                    description: >-
                                      Package-price row: billable units charged
                                      per started package of packageSize units.
                                      The row's usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - package_price
                                        description: 'Discriminator: package-price row.'
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '45.00'
                                      packagesBilled:
                                        type: number
                                        description: >-
                                          Number of packages billed: the billable
                                          units divided by packageSize, rounded
                                          up.
                                    required:
                                      - type
                                      - packageSize
                                      - price
                                      - packagesBilled
                                  - type: object
                                    description: >-
                                      Percentage row: a percentage applied over
                                      a monetary base amount. The row's usage
                                      holds the base amount, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - percentage
                                        description: 'Discriminator: percentage row.'
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount,
                                          as a decimal string from 0 to 100 (up to
                                          6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - percentage
                                  - type: object
                                    description: >-
                                      Per-unit overage row: units beyond the
                                      last tier boundary, billed at the
                                      configured excess unit price. The row's
                                      usage holds the units over the boundary.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - per_unit
                                        description: 'Discriminator: overage billed per unit.'
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          resource units.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per excess unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage overage row: the monetary base
                                      amount beyond the last tier boundary,
                                      billed at the configured excess
                                      percentage. The row's usage holds the base
                                      amount over the boundary, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - percentage
                                        description: >-
                                          Discriminator: overage billed as a
                                          percentage.
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          cents of the monetary base amount.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the excess base
                                          amount, as a decimal string from 0 to
                                          100 (up to 6 decimal places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - percentage
                                  - type: object
                                    description: >-
                                      Original-amount row: surfaces the line
                                      item's pre-adjustment amount when the line
                                      has adjustments (e.g. a discount) but no
                                      price-component rows of its own. The row's
                                      amount equals the line item's
                                      subtotalAmount.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - original_amount
                                        description: 'Discriminator: original-amount row.'
                                    required:
                                      - type
                                  - type: object
                                    description: >-
                                      Fixed unit price row: the quantity of a
                                      fixed charge multiplied by its unit
                                      amount. The row's usage holds the
                                      quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_unit_price
                                        description: 'Discriminator: fixed unit price row.'
                                      amount:
                                        type: integer
                                        minimum: 0
                                        description: Amount of one unit, in cents.
                                    required:
                                      - type
                                      - amount
                                  - type: object
                                    description: >-
                                      Custom row: one component of a custom plan
                                      charge, as its calculator billed it. The
                                      row's name, description, usage,
                                      usageFormat and amount hold the rest of
                                      the component.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: 'Discriminator: custom row.'
                                      key:
                                        type: string
                                        description: >-
                                          The key of the component in the sub-line
                                          schema of the charge's custom charge
                                          definition, such as documents_overage.
                                        examples:
                                          - documents_overage
                                    required:
                                      - type
                                      - key
                            required:
                              - id
                              - type
                              - name
                              - description
                              - usage
                              - usageFormat
                              - amount
                              - metadata
                            additionalProperties: false
                          description: >-
                            Breakdown of the line item amount into priced rows
                            (included quantities, unit/package/tier prices,
                            prorations, companions). Empty for line items
                            without a breakdown.
                        adjustments:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing an adjustment applied on top
                              of a line item subtotal, such as a discount or an
                              allocation offset.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the adjustment in our
                                  system.
                              name:
                                type: string
                                description: >-
                                  Display name of the adjustment as it appears
                                  on the invoice.
                                example: Desconto de boas-vindas
                              type:
                                type: string
                                enum:
                                  - monetary_discount
                                  - allocation_offset
                                description: >-
                                  The kind of adjustment: monetary_discount (a
                                  discount applied to the line item) or
                                  allocation_offset (the share of the amount
                                  moved to another payment account's invoice
                                  under a split allocation strategy).
                              amount:
                                type: number
                                description: >-
                                  Amount of the adjustment, in cents. Negative
                                  when the adjustment reduces the line item
                                  total.
                            required:
                              - id
                              - name
                              - type
                              - amount
                            additionalProperties: false
                          description: >-
                            Adjustments applied on top of the line item
                            subtotal, such as discounts and allocation offsets.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - resourceId
                        - licenseId
                        - lineItemGroupId
                        - name
                        - scope
                        - startDate
                        - endDate
                        - totalUsage
                        - usageFormat
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - metadata
                        - subLineItems
                        - adjustments
                      additionalProperties: false
                    description: >-
                      Line items that do not belong to any line item group (e.g.
                      contract-level minimum commitments, additional charges,
                      and ungrouped one-off items).
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of invoices, keyed by the
                      key of each custom field. The object is empty when the
                      invoice holds no value. A user edits them in the billing
                      app, and `PUT /v1/invoices/{id}/custom-fields` replaces
                      the whole set, in any status of the invoice.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  sentAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When Aira last sent the invoice by e-mail to its invoice
                      recipients, in an invoice delivery. Null when Aira has not
                      sent it.
                  replaceReason:
                    type: string
                    enum:
                      - contract_allocation_changed
                      - manually_reopened
                      - null
                    nullable: true
                    description: >-
                      Why one invoice of the same invoice slot replaced another,
                      on both invoices of the replacement: manually_reopened for
                      a reopening, and contract_allocation_changed when a change
                      to the contract allocation canceled the invoice and a
                      later billing of its billing act replaced it. Null when
                      the invoice replaces no invoice and no invoice replaces
                      it.
                  replacesInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the canceled invoice that this
                      invoice replaces in its invoice slot. Null when the
                      invoice replaces no invoice.
                  replacedByInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the invoice that replaces this
                      canceled invoice in its invoice slot. Null when no invoice
                      replaces it.
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - paymentAccountId
                  - contractId
                  - contractInvoiceSequence
                  - issuingAccount
                  - billingAccount
                  - invoiceAllocationStrategy
                  - lastCalculatedAt
                  - invoiceNumber
                  - invoiceDate
                  - memo
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - status
                  - isLocked
                  - failureReason
                  - source
                  - autoIssue
                  - amountDue
                  - dueDate
                  - lineItemGroups
                  - standaloneLineItems
                  - customFields
                  - sentAt
                  - replaceReason
                  - replacesInvoiceId
                  - replacedByInvoiceId
                additionalProperties: false
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is not an invoice of a
            contract, its contract is completed, it is open, in review or paid,
            it is dated more than four months ago, another invoice already
            replaced it, its contract or a change of the contract allocation
            canceled it, or an invoice of its invoice allocation group is paid
            or has a pending invoice sync.

            - `invalid_license_proration_allocation`: the contract of the
            invoice splits its invoices by the usage of its subsidiaries and
            bills a license-based charge whose billing model is proration.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                      - invalid_license_proration_allocation
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
                invalid_license_proration_allocation:
                  value:
                    message: >-
                      prorated license charges are not supported on contracts
                      that split invoices by subsidiary usage
                    code: invalid_license_proration_allocation
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
  /v1/invoices/{id}/custom-fields:
    put:
      summary: Update the custom fields of an invoice
      tags:
        - Invoices
      description: >-
        Replaces the whole set of custom field values of an invoice, in any
        status, and answers the invoice. A key that the body leaves out loses
        its value.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                customFields:
                  type: object
                  description: >-
                    The values of the custom fields of invoices, keyed by the
                    key of each custom field. They replace the whole set, so a
                    key that the object leaves out loses its value.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
              required:
                - customFields
              additionalProperties: false
        required: true
        description: >-
          The custom field values of the invoice, which replace the values that
          it holds.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the invoice in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_custom_fields
          when: >-
            the `customFields` leave out a required custom field of invoices,
            name a key that is not one, or hold a value that its custom field
            does not take
        - status: 404
          code: invoice_not_found
          when: no invoice has the `id`
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            The invoice, with the custom field values that the request saved.
            Monetary amounts are integers in cents.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the invoice in our system.
                  idempotencyKey:
                    type: string
                    description: >-
                      A unique key that identifies the invoice for idempotent
                      creation. Supplied by the caller for one-off invoices;
                      generated by the billing engine for contract invoices.
                    example: padaria-central-2026-11
                  customerId:
                    type: string
                    format: uuid
                    description: The unique identifier of the customer this invoice bills.
                  paymentAccountId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the customer payment account used
                      as the billing account for this invoice.
                  contractId:
                    type: string
                    nullable: true
                    format: uuid
                    description: >-
                      The unique identifier of the contract that generated this
                      invoice. Null for invoices not generated from a contract
                      (e.g. one-off and imported invoices).
                  contractInvoiceSequence:
                    type: integer
                    minimum: 1
                    nullable: true
                    description: >-
                      The number of the invoice within its contract, in the
                      order that Aira created the contract's invoices: 1 for the
                      first, 2 for the next, and so on. Every invoice gets its
                      own number, including each invoice of a split across
                      payment accounts and the replacement of a reopened
                      invoice, and a number never changes and is never reused.
                      Null for invoices without a contract.
                  issuingAccount:
                    type: object
                    description: >-
                      Snapshot of the legal entity issuing the invoice (the
                      seller), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  billingAccount:
                    type: object
                    description: >-
                      Snapshot of the billed party (the legal entity behind the
                      customer payment account), captured at invoice creation.
                    properties:
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        description: Billing contact email addresses of the legal entity.
                      taxId:
                        type: string
                        description: >-
                          Tax identification number of the legal entity, digits
                          only.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax identification number in taxId (e.g.
                          CNPJ for Brazilian companies, CPF for individuals).
                      zipCode:
                        type: string
                        nullable: true
                        description: >-
                          Postal code of the legal entity address. Null when
                          absent.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: Street of the legal entity address. Null when absent.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          Street number of the legal entity address. Null when
                          absent.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          Neighborhood of the legal entity address. Null when
                          absent.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: City of the legal entity address. Null when absent.
                        example: São Paulo
                      state:
                        type: string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        nullable: true
                        description: >-
                          State of the legal entity address, as a two-letter
                          code. Null when absent.
                      country:
                        type: string
                        enum:
                          - Brasil
                          - null
                        nullable: true
                        description: Country of the legal entity address. Null when absent.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          Address complement of the legal entity address. Null
                          when absent.
                        example: Sala 12
                    required:
                      - tradeName
                      - businessName
                      - emails
                      - taxId
                      - taxIdType
                      - zipCode
                      - street
                      - number
                      - neighborhood
                      - city
                      - state
                      - country
                      - complement
                    additionalProperties: false
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How the originating contract distributes charges across
                      payment accounts: single bills a single payment account;
                      percent_split divides the total between payment accounts
                      by configured percentages; subsidiary_usage_split divides
                      it according to each subsidiary's usage.
                  lastCalculatedAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When the invoice amounts were last computed by the billing
                      engine. Null when the invoice has never been calculated.
                  invoiceNumber:
                    type: string
                    description: >-
                      Human-readable invoice number, built from the customer's
                      invoice prefix plus a sequential counter.
                    example: ACMEI-0042
                  invoiceDate:
                    type: string
                    format: date
                    description: >-
                      The date of the invoice. On a contract invoice it is the
                      date of its billing act: the first day of the first
                      billing cycle that the contract invoices for an activation
                      invoice, and the last day of the billing cycle for a
                      closing invoice. Its line items state the periods that it
                      bills. On a one-off or imported invoice it is the date
                      given when the invoice was created.
                  memo:
                    type: string
                    nullable: true
                    description: >-
                      Free-form memo attached to the invoice. On contract
                      invoices, it reads "Período <start> a <end>" with the
                      period of the line item that bills most often, such as the
                      month when a monthly fee is billed with an annual fee.
                      When two line items bill equally often, it uses the
                      earlier period. Null when absent.
                    example: Período 01/11/2026 a 30/11/2026
                  subtotalAmount:
                    type: number
                    description: >-
                      Sum of the line item subtotals before adjustments, in
                      cents.
                  adjustmentAmount:
                    type: number
                    description: >-
                      Net amount of all adjustments applied to the invoice line
                      items (discounts and allocation offsets), in cents.
                      Negative when adjustments reduce the amount owed.
                  totalAmount:
                    type: number
                    description: >-
                      Final invoice amount, in cents: subtotalAmount +
                      adjustmentAmount.
                  discountAmount:
                    type: number
                    description: >-
                      The discount portion of adjustmentAmount, in cents (sum of
                      monetary discount adjustments only). Negative when
                      discounts were applied.
                  status:
                    type: string
                    enum:
                      - open
                      - in_review
                      - issued
                      - synced
                      - pending
                      - paid
                      - overdue
                      - canceled
                      - failed
                    description: >-
                      Current status of the invoice lifecycle: open
                      (accumulating charges, editable), in_review (flagged for
                      manual review before issuing), issued (finalized and
                      issued to the customer), synced (registered in the
                      external ERP/payment provider), pending (a payment was
                      initiated and awaits settlement), paid, overdue (unpaid
                      past the due date), canceled, or failed (an issue/sync
                      attempt failed and needs attention).
                  isLocked:
                    type: boolean
                    description: >-
                      Whether the invoice contents are locked against edits.
                      Aira locks an invoice when it issues or cancels it,
                      together with the other invoices of its allocation group,
                      except when it cancels the invoice because its payment
                      account left the allocation of the contract, which locks
                      only that invoice. A locked invoice stays locked, also
                      when its status later moves to failed.
                  failureReason:
                    type: string
                    nullable: true
                    description: >-
                      Reason for the most recent failure on the invoice (e.g. an
                      ERP sync or payment issue). Null when the invoice has no
                      active failure.
                    example: contract_sync_not_found
                  source:
                    type: string
                    enum:
                      - contract
                      - one_off
                      - import
                    description: >-
                      How the invoice originated: contract (generated by a
                      contract billing cycle), one_off (created manually or
                      through the API), or import (ingested from an external
                      system).
                  autoIssue:
                    type: boolean
                    description: >-
                      Whether the invoice is issued automatically when its
                      billing cycle closes, without manual review.
                  amountDue:
                    type: number
                    nullable: true
                    description: >-
                      Outstanding amount due on the invoice, in cents. Null when
                      not tracked.
                  dueDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Payment due date of the invoice. Null when no due date is
                      set (e.g. before the invoice is issued).
                  lineItemGroups:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a line item group: a container that
                        gathers the line items generated from one plan instance
                        (or created as a group on one-off invoices). Monetary
                        amounts are integers in cents.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item group in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the group within the
                            invoice. Supplied by the caller for one-off groups;
                            generated by the billing engine otherwise.
                          example: servicos-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this group bills.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this group
                            belongs to.
                        planId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan whose instance
                            generated this group. Null for groups not generated
                            from a plan (e.g. on one-off invoices).
                        planInstanceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the plan instance that
                            generated this group. Null for groups not generated
                            from a plan instance.
                        name:
                          type: string
                          description: >-
                            Display name of the group as it appears on the
                            invoice, typically the plan or product name.
                          example: Plano Entregas
                        startDate:
                          type: string
                          format: date
                          description: >-
                            Start of the period that the group shows. On
                            contract invoices, it is the period of the group's
                            line item that bills most often, such as the month
                            when a monthly fee is billed with an annual fee.
                            When two line items bill equally often, it is the
                            earlier period.
                        endDate:
                          type: string
                          format: date
                          description: >-
                            End of the period that the group shows, which
                            `startDate` describes.
                        subtotalAmount:
                          type: number
                          description: >-
                            Sum of the group's line item subtotals before
                            adjustments, in cents.
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to the group's
                            line items (discounts and allocation offsets), in
                            cents. Negative when adjustments reduce the amount
                            owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final group amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        lineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              One amount on an invoice, such as a plan charge,
                              the contract minimum, a tax gross-up (the withheld
                              ISS, the municipal service tax, added on top), a
                              one-off amount or an additional charge.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the line item in our
                                  system.
                              idempotencyKey:
                                type: string
                                description: >-
                                  A unique key that identifies the line item
                                  within the invoice. Supplied by the caller for
                                  one-off line items; generated by the billing
                                  engine otherwise.
                                example: entrega-novembro
                              customerId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the customer whose
                                  consumption this line item bills. On split or
                                  consolidated invoices it may be a subsidiary
                                  of the invoice's customer.
                              productId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the product this line
                                  item belongs to.
                              itemId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the catalog item this
                                  line bills. Null for line items not backed by
                                  a catalog item.
                              resourceId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the metered resource
                                  behind a usage_based line item. Null for line
                                  items not driven by resource usage.
                              licenseId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the license behind a
                                  license_based line item. Null for line items
                                  not driven by a license count.
                              lineItemGroupId:
                                type: string
                                nullable: true
                                format: uuid
                                description: >-
                                  The unique identifier of the line item group
                                  containing this line item. Null for standalone
                                  line items.
                              name:
                                type: string
                                description: >-
                                  Display name of the line item as it appears on
                                  the invoice.
                                example: Entregas
                              scope:
                                type: string
                                enum:
                                  - credit_purchase
                                  - contract_minimum_commitment
                                  - minimum_commitment
                                  - fixed
                                  - usage_based
                                  - license_based
                                  - custom
                                  - additional_charge
                                  - one_off
                                  - tax_gross_up
                                description: >-
                                  What the line item charges for: usage_based
                                  (metered resource consumption), license_based
                                  (a license's reported count billed in full),
                                  fixed (recurring fixed charge of a plan),
                                  custom (custom plan charge, priced by a
                                  calculator that Aira writes for you),
                                  minimum_commitment (plan-level minimum
                                  top-up), contract_minimum_commitment
                                  (contract-level minimum top-up),
                                  credit_purchase (credit pool top-up),
                                  additional_charge (extra charge added
                                  manually), one_off (line item of a one-off
                                  invoice), or tax_gross_up (tax gross-up
                                  charge).
                              startDate:
                                type: string
                                format: date
                                description: Start of the period covered by this line item.
                              endDate:
                                type: string
                                format: date
                                description: End of the period covered by this line item.
                              totalUsage:
                                type: number
                                nullable: true
                                description: >-
                                  Total usage billed by the line item, in the
                                  unit given by usageFormat. Null for line items
                                  without a single usage (e.g. fixed charges
                                  without a quantity, and custom line items
                                  whose calculator returns no total).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read totalUsage, and the usage of each
                                  sub-line item that has no usageFormat of its
                                  own: unit means a count of resource units or a
                                  fixed charge quantity; currency means a
                                  monetary base amount in cents. Null when the
                                  line item has no single usage, as a custom
                                  line item whose sub-line items bill different
                                  kinds of volume, each with its own
                                  usageFormat.
                              subtotalAmount:
                                type: number
                                description: >-
                                  Line item amount before adjustments, in cents
                                  (sum of its sub-line item amounts).
                              adjustmentAmount:
                                type: number
                                description: >-
                                  Net amount of the adjustments applied to this
                                  line item (discounts and allocation offsets),
                                  in cents. Negative when adjustments reduce the
                                  amount owed.
                              totalAmount:
                                type: number
                                description: >-
                                  Final line item amount, in cents:
                                  subtotalAmount + adjustmentAmount.
                              discountAmount:
                                type: number
                                description: >-
                                  The discount portion of adjustmentAmount, in
                                  cents (sum of monetary discount adjustments
                                  only). Negative when discounts were applied.
                              metadata:
                                description: >-
                                  Pricing metadata for the line item, where the
                                  shape is keyed by type. Always present, but
                                  null for line items without pricing metadata:
                                  credit_purchase, additional_charge, one_off,
                                  and tax_gross_up. It is populated for fixed
                                  (the billing timing), usage_based,
                                  license_based, minimum_commitment,
                                  contract_minimum_commitment, and custom (the
                                  definition and the calculation memory) line
                                  items.
                                anyOf:
                                  - title: Fixed
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed
                                        description: >-
                                          Discriminator: metadata for a fixed line
                                          item.
                                      billingTiming:
                                        type: string
                                        enum:
                                          - in_advance
                                          - in_arrears
                                        description: >-
                                          Whether the fee was billed in advance of
                                          its service period or after it.
                                    required:
                                      - type
                                      - billingTiming
                                  - title: Usage-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - usage_based
                                        description: >-
                                          Discriminator: metadata for a
                                          usage_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the metered resource accrues over
                                          the billing period: in_full bills the
                                          full usage of the period; proration
                                          weighs usage by the fraction of the
                                          period each amount was held.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          usage was divided across tiers.
                                          unique_tier prices all usage at the
                                          single tier that contains the total;
                                          progressive prices each tier's band
                                          separately. Absent for non-tiered
                                          models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item. Charges
                                          priced before pricing models existed are
                                          reported as advanced.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: License-based
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_based
                                        description: >-
                                          Discriminator: metadata for a
                                          license_based line item.
                                      billingModel:
                                        type: string
                                        enum:
                                          - in_full
                                          - proration
                                        description: >-
                                          How the license count accrues over the
                                          billing period. Always in_full: the
                                          latest reported count is billed in full.
                                      priceTierDivision:
                                        type: string
                                        enum:
                                          - unique_tier
                                          - progressive
                                        description: >-
                                          For tier-based pricing models only: how
                                          the license count was divided across
                                          tiers. unique_tier prices the whole
                                          count at the single tier that contains
                                          the total; progressive prices each
                                          tier's band separately. Absent for
                                          non-tiered models.
                                      pricingModel:
                                        type: string
                                        enum:
                                          - fixed
                                          - per_unit
                                          - per_package
                                          - percentage
                                          - tiered_per_unit
                                          - tiered_percentage
                                          - tiered_fixed
                                          - advanced
                                          - custom
                                        description: >-
                                          The pricing model of the plan charge
                                          that produced this line item.
                                    required:
                                      - type
                                      - billingModel
                                      - pricingModel
                                  - title: Contract minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - contract_minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a
                                          contract_minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          whole contract in the billing period, in
                                          cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the contract's consumption amounted
                                          to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Minimum commitment
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_commitment
                                        description: >-
                                          Discriminator: metadata for a plan-level
                                          minimum_commitment line item.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount committed for the
                                          plan in the billing period, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up charged by this line item to
                                          reach the committed minimum, in cents:
                                          the difference between minimumAmount and
                                          what the plan's consumption amounted to.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - title: Custom
                                    type: object
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: >-
                                          Discriminator: metadata for a custom
                                          line item.
                                      definitionKey:
                                        type: string
                                        description: >-
                                          The key of the custom charge definition
                                          whose calculator priced the charge,
                                          following the
                                          custom:charge:<slug>:<name> convention.
                                        examples:
                                          - custom:charge:padaria-central:entregas
                                      memory:
                                        type: object
                                        additionalProperties: true
                                        description: >-
                                          The full calculation memory that the
                                          calculator returned, such as every tier
                                          it evaluated and the one it billed. Its
                                          shape belongs to the definition.
                                    required:
                                      - type
                                      - definitionKey
                                      - memory
                                  - title: No metadata
                                    type: 'null'
                              subLineItems:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing a sub-line item: one
                                    priced row of a line item's breakdown. The
                                    row type dictates the shape of metadata.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the sub-line
                                        item in our system.
                                    type:
                                      type: string
                                      enum:
                                        - fixed_price
                                        - minimum_amount
                                        - price_tier_flat
                                        - price_tier_unit
                                        - price_tier_package
                                        - price_tier_percentage
                                        - proration
                                        - license_proration
                                        - license_proration_tier
                                        - unit_price
                                        - included_quantity
                                        - package_price
                                        - percentage
                                        - overage
                                        - original_amount
                                        - fixed_unit_price
                                        - custom
                                      description: >-
                                        The kind of priced row: fixed_price and
                                        minimum_amount are companions of
                                        usage-based charges; unit_price,
                                        package_price, percentage, and
                                        included_quantity break down
                                        single-model pricing; price_tier_* rows
                                        break down tiered pricing; overage bills
                                        usage beyond the last tier; proration
                                        bills per prorated interval;
                                        license_proration bills license deltas
                                        (removals are negative); original_amount
                                        surfaces the pre-adjustment amount of an
                                        adjusted line; fixed_unit_price breaks
                                        down a fixed charge billed as a quantity
                                        times a unit amount; custom bills one
                                        component of a custom plan charge.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the sub-line item as it
                                        appears on the invoice breakdown.
                                      example: '[A partir de 1] Unidades'
                                    description:
                                      type: string
                                      nullable: true
                                      description: >-
                                        Optional descriptive text for the row.
                                        Null when absent.
                                      example: 120 x 2,50
                                    usage:
                                      type: number
                                      nullable: true
                                      description: >-
                                        The usage billed by this row: a count of
                                        resource units (the quantity for a
                                        fixed_unit_price row), or a monetary
                                        base amount in cents for
                                        percentage-priced rows (see the row's
                                        usageFormat, or the line item
                                        usageFormat when the row has none). Null
                                        for rows without usage (e.g.
                                        companions).
                                    usageFormat:
                                      type: string
                                      enum:
                                        - unit
                                        - currency
                                        - null
                                      nullable: true
                                      description: >-
                                        How to read the usage of this row when
                                        the row has a format of its own, as the
                                        custom rows of a custom line item do:
                                        unit means a count, currency means an
                                        amount in cents. Null when the row reads
                                        its usage in the line item usageFormat.
                                    amount:
                                      type: number
                                      description: >-
                                        Amount billed by this row, in cents. The
                                        sum of a line item's sub-line amounts
                                        equals its subtotalAmount.
                                    metadata:
                                      description: >-
                                        Pricing details of the row, keyed by the
                                        row type (and pricingType for overage
                                        rows).
                                      anyOf:
                                        - type: object
                                          description: >-
                                            Fixed-price companion row: the charge's
                                            configured fixed amount, billed
                                            alongside the usage rows. Only rendered
                                            when configured greater than zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_price
                                              description: >-
                                                Discriminator: fixed-price companion
                                                row.
                                            fixedPrice:
                                              type: number
                                              description: >-
                                                The fixed amount configured on the
                                                charge, in cents.
                                          required:
                                            - type
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Minimum-amount companion row: tops the
                                            charge up to its configured minimum when
                                            usage alone stays below it. Only
                                            rendered when the top-up is greater than
                                            zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - minimum_amount
                                              description: >-
                                                Discriminator: minimum-amount companion
                                                row.
                                            minimumAmount:
                                              type: number
                                              description: >-
                                                The minimum amount configured on the
                                                charge, in cents.
                                            minimumAmountApplied:
                                              type: number
                                              description: >-
                                                The top-up billed by this row to reach
                                                the configured minimum, in cents.
                                          required:
                                            - type
                                            - minimumAmount
                                            - minimumAmountApplied
                                        - type: object
                                          description: >-
                                            Flat-priced tier row: usage falling in
                                            this tier band is billed at a flat
                                            amount, regardless of the exact
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_flat
                                              description: 'Discriminator: flat-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            fixedPrice:
                                              type: string
                                              description: >-
                                                The flat amount billed for the tier, as
                                                a decimal currency-unit string.
                                              examples:
                                                - '150.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Per-unit priced tier row: units
                                            attributed to this tier band are billed
                                            at the tier's unit price.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_unit
                                              description: 'Discriminator: per-unit priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            price:
                                              type: string
                                              description: >-
                                                Price per unit within the tier, as a
                                                decimal currency-unit string.
                                              examples:
                                                - '0.25'
                                            fixedPrice:
                                              type: string
                                              nullable: true
                                              description: >-
                                                Optional flat fee billed on top when the
                                                tier applies, as a decimal currency-unit
                                                string. Null when the tier has no flat
                                                fee.
                                              examples:
                                                - '10.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - price
                                            - fixedPrice
                                        - type: object
                                          description: >-
                                            Package-priced tier row: units
                                            attributed to this tier band are billed
                                            per started package of packageSize
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_package
                                              description: 'Discriminator: package-priced tier row.'
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in
                                                resource units (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in
                                                resource units (inclusive). Null for an
                                                unbounded final tier.
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string.
                                              examples:
                                                - '45.00'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - packageSize
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage-priced tier row: the monetary
                                            base amount attributed to this tier band
                                            is billed at a percentage.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - price_tier_percentage
                                              description: >-
                                                Discriminator: percentage-priced tier
                                                row.
                                            from:
                                              type: number
                                              description: >-
                                                Lower bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Upper bound of the tier band, in cents
                                                of the monetary base amount (inclusive).
                                                Null for an unbounded final tier.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount
                                                within the tier, as a decimal string
                                                from 0 to 100 (up to 6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - from
                                            - to
                                            - percentage
                                        - type: object
                                          description: >-
                                            Proration interval row: for charges on
                                            prorated resources, each interval bills
                                            the usage held during it, priced as if
                                            held for the whole cycle and scaled by
                                            the interval's share of the cycle.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - proration
                                              description: 'Discriminator: proration interval row.'
                                            intervalSize:
                                              type: number
                                              description: >-
                                                Length of the interval, in days of the
                                                billing cycle.
                                            amount:
                                              type: string
                                              description: >-
                                                The prorated amount of the interval, as
                                                a decimal currency-unit string: the
                                                interval usage priced as if held for the
                                                whole cycle, scaled by intervalSize over
                                                the cycle length.
                                              examples:
                                                - '29.0322580645'
                                            usage:
                                              type: number
                                              description: The usage held during the interval.
                                            intervalStart:
                                              type: string
                                              format: date
                                              description: First day of the interval.
                                            intervalEnd:
                                              type: string
                                              format: date
                                              description: Last day of the interval.
                                          required:
                                            - type
                                            - intervalSize
                                            - amount
                                            - usage
                                            - intervalStart
                                            - intervalEnd
                                        - type: object
                                          description: >-
                                            License proration delta row: for
                                            per_unit license charges billing under
                                            the proration model, the cycle-start row
                                            bills the starting licenses beyond the
                                            included quantity at their full-cycle
                                            price, and each change row bills the
                                            change in those licenses prorated over
                                            the days remaining in the cycle. A
                                            change that stays inside the included
                                            quantity has no row. Tiered charges use
                                            license_proration_tier instead.
                                            quantityDelta and the row's amount are
                                            signed — removals are negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration
                                              description: >-
                                                Discriminator: license proration delta
                                                row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on the cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the licenses beyond the
                                                included quantity (the starting licenses
                                                beyond it on the cycle-start row).
                                                Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity after this
                                                change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on
                                                the cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|. On a cycle-start row
                                                that bills no license, the unit price of
                                                the charge.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                        - type: object
                                          description: >-
                                            Tiered license proration delta row: one
                                            price band of a license charge billing
                                            under the proration model with
                                            tiered_per_unit pricing. The cycle-start
                                            rows bill each band's opening occupancy
                                            at its full-cycle unit price, and each
                                            change row bills that band's occupancy
                                            delta prorated over the days remaining
                                            in the cycle. quantityDelta and the
                                            row's amount are signed — removals are
                                            negative.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - license_proration_tier
                                              description: >-
                                                Discriminator: tiered license proration
                                                delta row.
                                            changeDate:
                                              type: string
                                              format: date
                                              nullable: true
                                              description: >-
                                                The day the combined license quantity
                                                changed. Null on a cycle-start row.
                                            quantityDelta:
                                              type: number
                                              description: >-
                                                Signed change in the units this band
                                                holds (the band's opening occupancy on a
                                                cycle-start row). Negative for removals.
                                            quantity:
                                              type: number
                                              description: >-
                                                The combined license quantity across
                                                every band after this change.
                                            remainingDays:
                                              type: number
                                              description: >-
                                                Days from the change (inclusive) to the
                                                end of the cycle. Equals cycleDays on a
                                                cycle-start row.
                                            cycleDays:
                                              type: number
                                              description: Length of the billing cycle, in days.
                                            proratedUnitRate:
                                              type: string
                                              description: >-
                                                Absolute effective per-unit rate of the
                                                row over the remaining window, as a
                                                decimal currency-unit string: |amount| /
                                                |quantityDelta|.
                                              examples:
                                                - '16.1290322581'
                                            amount:
                                              type: string
                                              description: >-
                                                The signed prorated amount of the row,
                                                as a decimal currency-unit string.
                                              examples:
                                                - '48.3870967742'
                                            planChargeTierId:
                                              type: string
                                              description: >-
                                                The unique identifier of the plan charge
                                                tier this row moved through.
                                              examples:
                                                - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                            from:
                                              type: number
                                              description: >-
                                                Inclusive lower bound of the band, in
                                                licenses.
                                            to:
                                              type: number
                                              nullable: true
                                              description: >-
                                                Inclusive upper bound of the band, in
                                                licenses. Null on the last, open-ended
                                                band.
                                            unitPrice:
                                              type: string
                                              description: >-
                                                The band's full-cycle price per unit, as
                                                a decimal currency-unit string.
                                                proratedUnitRate is this scaled by
                                                remainingDays over cycleDays.
                                              examples:
                                                - '25.00'
                                          required:
                                            - type
                                            - changeDate
                                            - quantityDelta
                                            - quantity
                                            - remainingDays
                                            - cycleDays
                                            - proratedUnitRate
                                            - amount
                                            - planChargeTierId
                                            - from
                                            - to
                                            - unitPrice
                                        - type: object
                                          description: >-
                                            Unit-price row: billable units
                                            multiplied by a single price per unit.
                                            The row's usage holds the billable
                                            units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - unit_price
                                              description: 'Discriminator: unit-price row.'
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.25'
                                          required:
                                            - type
                                            - price
                                        - type: object
                                          description: >-
                                            Included-quantity row: the free
                                            allotment of the charge. The row's usage
                                            holds the units consumed within the
                                            allotment and its amount is always zero.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - included_quantity
                                              description: 'Discriminator: included-quantity row.'
                                            includedQuantity:
                                              type: number
                                              description: >-
                                                Number of resource units included at no
                                                charge before billing starts.
                                          required:
                                            - type
                                            - includedQuantity
                                        - type: object
                                          description: >-
                                            Package-price row: billable units
                                            charged per started package of
                                            packageSize units. The row's usage holds
                                            the billable units.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - package_price
                                              description: 'Discriminator: package-price row.'
                                            packageSize:
                                              type: number
                                              description: Number of resource units per package.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per package, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '45.00'
                                            packagesBilled:
                                              type: number
                                              description: >-
                                                Number of packages billed: the billable
                                                units divided by packageSize, rounded
                                                up.
                                          required:
                                            - type
                                            - packageSize
                                            - price
                                            - packagesBilled
                                        - type: object
                                          description: >-
                                            Percentage row: a percentage applied
                                            over a monetary base amount. The row's
                                            usage holds the base amount, in cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - percentage
                                              description: 'Discriminator: percentage row.'
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the base amount,
                                                as a decimal string from 0 to 100 (up to
                                                6 decimal places).
                                              examples:
                                                - '2.5'
                                          required:
                                            - type
                                            - percentage
                                        - type: object
                                          description: >-
                                            Per-unit overage row: units beyond the
                                            last tier boundary, billed at the
                                            configured excess unit price. The row's
                                            usage holds the units over the boundary.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - per_unit
                                              description: 'Discriminator: overage billed per unit.'
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                resource units.
                                            price:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                Price per excess unit, as a decimal
                                                currency-unit string (up to 6 decimal
                                                places).
                                              examples:
                                                - '0.30'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - price
                                        - type: object
                                          description: >-
                                            Percentage overage row: the monetary
                                            base amount beyond the last tier
                                            boundary, billed at the configured
                                            excess percentage. The row's usage holds
                                            the base amount over the boundary, in
                                            cents.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - overage
                                              description: 'Discriminator: overage row.'
                                            pricingType:
                                              type: string
                                              enum:
                                                - percentage
                                              description: >-
                                                Discriminator: overage billed as a
                                                percentage.
                                            from:
                                              type: number
                                              description: >-
                                                The boundary the overage starts from:
                                                the upper bound of the last tier, in
                                                cents of the monetary base amount.
                                            percentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                Percentage applied to the excess base
                                                amount, as a decimal string from 0 to
                                                100 (up to 6 decimal places).
                                              examples:
                                                - '1.5'
                                          required:
                                            - type
                                            - pricingType
                                            - from
                                            - percentage
                                        - type: object
                                          description: >-
                                            Original-amount row: surfaces the line
                                            item's pre-adjustment amount when the
                                            line has adjustments (e.g. a discount)
                                            but no price-component rows of its own.
                                            The row's amount equals the line item's
                                            subtotalAmount.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - original_amount
                                              description: 'Discriminator: original-amount row.'
                                          required:
                                            - type
                                        - type: object
                                          description: >-
                                            Fixed unit price row: the quantity of a
                                            fixed charge multiplied by its unit
                                            amount. The row's usage holds the
                                            quantity.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - fixed_unit_price
                                              description: 'Discriminator: fixed unit price row.'
                                            amount:
                                              type: integer
                                              minimum: 0
                                              description: Amount of one unit, in cents.
                                          required:
                                            - type
                                            - amount
                                        - type: object
                                          description: >-
                                            Custom row: one component of a custom
                                            plan charge, as its calculator billed
                                            it. The row's name, description, usage,
                                            usageFormat and amount hold the rest of
                                            the component.
                                          properties:
                                            type:
                                              type: string
                                              enum:
                                                - custom
                                              description: 'Discriminator: custom row.'
                                            key:
                                              type: string
                                              description: >-
                                                The key of the component in the sub-line
                                                schema of the charge's custom charge
                                                definition, such as documents_overage.
                                              examples:
                                                - documents_overage
                                          required:
                                            - type
                                            - key
                                  required:
                                    - id
                                    - type
                                    - name
                                    - description
                                    - usage
                                    - usageFormat
                                    - amount
                                    - metadata
                                  additionalProperties: false
                                description: >-
                                  Breakdown of the line item amount into priced
                                  rows (included quantities, unit/package/tier
                                  prices, prorations, companions). Empty for
                                  line items without a breakdown.
                              adjustments:
                                type: array
                                items:
                                  type: object
                                  description: >-
                                    Schema representing an adjustment applied on
                                    top of a line item subtotal, such as a
                                    discount or an allocation offset.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the adjustment
                                        in our system.
                                    name:
                                      type: string
                                      description: >-
                                        Display name of the adjustment as it
                                        appears on the invoice.
                                      example: Desconto de boas-vindas
                                    type:
                                      type: string
                                      enum:
                                        - monetary_discount
                                        - allocation_offset
                                      description: >-
                                        The kind of adjustment:
                                        monetary_discount (a discount applied to
                                        the line item) or allocation_offset (the
                                        share of the amount moved to another
                                        payment account's invoice under a split
                                        allocation strategy).
                                    amount:
                                      type: number
                                      description: >-
                                        Amount of the adjustment, in cents.
                                        Negative when the adjustment reduces the
                                        line item total.
                                  required:
                                    - id
                                    - name
                                    - type
                                    - amount
                                  additionalProperties: false
                                description: >-
                                  Adjustments applied on top of the line item
                                  subtotal, such as discounts and allocation
                                  offsets.
                            required:
                              - id
                              - idempotencyKey
                              - customerId
                              - productId
                              - resourceId
                              - licenseId
                              - lineItemGroupId
                              - name
                              - scope
                              - startDate
                              - endDate
                              - totalUsage
                              - usageFormat
                              - subtotalAmount
                              - adjustmentAmount
                              - totalAmount
                              - discountAmount
                              - metadata
                              - subLineItems
                              - adjustments
                            additionalProperties: false
                          description: The line items contained in this group.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - planId
                        - planInstanceId
                        - name
                        - startDate
                        - endDate
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - lineItems
                      additionalProperties: false
                    description: >-
                      Line item groups on the invoice. Each group gathers the
                      line items generated from one plan instance (or created as
                      a group on one-off invoices).
                  standaloneLineItems:
                    type: array
                    items:
                      type: object
                      description: >-
                        One amount on an invoice, such as a plan charge, the
                        contract minimum, a tax gross-up (the withheld ISS, the
                        municipal service tax, added on top), a one-off amount
                        or an additional charge.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the line item in our
                            system.
                        idempotencyKey:
                          type: string
                          description: >-
                            A unique key that identifies the line item within
                            the invoice. Supplied by the caller for one-off line
                            items; generated by the billing engine otherwise.
                          example: entrega-novembro
                        customerId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the customer whose
                            consumption this line item bills. On split or
                            consolidated invoices it may be a subsidiary of the
                            invoice's customer.
                        productId:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the product this line item
                            belongs to.
                        itemId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the catalog item this line
                            bills. Null for line items not backed by a catalog
                            item.
                        resourceId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the metered resource behind
                            a usage_based line item. Null for line items not
                            driven by resource usage.
                        licenseId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the license behind a
                            license_based line item. Null for line items not
                            driven by a license count.
                        lineItemGroupId:
                          type: string
                          nullable: true
                          format: uuid
                          description: >-
                            The unique identifier of the line item group
                            containing this line item. Null for standalone line
                            items.
                        name:
                          type: string
                          description: >-
                            Display name of the line item as it appears on the
                            invoice.
                          example: Entregas
                        scope:
                          type: string
                          enum:
                            - credit_purchase
                            - contract_minimum_commitment
                            - minimum_commitment
                            - fixed
                            - usage_based
                            - license_based
                            - custom
                            - additional_charge
                            - one_off
                            - tax_gross_up
                          description: >-
                            What the line item charges for: usage_based (metered
                            resource consumption), license_based (a license's
                            reported count billed in full), fixed (recurring
                            fixed charge of a plan), custom (custom plan charge,
                            priced by a calculator that Aira writes for you),
                            minimum_commitment (plan-level minimum top-up),
                            contract_minimum_commitment (contract-level minimum
                            top-up), credit_purchase (credit pool top-up),
                            additional_charge (extra charge added manually),
                            one_off (line item of a one-off invoice), or
                            tax_gross_up (tax gross-up charge).
                        startDate:
                          type: string
                          format: date
                          description: Start of the period covered by this line item.
                        endDate:
                          type: string
                          format: date
                          description: End of the period covered by this line item.
                        totalUsage:
                          type: number
                          nullable: true
                          description: >-
                            Total usage billed by the line item, in the unit
                            given by usageFormat. Null for line items without a
                            single usage (e.g. fixed charges without a quantity,
                            and custom line items whose calculator returns no
                            total).
                        usageFormat:
                          type: string
                          enum:
                            - unit
                            - currency
                            - null
                          nullable: true
                          description: >-
                            How to read totalUsage, and the usage of each
                            sub-line item that has no usageFormat of its own:
                            unit means a count of resource units or a fixed
                            charge quantity; currency means a monetary base
                            amount in cents. Null when the line item has no
                            single usage, as a custom line item whose sub-line
                            items bill different kinds of volume, each with its
                            own usageFormat.
                        subtotalAmount:
                          type: number
                          description: >-
                            Line item amount before adjustments, in cents (sum
                            of its sub-line item amounts).
                        adjustmentAmount:
                          type: number
                          description: >-
                            Net amount of the adjustments applied to this line
                            item (discounts and allocation offsets), in cents.
                            Negative when adjustments reduce the amount owed.
                        totalAmount:
                          type: number
                          description: >-
                            Final line item amount, in cents: subtotalAmount +
                            adjustmentAmount.
                        discountAmount:
                          type: number
                          description: >-
                            The discount portion of adjustmentAmount, in cents
                            (sum of monetary discount adjustments only).
                            Negative when discounts were applied.
                        metadata:
                          description: >-
                            Pricing metadata for the line item, where the shape
                            is keyed by type. Always present, but null for line
                            items without pricing metadata: credit_purchase,
                            additional_charge, one_off, and tax_gross_up. It is
                            populated for fixed (the billing timing),
                            usage_based, license_based, minimum_commitment,
                            contract_minimum_commitment, and custom (the
                            definition and the calculation memory) line items.
                          anyOf:
                            - title: Fixed
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed
                                  description: >-
                                    Discriminator: metadata for a fixed line
                                    item.
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    Whether the fee was billed in advance of its
                                    service period or after it.
                              required:
                                - type
                                - billingTiming
                            - title: Usage-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - usage_based
                                  description: >-
                                    Discriminator: metadata for a usage_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the metered resource accrues over the
                                    billing period: in_full bills the full usage
                                    of the period; proration weighs usage by the
                                    fraction of the period each amount was held.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how
                                    usage was divided across tiers. unique_tier
                                    prices all usage at the single tier that
                                    contains the total; progressive prices each
                                    tier's band separately. Absent for
                                    non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item. Charges priced
                                    before pricing models existed are reported
                                    as advanced.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: License-based
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - license_based
                                  description: >-
                                    Discriminator: metadata for a license_based
                                    line item.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the license count accrues over the
                                    billing period. Always in_full: the latest
                                    reported count is billed in full.
                                priceTierDivision:
                                  type: string
                                  enum:
                                    - unique_tier
                                    - progressive
                                  description: >-
                                    For tier-based pricing models only: how the
                                    license count was divided across tiers.
                                    unique_tier prices the whole count at the
                                    single tier that contains the total;
                                    progressive prices each tier's band
                                    separately. Absent for non-tiered models.
                                pricingModel:
                                  type: string
                                  enum:
                                    - fixed
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                    - custom
                                  description: >-
                                    The pricing model of the plan charge that
                                    produced this line item.
                              required:
                                - type
                                - billingModel
                                - pricingModel
                            - title: Contract minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - contract_minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a
                                    contract_minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the whole
                                    contract in the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the contract's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Minimum commitment
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_commitment
                                  description: >-
                                    Discriminator: metadata for a plan-level
                                    minimum_commitment line item.
                                minimumAmount:
                                  type: number
                                  description: >-
                                    The minimum amount committed for the plan in
                                    the billing period, in cents.
                                minimumAmountApplied:
                                  type: number
                                  description: >-
                                    The top-up charged by this line item to
                                    reach the committed minimum, in cents: the
                                    difference between minimumAmount and what
                                    the plan's consumption amounted to.
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - title: Custom
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - custom
                                  description: >-
                                    Discriminator: metadata for a custom line
                                    item.
                                definitionKey:
                                  type: string
                                  description: >-
                                    The key of the custom charge definition
                                    whose calculator priced the charge,
                                    following the custom:charge:<slug>:<name>
                                    convention.
                                  examples:
                                    - custom:charge:padaria-central:entregas
                                memory:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The full calculation memory that the
                                    calculator returned, such as every tier it
                                    evaluated and the one it billed. Its shape
                                    belongs to the definition.
                              required:
                                - type
                                - definitionKey
                                - memory
                            - title: No metadata
                              type: 'null'
                        subLineItems:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing a sub-line item: one priced
                              row of a line item's breakdown. The row type
                              dictates the shape of metadata.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the sub-line item in
                                  our system.
                              type:
                                type: string
                                enum:
                                  - fixed_price
                                  - minimum_amount
                                  - price_tier_flat
                                  - price_tier_unit
                                  - price_tier_package
                                  - price_tier_percentage
                                  - proration
                                  - license_proration
                                  - license_proration_tier
                                  - unit_price
                                  - included_quantity
                                  - package_price
                                  - percentage
                                  - overage
                                  - original_amount
                                  - fixed_unit_price
                                  - custom
                                description: >-
                                  The kind of priced row: fixed_price and
                                  minimum_amount are companions of usage-based
                                  charges; unit_price, package_price,
                                  percentage, and included_quantity break down
                                  single-model pricing; price_tier_* rows break
                                  down tiered pricing; overage bills usage
                                  beyond the last tier; proration bills per
                                  prorated interval; license_proration bills
                                  license deltas (removals are negative);
                                  original_amount surfaces the pre-adjustment
                                  amount of an adjusted line; fixed_unit_price
                                  breaks down a fixed charge billed as a
                                  quantity times a unit amount; custom bills one
                                  component of a custom plan charge.
                              name:
                                type: string
                                description: >-
                                  Display name of the sub-line item as it
                                  appears on the invoice breakdown.
                                example: '[A partir de 1] Unidades'
                              description:
                                type: string
                                nullable: true
                                description: >-
                                  Optional descriptive text for the row. Null
                                  when absent.
                                example: 120 x 2,50
                              usage:
                                type: number
                                nullable: true
                                description: >-
                                  The usage billed by this row: a count of
                                  resource units (the quantity for a
                                  fixed_unit_price row), or a monetary base
                                  amount in cents for percentage-priced rows
                                  (see the row's usageFormat, or the line item
                                  usageFormat when the row has none). Null for
                                  rows without usage (e.g. companions).
                              usageFormat:
                                type: string
                                enum:
                                  - unit
                                  - currency
                                  - null
                                nullable: true
                                description: >-
                                  How to read the usage of this row when the row
                                  has a format of its own, as the custom rows of
                                  a custom line item do: unit means a count,
                                  currency means an amount in cents. Null when
                                  the row reads its usage in the line item
                                  usageFormat.
                              amount:
                                type: number
                                description: >-
                                  Amount billed by this row, in cents. The sum
                                  of a line item's sub-line amounts equals its
                                  subtotalAmount.
                              metadata:
                                description: >-
                                  Pricing details of the row, keyed by the row
                                  type (and pricingType for overage rows).
                                anyOf:
                                  - type: object
                                    description: >-
                                      Fixed-price companion row: the charge's
                                      configured fixed amount, billed alongside
                                      the usage rows. Only rendered when
                                      configured greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_price
                                        description: >-
                                          Discriminator: fixed-price companion
                                          row.
                                      fixedPrice:
                                        type: number
                                        description: >-
                                          The fixed amount configured on the
                                          charge, in cents.
                                    required:
                                      - type
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Minimum-amount companion row: tops the
                                      charge up to its configured minimum when
                                      usage alone stays below it. Only rendered
                                      when the top-up is greater than zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - minimum_amount
                                        description: >-
                                          Discriminator: minimum-amount companion
                                          row.
                                      minimumAmount:
                                        type: number
                                        description: >-
                                          The minimum amount configured on the
                                          charge, in cents.
                                      minimumAmountApplied:
                                        type: number
                                        description: >-
                                          The top-up billed by this row to reach
                                          the configured minimum, in cents.
                                    required:
                                      - type
                                      - minimumAmount
                                      - minimumAmountApplied
                                  - type: object
                                    description: >-
                                      Flat-priced tier row: usage falling in
                                      this tier band is billed at a flat amount,
                                      regardless of the exact quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_flat
                                        description: 'Discriminator: flat-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      fixedPrice:
                                        type: string
                                        description: >-
                                          The flat amount billed for the tier, as
                                          a decimal currency-unit string.
                                        examples:
                                          - '150.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Per-unit priced tier row: units attributed
                                      to this tier band are billed at the tier's
                                      unit price.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_unit
                                        description: 'Discriminator: per-unit priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      price:
                                        type: string
                                        description: >-
                                          Price per unit within the tier, as a
                                          decimal currency-unit string.
                                        examples:
                                          - '0.25'
                                      fixedPrice:
                                        type: string
                                        nullable: true
                                        description: >-
                                          Optional flat fee billed on top when the
                                          tier applies, as a decimal currency-unit
                                          string. Null when the tier has no flat
                                          fee.
                                        examples:
                                          - '10.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - price
                                      - fixedPrice
                                  - type: object
                                    description: >-
                                      Package-priced tier row: units attributed
                                      to this tier band are billed per started
                                      package of packageSize units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_package
                                        description: 'Discriminator: package-priced tier row.'
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in
                                          resource units (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in
                                          resource units (inclusive). Null for an
                                          unbounded final tier.
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string.
                                        examples:
                                          - '45.00'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - packageSize
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage-priced tier row: the monetary
                                      base amount attributed to this tier band
                                      is billed at a percentage.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - price_tier_percentage
                                        description: >-
                                          Discriminator: percentage-priced tier
                                          row.
                                      from:
                                        type: number
                                        description: >-
                                          Lower bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Upper bound of the tier band, in cents
                                          of the monetary base amount (inclusive).
                                          Null for an unbounded final tier.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          within the tier, as a decimal string
                                          from 0 to 100 (up to 6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - from
                                      - to
                                      - percentage
                                  - type: object
                                    description: >-
                                      Proration interval row: for charges on
                                      prorated resources, each interval bills
                                      the usage held during it, priced as if
                                      held for the whole cycle and scaled by the
                                      interval's share of the cycle.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - proration
                                        description: 'Discriminator: proration interval row.'
                                      intervalSize:
                                        type: number
                                        description: >-
                                          Length of the interval, in days of the
                                          billing cycle.
                                      amount:
                                        type: string
                                        description: >-
                                          The prorated amount of the interval, as
                                          a decimal currency-unit string: the
                                          interval usage priced as if held for the
                                          whole cycle, scaled by intervalSize over
                                          the cycle length.
                                        examples:
                                          - '29.0322580645'
                                      usage:
                                        type: number
                                        description: The usage held during the interval.
                                      intervalStart:
                                        type: string
                                        format: date
                                        description: First day of the interval.
                                      intervalEnd:
                                        type: string
                                        format: date
                                        description: Last day of the interval.
                                    required:
                                      - type
                                      - intervalSize
                                      - amount
                                      - usage
                                      - intervalStart
                                      - intervalEnd
                                  - type: object
                                    description: >-
                                      License proration delta row: for per_unit
                                      license charges billing under the
                                      proration model, the cycle-start row bills
                                      the starting licenses beyond the included
                                      quantity at their full-cycle price, and
                                      each change row bills the change in those
                                      licenses prorated over the days remaining
                                      in the cycle. A change that stays inside
                                      the included quantity has no row. Tiered
                                      charges use license_proration_tier
                                      instead. quantityDelta and the row's
                                      amount are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration
                                        description: >-
                                          Discriminator: license proration delta
                                          row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on the cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the licenses beyond the
                                          included quantity (the starting licenses
                                          beyond it on the cycle-start row).
                                          Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity after this
                                          change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on
                                          the cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|. On a cycle-start row
                                          that bills no license, the unit price of
                                          the charge.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                  - type: object
                                    description: >-
                                      Tiered license proration delta row: one
                                      price band of a license charge billing
                                      under the proration model with
                                      tiered_per_unit pricing. The cycle-start
                                      rows bill each band's opening occupancy at
                                      its full-cycle unit price, and each change
                                      row bills that band's occupancy delta
                                      prorated over the days remaining in the
                                      cycle. quantityDelta and the row's amount
                                      are signed — removals are negative.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - license_proration_tier
                                        description: >-
                                          Discriminator: tiered license proration
                                          delta row.
                                      changeDate:
                                        type: string
                                        format: date
                                        nullable: true
                                        description: >-
                                          The day the combined license quantity
                                          changed. Null on a cycle-start row.
                                      quantityDelta:
                                        type: number
                                        description: >-
                                          Signed change in the units this band
                                          holds (the band's opening occupancy on a
                                          cycle-start row). Negative for removals.
                                      quantity:
                                        type: number
                                        description: >-
                                          The combined license quantity across
                                          every band after this change.
                                      remainingDays:
                                        type: number
                                        description: >-
                                          Days from the change (inclusive) to the
                                          end of the cycle. Equals cycleDays on a
                                          cycle-start row.
                                      cycleDays:
                                        type: number
                                        description: Length of the billing cycle, in days.
                                      proratedUnitRate:
                                        type: string
                                        description: >-
                                          Absolute effective per-unit rate of the
                                          row over the remaining window, as a
                                          decimal currency-unit string: |amount| /
                                          |quantityDelta|.
                                        examples:
                                          - '16.1290322581'
                                      amount:
                                        type: string
                                        description: >-
                                          The signed prorated amount of the row,
                                          as a decimal currency-unit string.
                                        examples:
                                          - '48.3870967742'
                                      planChargeTierId:
                                        type: string
                                        description: >-
                                          The unique identifier of the plan charge
                                          tier this row moved through.
                                        examples:
                                          - 3c90c3cc-0d44-4b50-8888-8dd25736052a
                                      from:
                                        type: number
                                        description: >-
                                          Inclusive lower bound of the band, in
                                          licenses.
                                      to:
                                        type: number
                                        nullable: true
                                        description: >-
                                          Inclusive upper bound of the band, in
                                          licenses. Null on the last, open-ended
                                          band.
                                      unitPrice:
                                        type: string
                                        description: >-
                                          The band's full-cycle price per unit, as
                                          a decimal currency-unit string.
                                          proratedUnitRate is this scaled by
                                          remainingDays over cycleDays.
                                        examples:
                                          - '25.00'
                                    required:
                                      - type
                                      - changeDate
                                      - quantityDelta
                                      - quantity
                                      - remainingDays
                                      - cycleDays
                                      - proratedUnitRate
                                      - amount
                                      - planChargeTierId
                                      - from
                                      - to
                                      - unitPrice
                                  - type: object
                                    description: >-
                                      Unit-price row: billable units multiplied
                                      by a single price per unit. The row's
                                      usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - unit_price
                                        description: 'Discriminator: unit-price row.'
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.25'
                                    required:
                                      - type
                                      - price
                                  - type: object
                                    description: >-
                                      Included-quantity row: the free allotment
                                      of the charge. The row's usage holds the
                                      units consumed within the allotment and
                                      its amount is always zero.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - included_quantity
                                        description: 'Discriminator: included-quantity row.'
                                      includedQuantity:
                                        type: number
                                        description: >-
                                          Number of resource units included at no
                                          charge before billing starts.
                                    required:
                                      - type
                                      - includedQuantity
                                  - type: object
                                    description: >-
                                      Package-price row: billable units charged
                                      per started package of packageSize units.
                                      The row's usage holds the billable units.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - package_price
                                        description: 'Discriminator: package-price row.'
                                      packageSize:
                                        type: number
                                        description: Number of resource units per package.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per package, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '45.00'
                                      packagesBilled:
                                        type: number
                                        description: >-
                                          Number of packages billed: the billable
                                          units divided by packageSize, rounded
                                          up.
                                    required:
                                      - type
                                      - packageSize
                                      - price
                                      - packagesBilled
                                  - type: object
                                    description: >-
                                      Percentage row: a percentage applied over
                                      a monetary base amount. The row's usage
                                      holds the base amount, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - percentage
                                        description: 'Discriminator: percentage row.'
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount,
                                          as a decimal string from 0 to 100 (up to
                                          6 decimal places).
                                        examples:
                                          - '2.5'
                                    required:
                                      - type
                                      - percentage
                                  - type: object
                                    description: >-
                                      Per-unit overage row: units beyond the
                                      last tier boundary, billed at the
                                      configured excess unit price. The row's
                                      usage holds the units over the boundary.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - per_unit
                                        description: 'Discriminator: overage billed per unit.'
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          resource units.
                                      price:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per excess unit, as a decimal
                                          currency-unit string (up to 6 decimal
                                          places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - price
                                  - type: object
                                    description: >-
                                      Percentage overage row: the monetary base
                                      amount beyond the last tier boundary,
                                      billed at the configured excess
                                      percentage. The row's usage holds the base
                                      amount over the boundary, in cents.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - overage
                                        description: 'Discriminator: overage row.'
                                      pricingType:
                                        type: string
                                        enum:
                                          - percentage
                                        description: >-
                                          Discriminator: overage billed as a
                                          percentage.
                                      from:
                                        type: number
                                        description: >-
                                          The boundary the overage starts from:
                                          the upper bound of the last tier, in
                                          cents of the monetary base amount.
                                      percentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the excess base
                                          amount, as a decimal string from 0 to
                                          100 (up to 6 decimal places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - type
                                      - pricingType
                                      - from
                                      - percentage
                                  - type: object
                                    description: >-
                                      Original-amount row: surfaces the line
                                      item's pre-adjustment amount when the line
                                      has adjustments (e.g. a discount) but no
                                      price-component rows of its own. The row's
                                      amount equals the line item's
                                      subtotalAmount.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - original_amount
                                        description: 'Discriminator: original-amount row.'
                                    required:
                                      - type
                                  - type: object
                                    description: >-
                                      Fixed unit price row: the quantity of a
                                      fixed charge multiplied by its unit
                                      amount. The row's usage holds the
                                      quantity.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - fixed_unit_price
                                        description: 'Discriminator: fixed unit price row.'
                                      amount:
                                        type: integer
                                        minimum: 0
                                        description: Amount of one unit, in cents.
                                    required:
                                      - type
                                      - amount
                                  - type: object
                                    description: >-
                                      Custom row: one component of a custom plan
                                      charge, as its calculator billed it. The
                                      row's name, description, usage,
                                      usageFormat and amount hold the rest of
                                      the component.
                                    properties:
                                      type:
                                        type: string
                                        enum:
                                          - custom
                                        description: 'Discriminator: custom row.'
                                      key:
                                        type: string
                                        description: >-
                                          The key of the component in the sub-line
                                          schema of the charge's custom charge
                                          definition, such as documents_overage.
                                        examples:
                                          - documents_overage
                                    required:
                                      - type
                                      - key
                            required:
                              - id
                              - type
                              - name
                              - description
                              - usage
                              - usageFormat
                              - amount
                              - metadata
                            additionalProperties: false
                          description: >-
                            Breakdown of the line item amount into priced rows
                            (included quantities, unit/package/tier prices,
                            prorations, companions). Empty for line items
                            without a breakdown.
                        adjustments:
                          type: array
                          items:
                            type: object
                            description: >-
                              Schema representing an adjustment applied on top
                              of a line item subtotal, such as a discount or an
                              allocation offset.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the adjustment in our
                                  system.
                              name:
                                type: string
                                description: >-
                                  Display name of the adjustment as it appears
                                  on the invoice.
                                example: Desconto de boas-vindas
                              type:
                                type: string
                                enum:
                                  - monetary_discount
                                  - allocation_offset
                                description: >-
                                  The kind of adjustment: monetary_discount (a
                                  discount applied to the line item) or
                                  allocation_offset (the share of the amount
                                  moved to another payment account's invoice
                                  under a split allocation strategy).
                              amount:
                                type: number
                                description: >-
                                  Amount of the adjustment, in cents. Negative
                                  when the adjustment reduces the line item
                                  total.
                            required:
                              - id
                              - name
                              - type
                              - amount
                            additionalProperties: false
                          description: >-
                            Adjustments applied on top of the line item
                            subtotal, such as discounts and allocation offsets.
                      required:
                        - id
                        - idempotencyKey
                        - customerId
                        - productId
                        - resourceId
                        - licenseId
                        - lineItemGroupId
                        - name
                        - scope
                        - startDate
                        - endDate
                        - totalUsage
                        - usageFormat
                        - subtotalAmount
                        - adjustmentAmount
                        - totalAmount
                        - discountAmount
                        - metadata
                        - subLineItems
                        - adjustments
                      additionalProperties: false
                    description: >-
                      Line items that do not belong to any line item group (e.g.
                      contract-level minimum commitments, additional charges,
                      and ungrouped one-off items).
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of invoices, keyed by the
                      key of each custom field. The object is empty when the
                      invoice holds no value. A user edits them in the billing
                      app, and `PUT /v1/invoices/{id}/custom-fields` replaces
                      the whole set, in any status of the invoice.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  sentAt:
                    type: string
                    format: date-time
                    nullable: true
                    description: >-
                      When Aira last sent the invoice by e-mail to its invoice
                      recipients, in an invoice delivery. Null when Aira has not
                      sent it.
                  replaceReason:
                    type: string
                    enum:
                      - contract_allocation_changed
                      - manually_reopened
                      - null
                    nullable: true
                    description: >-
                      Why one invoice of the same invoice slot replaced another,
                      on both invoices of the replacement: manually_reopened for
                      a reopening, and contract_allocation_changed when a change
                      to the contract allocation canceled the invoice and a
                      later billing of its billing act replaced it. Null when
                      the invoice replaces no invoice and no invoice replaces
                      it.
                  replacesInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the canceled invoice that this
                      invoice replaces in its invoice slot. Null when the
                      invoice replaces no invoice.
                  replacedByInvoiceId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the invoice that replaces this
                      canceled invoice in its invoice slot. Null when no invoice
                      replaces it.
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - paymentAccountId
                  - contractId
                  - contractInvoiceSequence
                  - issuingAccount
                  - billingAccount
                  - invoiceAllocationStrategy
                  - lastCalculatedAt
                  - invoiceNumber
                  - invoiceDate
                  - memo
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - status
                  - isLocked
                  - failureReason
                  - source
                  - autoIssue
                  - amountDue
                  - dueDate
                  - lineItemGroups
                  - standaloneLineItems
                  - customFields
                  - sentAt
                  - replaceReason
                  - replacesInvoiceId
                  - replacedByInvoiceId
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invalid_custom_fields`: the `customFields` leave out a required
            custom field of invoices, name a key that is not one, or hold a
            value that its custom field does not take.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''customFields'' is required'
                    code: json_schema_validation_error
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
  /v1/invoices/{id}/send-email:
    post:
      summary: Send an invoice by e-mail
      tags:
        - Invoices
      description: >-
        Creates an invoice delivery, which Aira sends in the background: an
        e-mail of the invoice with the subject, the text and the files of the
        dunning step that the dunning schedule of the customer sends on the
        issue day. The e-mail goes to the invoice recipients of the payment
        account of the invoice, or to the recipientEmails of the body.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              nullable: true
              properties:
                recipientEmails:
                  type: array
                  items:
                    type: string
                    format: email
                  description: >-
                    The e-mails that receive the invoice in place of the invoice
                    recipients of its payment account.
              additionalProperties: false
        description: >-
          Who receives the e-mail. Leave the body out, or leave recipientEmails
          out or empty, to e-mail the invoice recipients of the payment account
          of the invoice.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the invoice in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_delivery_blocked
          when: >-
            Aira cannot deliver the invoice: the customer follows no dunning
            schedule, its dunning schedule has no step on the issue day, the
            invoice is not in review, issued, synced, pending, paid or overdue,
            a file that the step attaches does not exist, the e-mail has no
            recipient, or the payment method of the contract of the invoice is
            credit card and the invoice has no payment link yet
        - status: 404
          code: invoice_not_found
          when: no invoice has the `id`
      x-required-roles: *ref_8
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invoice_delivery_blocked`: Aira cannot deliver the invoice: the
            customer follows no dunning schedule, its dunning schedule has no
            step on the issue day, the invoice is not in review, issued, synced,
            pending, paid or overdue, a file that the step attaches does not
            exist, the e-mail has no recipient, or the payment method of the
            contract of the invoice is credit card and the invoice has no
            payment link yet.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_delivery_blocked
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                invoice_delivery_blocked:
                  value:
                    message: customer has no dunning schedule
                    code: invoice_delivery_blocked
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `invoice_not_found`: no invoice has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
  /v1/invoices/{invoiceId}/additional-charges/{lineItemId}:
    put:
      summary: Replace an additional charge of an invoice
      tags:
        - Invoices
      description: >-
        Replaces an additional charge of an invoice: Aira deletes its line item
        and adds a new one with the values of the body, so the reply carries a
        new lineItemId, and updates the amounts of the invoice.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                productId:
                  type: string
                  format: uuid
                  description: >-
                    The unique identifier of the product that the additional
                    charge belongs to.
                itemId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    The unique identifier of the catalog item that the
                    additional charge bills. Null when the additional charge
                    names no item.
                name:
                  type: string
                  description: The name of the additional charge, as the invoice shows it.
                  example: Taxa de entrega extra
                amount:
                  type: integer
                  minimum: 1
                  description: The amount that the additional charge bills, in cents.
                startDate:
                  type: string
                  format: date
                  description: >-
                    The first day of the period that the additional charge
                    bills.
                endDate:
                  type: string
                  format: date
                  description: The last day of the period that the additional charge bills.
              required:
                - productId
                - name
                - amount
                - startDate
                - endDate
              additionalProperties: false
        required: true
        description: >-
          The additional charge that replaces the one that the path names. Leave
          itemId out, or send null, when the additional charge names no catalog
          item.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice in our system.
        - schema:
            type: string
            format: uuid
          in: path
          name: lineItemId
          required: true
          description: >-
            The unique identifier of the line item of the additional charge in
            our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: the invoice is locked, because it was issued or canceled
        - status: 400
          code: invalid_invoice_line_item_scope
          when: >-
            the line item is neither an additional charge nor a line item of a
            one-off invoice
        - status: 404
          code: product_not_found
          when: no product has the `productId`
        - status: 404
          code: item_not_found
          when: no item has the `itemId`
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - status: 404
          code: line_item_not_found
          when: no line item of the invoice has the `lineItemId`
      x-required-roles: *ref_8
      responses:
        '200':
          description: >-
            The additional charge that replaces the one that the path names,
            with a new lineItemId. Monetary amounts are integers in cents.
          content:
            application/json:
              schema:
                type: object
                properties:
                  lineItemId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the line item of the additional
                      charge in our system.
                  productId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the product that the additional
                      charge belongs to.
                  itemId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the catalog item that the
                      additional charge bills. Null when the additional charge
                      names no item.
                  name:
                    type: string
                    description: >-
                      The name of the additional charge, as the invoice shows
                      it.
                    example: Taxa de entrega extra
                  amount:
                    type: integer
                    minimum: 1
                    description: The amount that the additional charge bills, in cents.
                  startDate:
                    type: string
                    format: date
                    description: >-
                      The first day of the period that the additional charge
                      bills.
                  endDate:
                    type: string
                    format: date
                    description: >-
                      The last day of the period that the additional charge
                      bills.
                required:
                  - lineItemId
                  - productId
                  - itemId
                  - name
                  - amount
                  - startDate
                  - endDate
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is locked, because it was
            issued or canceled.

            - `invalid_invoice_line_item_scope`: the line item is neither an
            additional charge nor a line item of a one-off invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                      - invalid_invoice_line_item_scope
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''productId'' is required'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
                invalid_invoice_line_item_scope:
                  value:
                    message: invoice line item has invalid scope for deletion
                    code: invalid_invoice_line_item_scope
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `product_not_found`: no product has the `productId`.

            - `item_not_found`: no item has the `itemId`.

            - `invoice_not_found`: no invoice has the `invoiceId`.

            - `line_item_not_found`: no line item of the invoice has the
            `lineItemId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - product_not_found
                      - item_not_found
                      - invoice_not_found
                      - line_item_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                product_not_found:
                  value:
                    message: default product not found
                    code: product_not_found
                item_not_found:
                  value:
                    message: item not found
                    code: item_not_found
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                line_item_not_found:
                  value:
                    message: Failed to create invoice line item
                    code: line_item_not_found
    delete:
      summary: Delete an additional charge of an invoice
      tags:
        - Invoices
      description: >-
        Deletes an additional charge of an invoice and updates the amounts of
        the invoice.


        Requires the role `invoices:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice in our system.
        - schema:
            type: string
            format: uuid
          in: path
          name: lineItemId
          required: true
          description: >-
            The unique identifier of the line item of the additional charge in
            our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: invoice_cannot_be_updated
          when: the invoice is locked, because it was issued or canceled
        - status: 400
          code: invalid_invoice_line_item_scope
          when: >-
            the line item is neither an additional charge nor a line item of a
            one-off invoice
        - status: 404
          code: invoice_not_found
          when: no invoice has the `invoiceId`
        - status: 404
          code: line_item_not_found
          when: no line item of the invoice has the `lineItemId`
      x-required-roles: *ref_8
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `invoice_cannot_be_updated`: the invoice is locked, because it was
            issued or canceled.

            - `invalid_invoice_line_item_scope`: the line item is neither an
            additional charge nor a line item of a one-off invoice.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invoice_cannot_be_updated
                      - invalid_invoice_line_item_scope
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
                invoice_cannot_be_updated:
                  value:
                    message: >-
                      invoice is not a one-off invoice and cannot be modified
                      through the public API
                    code: invoice_cannot_be_updated
                invalid_invoice_line_item_scope:
                  value:
                    message: invoice line item has invalid scope for deletion
                    code: invalid_invoice_line_item_scope
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_not_found`: no invoice has the `invoiceId`.

            - `line_item_not_found`: no line item of the invoice has the
            `lineItemId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_not_found
                      - line_item_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
                line_item_not_found:
                  value:
                    message: Failed to create invoice line item
                    code: line_item_not_found
  /v1/invoices/{invoiceId}/attachments/{attachmentId}:
    patch:
      summary: Update an attachment of an invoice
      tags:
        - Invoices
      description: >-
        Renames an invoice attachment, or sets whether each invoice delivery
        attaches it, and answers the attachment. An invoice delivery attaches
        the file only when the dunning step that it sends carries the invoice
        attachments.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                filename:
                  type: string
                  description: >-
                    The new name of the file, of up to 255 characters, which its
                    download carries. A new name keeps the fileExtension of the
                    attachment.
                  minLength: 1
                  maxLength: 255
                  example: pedido-de-compra-novembro.pdf
                includeInDelivery:
                  type: boolean
                  description: >-
                    Whether an invoice delivery attaches the file, when the
                    dunning step of the delivery carries the invoice
                    attachments. An uploaded file starts with false.
              minProperties: 1
              additionalProperties: false
        description: >-
          The fields of the invoice attachment to change. Send at least one of
          them.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice that the attachment belongs to.
        - schema:
            type: string
            format: uuid
          in: path
          name: attachmentId
          required: true
          description: The unique identifier of the invoice attachment in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_attachment_not_found
          when: no invoice attachment of the invoice has the `attachmentId`
      x-required-roles: *ref_8
      responses:
        '200':
          description: The invoice attachment, with the changes of the request.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the invoice attachment in our
                      system.
                  invoiceId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the invoice that the attachment
                      belongs to.
                  filename:
                    type: string
                    description: The name of the file, which its download carries.
                    example: pedido-de-compra-novembro.pdf
                  fileExtension:
                    type: string
                    enum:
                      - pdf
                      - csv
                      - xlsx
                      - xlsm
                      - xml
                      - zip
                    description: >-
                      The extension of the file, taken from the name of the
                      uploaded file. A file whose name has another extension, or
                      none, is recorded as pdf.
                  includeInDelivery:
                    type: boolean
                    description: >-
                      Whether an invoice delivery attaches the file, when the
                      dunning step of the delivery carries the invoice
                      attachments. An uploaded file starts with false.
                required:
                  - id
                  - invoiceId
                  - filename
                  - fileExtension
                  - includeInDelivery
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_attachment_not_found`: no invoice attachment of the
            invoice has the `attachmentId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_attachment_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_attachment_not_found:
                  value:
                    message: invoice attachment not found
                    code: invoice_attachment_not_found
    delete:
      summary: Delete an attachment of an invoice
      tags:
        - Invoices
      description: >-
        Deletes an invoice attachment and its file, so no later invoice delivery
        attaches it.


        Requires the role `invoices:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice that the attachment belongs to.
        - schema:
            type: string
            format: uuid
          in: path
          name: attachmentId
          required: true
          description: The unique identifier of the invoice attachment in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: invoice_attachment_not_found
          when: no invoice attachment of the invoice has the `attachmentId`
      x-required-roles: *ref_8
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceId'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `invoice_attachment_not_found`: no invoice attachment of the
            invoice has the `attachmentId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - invoice_attachment_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                invoice_attachment_not_found:
                  value:
                    message: invoice attachment not found
                    code: invoice_attachment_not_found
  /v1/invoices/sync/retry:
    post:
      summary: Retry failed invoice syncs
      tags:
        - Invoices
      description: >-
        Retries the failed invoice sync of each invoice of the body: Aira
        replaces it with a pending invoice sync for the same ERP and the same
        ERP record, and sends the invoice to the ERP again. Aira skips an
        invoice whose invoice sync did not fail.


        Requires the role `invoices:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                invoiceIds:
                  type: array
                  items:
                    type: string
                    format: uuid
                    description: The unique identifier of the invoice in our system.
                  minItems: 1
                  maxItems: 10000
                  uniqueItems: true
                  description: >-
                    The invoices whose failed invoice sync Aira retries, each id
                    once. Aira skips the id of an invoice whose invoice sync did
                    not fail, the id of an invoice with no invoice sync, and an
                    id that names no invoice.
              required:
                - invoiceIds
              additionalProperties: false
        required: true
        description: The invoices whose failed invoice sync Aira retries.
      x-public-api: true
      x-errors: []
      x-required-roles: *ref_8
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''invoiceIds'' is required'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role invoices:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
  /v1/events/:
    get:
      summary: List events
      tags:
        - Events
      description: >-
        Lists the latest version of each event that occurred in the `occurredAt`
        window, newest first by the time when Aira recorded it. The window is
        required and spans at most 31 days, so that no call reads every event.
        Archived events are listed only when `includeArchived` is true.


        Requires the role `events:read`.
      parameters:
        - schema:
            type: string
            format: date-time
          example: '2026-10-01T00:00:00.000Z'
          in: query
          name: occurredAt.gte
          required: true
          description: >-
            Start of the window, inclusive: the list returns only the events
            that occurred at or after this instant. The window spans at most 31
            days.
        - schema:
            type: string
            format: date-time
          example: '2026-10-31T23:59:59.999Z'
          in: query
          name: occurredAt.lte
          required: true
          description: >-
            End of the window, inclusive: the list returns only the events that
            occurred at or before this instant, which is at most 31 days after
            `occurredAt.gte`.
        - schema:
            type: string
            format: date-time
          in: query
          name: createdAt.gte
          required: false
          description: >-
            The list returns only the events that Aira recorded at or after this
            instant.
        - schema:
            type: string
            format: date-time
          in: query
          name: createdAt.lte
          required: false
          description: >-
            The list returns only the events that Aira recorded at or before
            this instant.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: customerIds[]
          required: false
          description: >-
            The list returns only the events of these customers, by their ids in
            Aira.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeSubsidiaryEvents
          required: false
          description: >-
            Whether the list also returns the events of the subsidiaries of the
            organizations that `customerIds[]` names.
        - schema:
            type: array
            items:
              type: string
          in: query
          name: eventNames[]
          required: false
          description: The list returns only the events with these event names.
        - schema:
            type: string
          example: 123e4567-e89b-12d3-a456-426614174000
          in: query
          name: search
          required: false
          description: >-
            The list returns only the event whose idempotency key equals this
            value after Aira lowercases it, so a key with a capital letter never
            matches.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeArchived
          required: false
          description: Whether the list also returns the archived events.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_period_range
          when: >-
            `occurredAt.gte` is after `occurredAt.lte`, or `occurredAt.lte` is
            more than 31 days after `occurredAt.gte`
        - *ref_1
        - *ref_2
      x-required-roles:
        - events:read
      responses:
        '200':
          description: The events that match the filters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        An event: one usage record that you send for a customer,
                        with an event name, properties and a time.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of this version of the event
                            in our system.
                        idempotencyKey:
                          type: string
                          pattern: ^[a-zA-Z0-9_-]+$
                          description: >-
                            The key that you give the event, the same in all its
                            versions.
                          example: 123e4567-e89b-12d3-a456-426614174000
                        eventName:
                          type: string
                          pattern: ^[a-zA-Z0-9_-]+$
                          description: >-
                            The event name, which the event filter of a resource
                            matches to count the event.
                          example: api_request
                        customerExternalId:
                          type: string
                          pattern: ^[a-zA-Z0-9_-]+$
                          description: >-
                            The external id of the customer of the event: the
                            key that you give the customer.
                          example: cust_1234567890abcdef
                        properties:
                          type: object
                          description: >-
                            A dictionary of additional properties associated
                            with the event.
                          propertyNames:
                            pattern: ^[a-zA-Z](?:[a-zA-Z0-9]*|(?:_[a-zA-Z0-9]+))*$
                          required:
                            - value
                          properties:
                            value:
                              type: number
                              minimum: 0
                              description: >-
                                Numeric value associated with the event, with up
                                to 6 decimal places.
                              example: 3600
                          additionalProperties:
                            if:
                              type: number
                            then:
                              type: number
                              minimum: 0
                            else:
                              anyOf:
                                - type: boolean
                                - type: string
                          example:
                            value: 3600
                            endpoint: /api/v1/users
                            method: GET
                            status_code: 200
                        occurredAt:
                          type: string
                          format: date-time
                          description: >-
                            ISO 8601 timestamp in UTC indicating when the event
                            occurred.
                          example: '2024-01-01T12:00:00Z'
                        createdAt:
                          type: string
                          format: date-time
                          description: >-
                            ISO 8601 timestamp in UTC indicating when Aira
                            recorded this version of the event.
                        archivedAt:
                          type:
                            - 'null'
                            - string
                          format: date-time
                          description: >-
                            ISO 8601 timestamp in UTC indicating when the event
                            was archived, or null if it is active.
                        version:
                          type: integer
                          description: >-
                            The version of the event: 1 is the first record of
                            its idempotency key, and each overwrite or archive
                            adds one.
                      required:
                        - id
                        - idempotencyKey
                        - eventName
                        - customerExternalId
                        - properties
                        - occurredAt
                        - createdAt
                        - archivedAt
                        - version
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.

            - `invalid_period_range`: `occurredAt.gte` is after
            `occurredAt.lte`, or `occurredAt.lte` is more than 31 days after
            `occurredAt.gte`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_period_range
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''occurredAt.gte'' must match format "date-time"'
                    code: json_schema_validation_error
                invalid_period_range:
                  value:
                    message: occurredAt.gte must not be after occurredAt.lte
                    code: invalid_period_range
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role events:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/events/ingest:
    post:
      summary: Ingest events
      tags:
        - Events
      description: >-
        Records a batch of events, all of them or none. An event whose
        `idempotencyKey` no event has records its first version. An event with
        the `idempotencyKey` of a recorded event records a new version of it
        when its `properties`, `value` included, differ from those of the
        recorded event or the recorded event is archived, and records nothing
        otherwise, so a resend of a batch records no event twice. The
        `eventName`, the `customerExternalId` and the `occurredAt` of an event
        stay the same in all its versions. `GET /v1/events` lists the latest
        version of each event.


        Requires the role `events:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                events:
                  description: >-
                    The events to record, from 1 to 10,000, each one usage
                    record that you send for a customer.
                  type: array
                  items:
                    type: object
                    description: The event to record for a customer.
                    properties:
                      idempotencyKey:
                        type: string
                        pattern: ^[a-zA-Z0-9_-]+$
                        description: >-
                          The key that you give the event, the same in all its
                          versions.
                        example: 123e4567-e89b-12d3-a456-426614174000
                      eventName:
                        type: string
                        pattern: ^[a-zA-Z0-9_-]+$
                        description: >-
                          The event name, which the event filter of a resource
                          matches to count the event.
                        example: api_request
                      customerExternalId:
                        type: string
                        pattern: ^[a-zA-Z0-9_-]+$
                        description: >-
                          The external id of the customer of the event: the key
                          that you give the customer.
                        example: cust_1234567890abcdef
                      properties:
                        type: object
                        description: >-
                          A dictionary of additional properties associated with
                          the event.
                        propertyNames:
                          pattern: ^[a-zA-Z](?:[a-zA-Z0-9]*|(?:_[a-zA-Z0-9]+))*$
                        required:
                          - value
                        properties:
                          value:
                            type: number
                            minimum: 0
                            description: >-
                              Numeric value associated with the event, with up
                              to 6 decimal places.
                            example: 3600
                        additionalProperties:
                          if:
                            type: number
                          then:
                            type: number
                            minimum: 0
                          else:
                            anyOf:
                              - type: boolean
                              - type: string
                        example:
                          value: 3600
                          endpoint: /api/v1/users
                          method: GET
                          status_code: 200
                      occurredAt:
                        type: string
                        format: date-time
                        description: >-
                          ISO 8601 timestamp in UTC indicating when the event
                          occurred.
                        example: '2024-01-01T12:00:00Z'
                    required:
                      - idempotencyKey
                      - eventName
                      - customerExternalId
                      - properties
                      - occurredAt
                    additionalProperties: false
                  minItems: 1
                  maxItems: 10000
              required:
                - events
              additionalProperties: false
        required: true
        description: The batch of events to record.
      x-public-api: true
      x-errors:
        - status: 400
          code: failed_to_create_events
          when: >-
            an event of the batch occurred in the future (`future_occurred_at`),
            has a number with more than 6 decimal places in its `properties`
            (`failed_on_previous_event_creation`), has the `idempotencyKey` of
            an earlier event of the batch (`duplicated_idempotency_key`), or has
            the `idempotencyKey` of a recorded event with another `eventName`,
            `customerExternalId` or `occurredAt` (`immutable_field_change`), and
            `details` lists each refused event by its `idempotencyKey`, with the
            `code` and the `message` of each of its errors
        - status: 409
          code: race_condition_duplicated_idempotency_key
          when: >-
            other requests keep writing versions of the same event at the same
            time
      x-required-roles: &ref_9
        - events:write
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `failed_to_create_events`: an event of the batch occurred in the
            future (`future_occurred_at`), has a number with more than 6 decimal
            places in its `properties` (`failed_on_previous_event_creation`),
            has the `idempotencyKey` of an earlier event of the batch
            (`duplicated_idempotency_key`), or has the `idempotencyKey` of a
            recorded event with another `eventName`, `customerExternalId` or
            `occurredAt` (`immutable_field_change`), and `details` lists each
            refused event by its `idempotencyKey`, with the `code` and the
            `message` of each of its errors.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - failed_to_create_events
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''events'' is required'
                    code: json_schema_validation_error
                failed_to_create_events:
                  value:
                    message: >-
                      not all events were processed successfully, so none have
                      been recorded
                    code: failed_to_create_events
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role events:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '409':
          description: >-
            Other data blocks the action.


            - `race_condition_duplicated_idempotency_key`: other requests keep
            writing versions of the same event at the same time.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - race_condition_duplicated_idempotency_key
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                race_condition_duplicated_idempotency_key:
                  value:
                    message: >-
                      concurrent writes kept colliding on the same
                      idempotency_key; retry the request
                    code: race_condition_duplicated_idempotency_key
  /v1/events/archive:
    put:
      summary: Archive events
      tags:
        - Events
      description: >-
        Archives the event of each key of `idempotencyKeys` by recording a new
        version of it that is archived, so `GET /v1/events` leaves those events
        out unless `includeArchived` is true. A key that no event has, or whose
        event is already archived, changes nothing, so a resend of the request
        archives nothing twice.


        Requires the role `events:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                idempotencyKeys:
                  type: array
                  items:
                    type: string
                    minLength: 1
                  minItems: 1
                  maxItems: 10000
                  uniqueItems: true
                  description: >-
                    The idempotency keys of the events to archive, from 1 to
                    10,000 keys, each once.
              required:
                - idempotencyKeys
              additionalProperties: false
        required: true
        description: The idempotency keys of the events to archive.
      x-public-api: true
      x-errors:
        - status: 409
          code: race_condition_duplicated_idempotency_key
          when: another request writes a version of the same event at the same time
      x-required-roles: *ref_9
      responses:
        '200':
          description: The idempotency keys of the events that the request archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  archivedIdempotencyKeys:
                    type: array
                    items:
                      type: string
                    description: >-
                      The idempotency keys of the events that the request
                      archived. A key that no event has, or whose event was
                      already archived, is left out.
                required:
                  - archivedIdempotencyKeys
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''idempotencyKeys'' is required'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role events:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '409':
          description: >-
            Other data blocks the action.


            - `race_condition_duplicated_idempotency_key`: another request
            writes a version of the same event at the same time.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - race_condition_duplicated_idempotency_key
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                race_condition_duplicated_idempotency_key:
                  value:
                    message: >-
                      concurrent writes kept colliding on the same
                      idempotency_key; retry the request
                    code: race_condition_duplicated_idempotency_key
  /v1/events/{idempotencyKey}:
    put:
      summary: Overwrite event
      tags:
        - Events
      description: >-
        Records a new version of the event with the `idempotencyKey`, whose
        `properties`, `value` included, replace those of the recorded event, and
        answers the latest version of the event. When no event has the key, the
        route records its first version. When the `properties` are the same as
        those of the recorded event and it is not archived, the route records
        nothing. The `eventName`, the `customerExternalId` and the `occurredAt`
        of an event stay the same in all its versions.


        Requires the role `events:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                eventName:
                  type: string
                  pattern: ^[a-zA-Z0-9_-]+$
                  description: >-
                    The event name, which the event filter of a resource matches
                    to count the event.
                  example: api_request
                customerExternalId:
                  type: string
                  pattern: ^[a-zA-Z0-9_-]+$
                  description: >-
                    The external id of the customer of the event: the key that
                    you give the customer.
                  example: cust_1234567890abcdef
                properties:
                  type: object
                  description: >-
                    A dictionary of additional properties associated with the
                    event.
                  propertyNames:
                    pattern: ^[a-zA-Z](?:[a-zA-Z0-9]*|(?:_[a-zA-Z0-9]+))*$
                  required:
                    - value
                  properties:
                    value:
                      type: number
                      minimum: 0
                      description: >-
                        Numeric value associated with the event, with up to 6
                        decimal places.
                      example: 3600
                  additionalProperties:
                    if:
                      type: number
                    then:
                      type: number
                      minimum: 0
                    else:
                      anyOf:
                        - type: boolean
                        - type: string
                  example:
                    value: 3600
                    endpoint: /api/v1/users
                    method: GET
                    status_code: 200
                occurredAt:
                  type: string
                  format: date-time
                  description: >-
                    ISO 8601 timestamp in UTC indicating when the event
                    occurred.
                  example: '2024-01-01T12:00:00Z'
              required:
                - eventName
                - customerExternalId
                - properties
                - occurredAt
              additionalProperties: false
        required: true
        description: >-
          The event with the `idempotencyKey`: its `properties`, `value`
          included, replace those of the recorded event, and its `eventName`,
          `customerExternalId` and `occurredAt` are those of the recorded event,
          which stay the same in all its versions.
      parameters:
        - schema:
            type: string
            pattern: ^[a-zA-Z0-9_-]+$
          example: 123e4567-e89b-12d3-a456-426614174000
          in: path
          name: idempotencyKey
          required: true
          description: The key that you give the event, the same in all its versions.
      x-public-api: true
      x-errors:
        - status: 400
          code: failed_to_create_events
          when: >-
            the event occurred in the future (`future_occurred_at`), has a
            number with more than 6 decimal places in its `properties`
            (`failed_on_previous_event_creation`), or has the `idempotencyKey`
            of a recorded event with another `eventName`, `customerExternalId`
            or `occurredAt` (`immutable_field_change`), and `details` lists the
            event by its `idempotencyKey`, with the `code` and the `message` of
            each of its errors
        - status: 409
          code: race_condition_duplicated_idempotency_key
          when: >-
            other requests keep writing versions of the same event at the same
            time
      x-required-roles: *ref_9
      responses:
        '200':
          description: >-
            An event: one usage record that you send for a customer, with an
            event name, properties and a time.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of this version of the event in our
                      system.
                  idempotencyKey:
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    description: >-
                      The key that you give the event, the same in all its
                      versions.
                    example: 123e4567-e89b-12d3-a456-426614174000
                  eventName:
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    description: >-
                      The event name, which the event filter of a resource
                      matches to count the event.
                    example: api_request
                  customerExternalId:
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    description: >-
                      The external id of the customer of the event: the key that
                      you give the customer.
                    example: cust_1234567890abcdef
                  properties:
                    type: object
                    description: >-
                      A dictionary of additional properties associated with the
                      event.
                    propertyNames:
                      pattern: ^[a-zA-Z](?:[a-zA-Z0-9]*|(?:_[a-zA-Z0-9]+))*$
                    required:
                      - value
                    properties:
                      value:
                        type: number
                        minimum: 0
                        description: >-
                          Numeric value associated with the event, with up to 6
                          decimal places.
                        example: 3600
                    additionalProperties:
                      if:
                        type: number
                      then:
                        type: number
                        minimum: 0
                      else:
                        anyOf:
                          - type: boolean
                          - type: string
                    example:
                      value: 3600
                      endpoint: /api/v1/users
                      method: GET
                      status_code: 200
                  occurredAt:
                    type: string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when the event
                      occurred.
                    example: '2024-01-01T12:00:00Z'
                  createdAt:
                    type: string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when Aira recorded
                      this version of the event.
                  archivedAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when the event was
                      archived, or null if it is active.
                  version:
                    type: integer
                    description: >-
                      The version of the event: 1 is the first record of its
                      idempotency key, and each overwrite or archive adds one.
                required:
                  - id
                  - idempotencyKey
                  - eventName
                  - customerExternalId
                  - properties
                  - occurredAt
                  - createdAt
                  - archivedAt
                  - version
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `failed_to_create_events`: the event occurred in the future
            (`future_occurred_at`), has a number with more than 6 decimal places
            in its `properties` (`failed_on_previous_event_creation`), or has
            the `idempotencyKey` of a recorded event with another `eventName`,
            `customerExternalId` or `occurredAt` (`immutable_field_change`), and
            `details` lists the event by its `idempotencyKey`, with the `code`
            and the `message` of each of its errors.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - failed_to_create_events
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''eventName'' is required'
                    code: json_schema_validation_error
                failed_to_create_events:
                  value:
                    message: >-
                      not all events were processed successfully, so none have
                      been recorded
                    code: failed_to_create_events
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role events:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '409':
          description: >-
            Other data blocks the action.


            - `race_condition_duplicated_idempotency_key`: other requests keep
            writing versions of the same event at the same time.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - race_condition_duplicated_idempotency_key
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                race_condition_duplicated_idempotency_key:
                  value:
                    message: >-
                      concurrent writes kept colliding on the same
                      idempotency_key; retry the request
                    code: race_condition_duplicated_idempotency_key
  /v1/licenses/report-balances:
    post:
      summary: Report license balances
      tags:
        - Licenses
      description: >-
        Reports a batch of license balances. Each license balance names its
        license by `code`, and its `code`, `customerExternalId` and `occurredAt`
        identify it. Aira records the first report of a license balance, changes
        nothing for a report with the same `total` and the same units in
        `payload`, in any order, and records any other report as a new version
        that replaces the previous one. Aira records all the license balances of
        the batch or none of them.


        Requires the role `licenses:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                balances:
                  description: >-
                    The license balances to report. Each names its license by
                    `code` and its customer by `customerExternalId`.
                  type: array
                  items:
                    type: object
                    description: >-
                      A license balance: one quantity of a license that you
                      report for one customer at one moment. It stays in effect
                      until a report for a later moment.
                    properties:
                      code:
                        type: string
                        pattern: ^[a-zA-Z0-9_-]+$
                        description: The code of the license of the license balance.
                        example: active_users
                      customerExternalId:
                        type: string
                        pattern: ^[a-zA-Z0-9_-]+$
                        description: >-
                          The external id of the customer of the license
                          balance: the key that you give the customer.
                        example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                      occurredAt:
                        type: string
                        format: date-time
                        description: The moment of the license balance, in ISO 8601.
                      total:
                        type: number
                        minimum: 0
                        multipleOf: 1
                        description: >-
                          The quantity of the license at the moment, in units of
                          the license, such as seats.
                      payload:
                        type: array
                        description: >-
                          The units behind the total, one per unit. Leave it out
                          to report only the total. When you send it, send as
                          many units as the total.
                        items:
                          type: object
                          description: >-
                            One unit behind the total, such as an active user.
                            Aira keeps each other key of the unit as it is, with
                            its type: a string, a number or a boolean.
                          properties:
                            id:
                              type: string
                              minLength: 1
                              description: >-
                                The identifier of the unit, such as the id of an
                                active user in your system.
                              example: user_0042
                            name:
                              type: string
                              description: A label of the unit that a person reads.
                              example: Caixa 2
                          required:
                            - id
                          additionalProperties:
                            type:
                              - string
                              - number
                              - boolean
                    required:
                      - code
                      - customerExternalId
                      - occurredAt
                      - total
                    additionalProperties: false
                  minItems: 1
                  maxItems: 10000
              required:
                - balances
              additionalProperties: false
        required: true
        description: The license balances to report.
      x-public-api: true
      x-errors:
        - status: 400
          code: failed_to_report_license_balances
          when: >-
            a license balance repeats the `code`, the `customerExternalId` and
            the `occurredAt` of another license balance of the batch, has a
            `payload` with more or fewer units than its `total`, has an
            `occurredAt` in the future, or names a `code` that no license has,
            and `details` lists each failed license balance with the code of
            each of its errors
        - status: 409
          code: race_condition_duplicated_license_balance
          when: >-
            other requests write a license balance with the same `code`,
            `customerExternalId` and `occurredAt` at the same time, in each of
            the three attempts of the route, and the request can be sent again
      x-required-roles: &ref_10
        - licenses:write
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `failed_to_report_license_balances`: a license balance repeats the
            `code`, the `customerExternalId` and the `occurredAt` of another
            license balance of the batch, has a `payload` with more or fewer
            units than its `total`, has an `occurredAt` in the future, or names
            a `code` that no license has, and `details` lists each failed
            license balance with the code of each of its errors.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - failed_to_report_license_balances
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''balances'' is required'
                    code: json_schema_validation_error
                failed_to_report_license_balances:
                  value:
                    message: >-
                      not all balances were processed successfully, so none have
                      been recorded
                    code: failed_to_report_license_balances
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role licenses:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '409':
          description: >-
            Other data blocks the action.


            - `race_condition_duplicated_license_balance`: other requests write
            a license balance with the same `code`, `customerExternalId` and
            `occurredAt` at the same time, in each of the three attempts of the
            route, and the request can be sent again.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - race_condition_duplicated_license_balance
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                race_condition_duplicated_license_balance:
                  value:
                    message: >-
                      concurrent writes kept colliding on the same balance key;
                      retry the request
                    code: race_condition_duplicated_license_balance
  /v1/licenses/:
    post:
      summary: Create license
      tags:
        - Licenses
      description: >-
        Creates a license of the item of `itemId`, so that `POST
        /v1/licenses/report-balances` takes license balances with its `code`.


        Requires the role `licenses:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  description: The name of the license.
                  type: string
                  minLength: 1
                  example: Active users
                code:
                  description: >-
                    The code of the license, which a balance report sends in
                    `code`. Case-sensitive.
                  type: string
                  pattern: ^[a-zA-Z0-9_-]+$
                  example: active_users
                itemId:
                  description: >-
                    The unique identifier of the catalog item that the license
                    bills.
                  type: string
                  format: uuid
              required:
                - name
                - code
                - itemId
              additionalProperties: false
        required: true
        description: The name, the code and the item of the license.
      x-public-api: true
      x-errors:
        - status: 400
          code: license_item_not_found
          when: no item has the `itemId`
        - status: 409
          code: license_code_already_exists
          when: another license, archived or not, has the `code`
      x-required-roles: *ref_10
      responses:
        '201':
          description: >-
            A license: a quantity that you report for a customer over time, such
            as seats. A report of license balances names the license by its
            code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the license in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the license.
                    type: string
                    minLength: 1
                    example: Active users
                  code:
                    description: >-
                      The code of the license, which a balance report sends in
                      `code`. Case-sensitive.
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    example: active_users
                  itemId:
                    description: >-
                      The unique identifier of the catalog item that the license
                      bills.
                    type: string
                    format: uuid
                  archivedAt:
                    description: >-
                      The timestamp when the license was archived, or null if
                      not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - code
                  - itemId
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `license_item_not_found`: no item has the `itemId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - license_item_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                license_item_not_found:
                  value:
                    message: item not found
                    code: license_item_not_found
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role licenses:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '409':
          description: >-
            Other data blocks the action.


            - `license_code_already_exists`: another license, archived or not,
            has the `code`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - license_code_already_exists
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                license_code_already_exists:
                  value:
                    message: license code already exists
                    code: license_code_already_exists
    get:
      summary: List licenses
      tags:
        - Licenses
      description: >-
        Lists the licenses, newest first by creation time, with the `code` that
        `POST /v1/licenses/report-balances` takes. Archived licenses are listed
        only when `includeArchived` is true.


        Requires the role `licenses:read`.
      parameters:
        - schema:
            type: string
          example: users
          in: query
          name: search
          required: false
          description: >-
            Free-text search over the license name, its code and the name of its
            item, ignoring case.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeArchived
          required: false
          description: Whether archived licenses should be returned.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: &ref_11
        - licenses:read
      responses:
        '200':
          description: The licenses that match the filters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A license: a quantity that you report for a customer
                        over time, such as seats. A report of license balances
                        names the license by its code.
                      properties:
                        id:
                          description: The unique identifier of the license in our system.
                          type: string
                          format: uuid
                        name:
                          description: The name of the license.
                          type: string
                          minLength: 1
                          example: Active users
                        code:
                          description: >-
                            The code of the license, which a balance report
                            sends in `code`. Case-sensitive.
                          type: string
                          pattern: ^[a-zA-Z0-9_-]+$
                          example: active_users
                        itemId:
                          description: >-
                            The unique identifier of the catalog item that the
                            license bills.
                          type: string
                          format: uuid
                        archivedAt:
                          description: >-
                            The timestamp when the license was archived, or null
                            if not archived.
                          type:
                            - 'null'
                            - string
                          format: date-time
                      required:
                        - id
                        - name
                        - code
                        - itemId
                        - archivedAt
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''search'' must be string'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role licenses:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/licenses/{id}:
    put:
      summary: Update license
      tags:
        - Licenses
      description: >-
        Replaces the name and the code of a license. The license balances that
        you already reported stay with the license, and `POST
        /v1/licenses/report-balances` takes the next ones under the new `code`.


        Requires the role `licenses:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  description: The name of the license.
                  type: string
                  minLength: 1
                  example: Active users
                code:
                  description: >-
                    The code of the license, which a balance report sends in
                    `code`. Case-sensitive.
                  type: string
                  pattern: ^[a-zA-Z0-9_-]+$
                  example: active_users
              required:
                - name
                - code
              additionalProperties: false
        required: true
        description: The name and the code that replace those of the license.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the license in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: license_not_found
          when: no license has the `id`
        - status: 409
          code: license_is_already_archived
          when: the license is archived
        - status: 409
          code: license_code_already_exists
          when: another license, archived or not, has the `code`
      x-required-roles: *ref_10
      responses:
        '200':
          description: >-
            A license: a quantity that you report for a customer over time, such
            as seats. A report of license balances names the license by its
            code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the license in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the license.
                    type: string
                    minLength: 1
                    example: Active users
                  code:
                    description: >-
                      The code of the license, which a balance report sends in
                      `code`. Case-sensitive.
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    example: active_users
                  itemId:
                    description: >-
                      The unique identifier of the catalog item that the license
                      bills.
                    type: string
                    format: uuid
                  archivedAt:
                    description: >-
                      The timestamp when the license was archived, or null if
                      not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - code
                  - itemId
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role licenses:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `license_not_found`: no license has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - license_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                license_not_found:
                  value:
                    message: license not found
                    code: license_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `license_is_already_archived`: the license is archived.

            - `license_code_already_exists`: another license, archived or not,
            has the `code`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - license_is_already_archived
                      - license_code_already_exists
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                license_is_already_archived:
                  value:
                    message: license is already archived
                    code: license_is_already_archived
                license_code_already_exists:
                  value:
                    message: license code already exists
                    code: license_code_already_exists
    delete:
      summary: Delete license
      tags:
        - Licenses
      description: >-
        Deletes a license, so that `GET /v1/licenses` leaves it out even when
        `includeArchived` is true.


        Requires the role `licenses:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the license in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: license_not_found
          when: no license has the `id`
        - status: 409
          code: license_has_blocking_references
          when: >-
            a plan charge or a line item of an invoice names the license, and
            `details.references` lists those references
      x-required-roles: *ref_10
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role licenses:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `license_not_found`: no license has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - license_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                license_not_found:
                  value:
                    message: license not found
                    code: license_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `license_has_blocking_references`: a plan charge or a line item of
            an invoice names the license, and `details.references` lists those
            references.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - license_has_blocking_references
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                license_has_blocking_references:
                  value:
                    message: license has blocking references and cannot be deleted
                    code: license_has_blocking_references
    get:
      summary: Fetch license
      tags:
        - Licenses
      description: |-
        Fetches a license by its id, archived or not.

        Requires the role `licenses:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the license in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: license_not_found
          when: no license has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_11
      responses:
        '200':
          description: >-
            A license: a quantity that you report for a customer over time, such
            as seats. A report of license balances names the license by its
            code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the license in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the license.
                    type: string
                    minLength: 1
                    example: Active users
                  code:
                    description: >-
                      The code of the license, which a balance report sends in
                      `code`. Case-sensitive.
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    example: active_users
                  itemId:
                    description: >-
                      The unique identifier of the catalog item that the license
                      bills.
                    type: string
                    format: uuid
                  archivedAt:
                    description: >-
                      The timestamp when the license was archived, or null if
                      not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - code
                  - itemId
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role licenses:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `license_not_found`: no license has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - license_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                license_not_found:
                  value:
                    message: license not found
                    code: license_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/licenses/{id}/archive:
    post:
      summary: Archive license
      tags:
        - Licenses
      description: >-
        Archives a license, so that `GET /v1/licenses` leaves it out unless
        `includeArchived` is true, and `PUT /v1/licenses/{id}` refuses to change
        it.


        Requires the role `licenses:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the license in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: license_is_already_archived
          when: the license is already archived
        - status: 404
          code: license_not_found
          when: no license has the `id`
      x-required-roles: *ref_10
      responses:
        '200':
          description: >-
            A license: a quantity that you report for a customer over time, such
            as seats. A report of license balances names the license by its
            code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the license in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the license.
                    type: string
                    minLength: 1
                    example: Active users
                  code:
                    description: >-
                      The code of the license, which a balance report sends in
                      `code`. Case-sensitive.
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    example: active_users
                  itemId:
                    description: >-
                      The unique identifier of the catalog item that the license
                      bills.
                    type: string
                    format: uuid
                  archivedAt:
                    description: >-
                      The timestamp when the license was archived, or null if
                      not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - code
                  - itemId
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `license_is_already_archived`: the license is already archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - license_is_already_archived
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                license_is_already_archived:
                  value:
                    message: license is already archived
                    code: license_is_already_archived
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role licenses:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `license_not_found`: no license has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - license_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                license_not_found:
                  value:
                    message: license not found
                    code: license_not_found
  /v1/licenses/{id}/unarchive:
    post:
      summary: Unarchive license
      tags:
        - Licenses
      description: >-
        Unarchives a license, so that `GET /v1/licenses` includes it again
        without `includeArchived`, and `PUT /v1/licenses/{id}` can change it
        again.


        Requires the role `licenses:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the license in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: license_is_not_archived
          when: the license is not archived
        - status: 404
          code: license_not_found
          when: no license has the `id`
      x-required-roles: *ref_10
      responses:
        '200':
          description: >-
            A license: a quantity that you report for a customer over time, such
            as seats. A report of license balances names the license by its
            code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the license in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the license.
                    type: string
                    minLength: 1
                    example: Active users
                  code:
                    description: >-
                      The code of the license, which a balance report sends in
                      `code`. Case-sensitive.
                    type: string
                    pattern: ^[a-zA-Z0-9_-]+$
                    example: active_users
                  itemId:
                    description: >-
                      The unique identifier of the catalog item that the license
                      bills.
                    type: string
                    format: uuid
                  archivedAt:
                    description: >-
                      The timestamp when the license was archived, or null if
                      not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - code
                  - itemId
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `license_is_not_archived`: the license is not archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - license_is_not_archived
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                license_is_not_archived:
                  value:
                    message: license is not archived
                    code: license_is_not_archived
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role licenses:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `license_not_found`: no license has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - license_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                license_not_found:
                  value:
                    message: license not found
                    code: license_not_found
  /v1/licenses/{id}/balances:
    get:
      summary: List license balances
      tags:
        - Licenses
      description: >-
        Lists the license balance in effect for each customer with a license
        balance of the license, which is the balance of the latest moment in its
        latest version, ordered by the external id of the customer.


        Requires the role `licenses:read`.
      parameters:
        - schema:
            type: array
            maxItems: 100
            items:
              type: string
              format: uuid
          in: query
          name: customerIds[]
          required: false
          description: >-
            The unique identifiers of the customers to keep. An id that no
            customer has matches no license balance.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the license in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: license_not_found
          when: no license has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_11
      responses:
        '200':
          description: >-
            The license balance in effect for each customer that matches the
            filters, ordered by the external id of the customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A license balance: one quantity of a license that you
                        report for one customer at one moment. It stays in
                        effect until a report for a later moment.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the version of the license
                            balance.
                        customerExternalId:
                          type: string
                          description: >-
                            The external id of the customer of the license
                            balance: the key that you give the customer.
                          example: 705faf65-9c8b-4053-8c0b-2021281ce83f
                        total:
                          type: number
                          description: >-
                            The quantity of the license balance, in units of the
                            license, such as seats.
                        occurredAt:
                          type: string
                          format: date-time
                          description: >-
                            The moment of the license balance, the latest moment
                            that you reported for the customer.
                      required:
                        - id
                        - customerExternalId
                        - total
                        - occurredAt
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or a query
            parameter breaks the schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role licenses:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `license_not_found`: no license has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - license_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                license_not_found:
                  value:
                    message: license not found
                    code: license_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/licenses/{id}/balances/{customerExternalId}/history:
    get:
      summary: List license balance history
      tags:
        - Licenses
      description: >-
        Lists each version of each license balance that you reported for the
        license and the customer of `customerExternalId`, newest moment first
        and newest version first within a moment.


        Requires the role `licenses:read`.
      parameters:
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the license.
        - schema:
            type: string
            pattern: ^[a-zA-Z0-9_-]+$
          example: 705faf65-9c8b-4053-8c0b-2021281ce83f
          in: path
          name: customerExternalId
          required: true
          description: 'The external id of the customer: the key that you give the customer.'
      x-public-api: true
      x-errors:
        - status: 404
          code: license_not_found
          when: no license has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_11
      responses:
        '200':
          description: >-
            The versions of the license balances of the customer, newest moment
            first and newest version first within a moment.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        One version of a license balance: one quantity of a
                        license that you reported for one customer at one
                        moment.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the version of the license
                            balance.
                        occurredAt:
                          type: string
                          format: date-time
                          description: >-
                            The moment of the license balance, from which its
                            quantity stays in effect until a license balance of
                            a later moment.
                        createdAt:
                          type: string
                          format: date-time
                          description: When Aira recorded the version.
                        total:
                          type: number
                          description: >-
                            The quantity of the license balance, in units of the
                            license, such as seats.
                        version:
                          type: number
                          description: >-
                            The number of the version among the versions of the
                            same moment, from 1. A report of the same moment
                            with another total or payload records the next
                            version.
                        payload:
                          type: array
                          description: >-
                            The units behind the total, one per unit. Empty when
                            you reported the license balance with only its
                            total.
                          items:
                            type: object
                            description: >-
                              One unit behind the total, such as an active user.
                              Aira keeps each other key of the unit as it is,
                              with its type: a string, a number or a boolean.
                            properties:
                              id:
                                type: string
                                minLength: 1
                                description: >-
                                  The identifier of the unit, such as the id of
                                  an active user in your system.
                                example: user_0042
                              name:
                                type: string
                                description: A label of the unit that a person reads.
                                example: Caixa 2
                            required:
                              - id
                            additionalProperties:
                              type:
                                - string
                                - number
                                - boolean
                      required:
                        - id
                        - occurredAt
                        - createdAt
                        - total
                        - version
                        - payload
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or a query
            parameter breaks the schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role licenses:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `license_not_found`: no license has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - license_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                license_not_found:
                  value:
                    message: license not found
                    code: license_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/contracts/:
    post:
      summary: Create contract
      tags:
        - Contracts
      description: >-
        Creates a contract in draft status for a customer, with the next
        contract number of that customer, and a plan instance of each plan of
        `planIds` from the current version of the plan. Aira creates the
        contract and its plan instances together or not at all, and bills the
        contract only after its activation, which needs at least one active plan
        instance.


        Requires the role `contracts:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                customerId:
                  type: string
                  format: uuid
                  description: ID of the customer associated with this contract.
                legalEntityId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    ID of the legal entity associated with this contract.
                    Optional on create; defaults to the default legal entity
                    when absent.
                startDate:
                  type: string
                  format: date
                  description: The first day of the term of the contract.
                endDate:
                  type: string
                  format: date
                  nullable: true
                  description: >-
                    The last day of the term of the contract, or null when the
                    contract has no end date.
                retroactiveDate:
                  type: string
                  format: date
                  nullable: true
                  description: >-
                    The date since which the contract was served before it
                    reached Aira, or null. Aira records invoices for the billing
                    cycles since that date but does not collect them, because
                    they were charged elsewhere.
                rateAdjustmentIndex:
                  type:
                    - 'null'
                    - string
                  enum:
                    - none
                    - igpm
                    - ipca
                    - other
                    - null
                  description: >-
                    Reference index (e.g. IPCA) used to filter contracts when
                    applying a mass adjustment on contracts.
                customFields:
                  type: object
                  description: >-
                    Custom fields that can be associated with the entity. The
                    fields must be previously created in the system before they
                    can be used.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
                taxRegimeId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    ID of the tax regime applied to invoices generated from this
                    contract. Null when no regime is attached.
                invoiceAllocationStrategy:
                  type: string
                  enum:
                    - single
                    - percent_split
                    - subsidiary_usage_split
                  description: >-
                    How each billing act of the contract becomes invoices:
                    `single` makes one invoice, `percent_split` makes one per
                    payment account by fixed percentages, and
                    `subsidiary_usage_split` makes one per payment account by
                    the share of the usage of its customer.
                includeNewSubsidiariesOnUsageScope:
                  type: boolean
                  description: >-
                    Whether future subsidiaries are automatically included in
                    usage scope.
                autoIssue:
                  type: boolean
                  description: >-
                    When true, invoices produced at billing-cycle close are
                    issued automatically instead of waiting in review. Defaults
                    to false when omitted; omitting it on update leaves the
                    current value unchanged.
                usageScopes:
                  type: array
                  items:
                    type: object
                    description: >-
                      A customer of the usage scope of the contract, whose usage
                      and license balances the contract bills.
                    properties:
                      customerId:
                        type: string
                        format: uuid
                        description: Customer ID that contributes usage to this contract.
                    required:
                      - customerId
                    additionalProperties: false
                  minItems: 1
                  description: >-
                    The usage scope of the contract: the customers whose usage
                    and license balances it bills, which are the individual
                    alone, or a set of the organization and its subsidiaries.
                  uniqueItems: true
                allocations:
                  type: array
                  description: >-
                    The contract allocation: the payment accounts that receive
                    the invoices of the contract.
                  items:
                    type: object
                    description: >-
                      A payment account that receives invoices of the contract,
                      with its share of each billing act.
                    properties:
                      paymentAccountId:
                        type: string
                        format: uuid
                        description: ID of the payment account.
                      allocationPercentage:
                        type: string
                        description: >-
                          The percentage of each billing act that the payment
                          account receives, from 0 to 100 with up to 6 decimal
                          places, or null, which only a contract that splits its
                          invoices by subsidiary usage allows.
                        nullable: true
                        example: '50.000000'
                    required:
                      - paymentAccountId
                      - allocationPercentage
                    additionalProperties: false
                  minItems: 1
                billingSettings:
                  type: object
                  description: >-
                    The contract minimum: the least that the contract bills in a
                    billing cycle, across all its plans. When its plans total
                    less, the closing invoice adds the difference.
                  properties:
                    invoiceMinimumAmount:
                      type: number
                      description: >-
                        The least amount, in cents, that the contract bills in a
                        billing cycle across all its plans.
                      minimum: 0
                    productId:
                      type: string
                      format: uuid
                      description: >-
                        Product ID to use for contract minimum amount line
                        items.
                  required:
                    - invoiceMinimumAmount
                    - productId
                  additionalProperties: false
                  nullable: true
                billingSchedule:
                  type: object
                  description: >-
                    How the billing cycles of the contract repeat: every month
                    or every week, from the billing day of the contract.
                  properties:
                    periodUnit:
                      type: string
                      enum:
                        - week
                        - month
                      description: >-
                        The calendar the contract closes on: month bills on a
                        day of the month, week on a weekday. Every plan on the
                        contract bills on this family; a plan from the other
                        family belongs on a second contract. A draft can change
                        it only while it has no plans.
                    anchorSource:
                      type: string
                      enum:
                        - based_on_contract_start_date
                        - explicit
                        - first_day_of_month
                      description: >-
                        The label the contract screen shows for the billing day.
                        The engine bills on anchorDay alone, so
                        first_day_of_month only describes a schedule that
                        already opens on day 1.
                    anchorDay:
                      type: integer
                      minimum: 1
                      maximum: 31
                      description: >-
                        The billing day, read per family: day of month (1-31) on
                        the month family, day of week (1=Sunday...7=Saturday) on
                        the week family.
                  required:
                    - periodUnit
                    - anchorSource
                    - anchorDay
                  allOf:
                    - if:
                        type: object
                        properties:
                          anchorSource:
                            enum:
                              - first_day_of_month
                        required:
                          - anchorSource
                      then:
                        type: object
                        properties:
                          anchorDay:
                            enum:
                              - 1
                      errorMessage: >-
                        must pair first_day_of_month with anchorDay 1; use
                        another anchorSource to bill on a different day
                    - if:
                        type: object
                        properties:
                          periodUnit:
                            enum:
                              - week
                        required:
                          - periodUnit
                      then:
                        type: object
                        properties:
                          anchorDay:
                            type: integer
                            maximum: 7
                      errorMessage: >-
                        on the week calendar the billing day is a weekday, 1
                        (Sunday) to 7 (Saturday)
                    - if:
                        type: object
                        properties:
                          anchorSource:
                            enum:
                              - first_day_of_month
                        required:
                          - anchorSource
                      then:
                        type: object
                        properties:
                          periodUnit:
                            enum:
                              - month
                      errorMessage: >-
                        first_day_of_month is a month-calendar label; the week
                        calendar bills on a weekday
                  additionalProperties: false
                paymentGatewaySettings:
                  type: object
                  description: >-
                    The payment conditions of the contract: how its invoices are
                    paid, with the payment method, and the due date as a number
                    of days after the issue or a fixed day of the month.
                  properties:
                    paymentMethod:
                      type: string
                      enum:
                        - bolepix
                        - bank_slip
                        - pix
                        - credit_card
                        - bank_transfer
                      description: >-
                        Payment method to use for this contract. Must be
                        supported by the active payment provider.
                    dueDateMode:
                      type: string
                      enum:
                        - days_after_issue
                        - fixed_day
                      description: >-
                        How invoice due dates are derived: a day offset from the
                        issue date, or a fixed day of the month.
                      default: days_after_issue
                    dueOffsetDays:
                      type: number
                      minimum: 0
                      nullable: true
                      description: >-
                        Number of days after the issue date until payment is due
                        (0 = due on issue day). Used when dueDateMode is
                        days_after_issue.
                    dueDay:
                      type: number
                      minimum: 1
                      maximum: 31
                      nullable: true
                      description: >-
                        Day of the month invoices are due on, clamped to the
                        last day of shorter months. Used when dueDateMode is
                        fixed_day.
                    dueMonthOffset:
                      type: integer
                      enum:
                        - 0
                        - 1
                      description: >-
                        How many months after the issue month the fixed due day
                        falls on: 0 for the same month, 1 for the next. Used
                        when dueDateMode is fixed_day.
                      default: 0
                    rollDueDateToBusinessDay:
                      type: boolean
                      description: >-
                        Whether a due date landing on a weekend moves to the
                        next business day. Off keeps it on the day it falls.
                      default: true
                  required:
                    - paymentMethod
                    - dueDateMode
                  allOf:
                    - if:
                        properties:
                          dueDateMode:
                            enum:
                              - fixed_day
                        required:
                          - dueDateMode
                      then:
                        properties:
                          dueDay:
                            not:
                              enum:
                                - null
                        required:
                          - dueDay
                      else:
                        properties:
                          dueOffsetDays:
                            not:
                              enum:
                                - null
                        required:
                          - dueOffsetDays
                  additionalProperties: false
                  nullable: true
                planIds:
                  type: array
                  items:
                    type: string
                    format: uuid
                  uniqueItems: true
                  description: >-
                    Plans to instantiate on the new contract, each from its
                    current active version and following the contract dates. The
                    contract and its plan instances are created together: when
                    any plan cannot be instantiated, nothing is created.
              required:
                - customerId
                - startDate
                - endDate
                - retroactiveDate
                - rateAdjustmentIndex
                - customFields
                - invoiceAllocationStrategy
                - includeNewSubsidiariesOnUsageScope
                - usageScopes
                - allocations
                - billingSchedule
              additionalProperties: false
        required: true
        description: The contract to create, in draft status, with the plans to put on it.
      x-public-api: true
      x-errors:
        - status: 400
          code: tax_regime_required
          when: the tax regime module is on and `taxRegimeId` is missing
        - status: 400
          code: customer_is_already_archived
          when: >-
            the customer is archived, or the usage scope of an organization
            names one of its archived subsidiaries
        - status: 400
          code: contract_legal_entity_mismatch
          when: no legal entity has the `legalEntityId`
        - status: 400
          code: invalid_customer_hierarchy
          when: >-
            the customer is a subsidiary, the usage scope names a customer
            twice, the contract of an individual has another customer in its
            usage scope or sets `includeNewSubsidiariesOnUsageScope`, or the
            usage scope of an organization names a customer other than the
            organization and its subsidiaries
        - status: 400
          code: start_date_after_end_date
          when: '`endDate` is on or before `startDate`'
        - status: 400
          code: invalid_retroactive_date
          when: >-
            `retroactiveDate` comes before `startDate`, after `endDate` or after
            today, falls in a month more than three years before the current
            month, or is set on a contract whose `endDate` has passed
        - status: 400
          code: invalid_custom_fields
          when: >-
            the custom fields leave out a required custom field of contracts,
            name a key that no custom field of contracts has, or give a custom
            field a value that it does not take
        - status: 400
          code: invalid_billing_type
          when: >-
            the allocations name a payment account twice, or break
            `invoiceAllocationStrategy`: `single` takes one allocation of 100
            percent, and `percent_split` takes a percentage on every allocation,
            with a total of 100
        - status: 400
          code: contract_and_payment_account_must_belong_to_the_same_customer
          when: >-
            an allocation names a payment account of a customer other than the
            customer of the contract and its subsidiaries that are not archived
        - status: 400
          code: contract_without_payment_gateway_settings
          when: >-
            every contract must have payment conditions, and
            `paymentGatewaySettings` is missing
        - status: 400
          code: invalid_proration_usage_scope
          when: >-
            the usage scope holds more than one customer while a plan of
            `planIds` charges for a resource whose billing model is proration
        - status: 400
          code: invalid_license_proration_allocation
          when: >-
            `invoiceAllocationStrategy` is `subsidiary_usage_split` while a plan
            of `planIds` has a license-based charge billed by proration
        - status: 400
          code: mixed_billing_frequency_family
          when: >-
            the plans of `planIds` have plan charges with billing frequencies in
            both months and weeks, or in a unit other than
            `billingSchedule.periodUnit`
        - status: 404
          code: tax_regime_not_found
          when: no tax regime has the `taxRegimeId`, or that tax regime is archived
        - status: 404
          code: customer_not_found
          when: no customer has the `customerId`
        - status: 404
          code: payment_account_not_found
          when: >-
            an allocation names a payment account that does not exist or that is
            archived
        - status: 404
          code: plan_not_found
          when: an id of `planIds` names no plan
        - status: 422
          code: incompatible_payment_method_for_provider
          when: >-
            the payment provider does not take
            `paymentGatewaySettings.paymentMethod`
      x-required-roles: &ref_12
        - contracts:write
      responses:
        '201':
          description: >-
            An agreement with an individual or an organization that bills plans,
            each through at most one active plan instance. It holds the term,
            the billing schedule, the usage scope, the payment accounts and the
            payment conditions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: Unique identifier for the contract.
                  contractNumber:
                    type: string
                    description: >-
                      The number of the contract, which Aira gives it on
                      creation from the prefix of its customer and the sequence
                      of the contracts of that customer.
                    example: MERCA-CTR-01
                  customerId:
                    type: string
                    format: uuid
                    description: ID of the customer associated with this contract.
                  legalEntityId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      ID of the legal entity associated with this contract.
                      Optional on create; defaults to the default legal entity
                      when absent.
                  legalEntity:
                    type: object
                    description: >-
                      The legal entity, a registered company, that issues the
                      invoices of the contract.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the legal entity in our
                          system.
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                    required:
                      - id
                      - businessName
                      - tradeName
                    additionalProperties: false
                  startDate:
                    type: string
                    format: date
                    description: The first day of the term of the contract.
                  endDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      The last day of the term of the contract, or null when the
                      contract has no end date.
                  retroactiveDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      The date since which the contract was served before it
                      reached Aira, or null. Aira records invoices for the
                      billing cycles since that date but does not collect them,
                      because they were charged elsewhere.
                  invoicingStartDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Read-only. Start date of the first billing cycle Aira
                      invoices for this contract, recorded when it is activated:
                      the cycle containing the retroactive date when one is set,
                      otherwise the cycle running on the activation day, or the
                      contract start when that is still ahead. Null while the
                      contract is a draft.
                  status:
                    type: string
                    enum:
                      - active
                      - canceled
                      - completed
                      - draft
                    description: Current status of the contract.
                  rateAdjustmentIndex:
                    type:
                      - 'null'
                      - string
                    enum:
                      - none
                      - igpm
                      - ipca
                      - other
                      - null
                    description: >-
                      Reference index (e.g. IPCA) used to filter contracts when
                      applying a mass adjustment on contracts.
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  taxRegimeId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      ID of the tax regime applied to invoices generated from
                      this contract. Null when no regime is attached.
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How each billing act of the contract becomes invoices:
                      `single` makes one invoice, `percent_split` makes one per
                      payment account by fixed percentages, and
                      `subsidiary_usage_split` makes one per payment account by
                      the share of the usage of its customer.
                  includeNewSubsidiariesOnUsageScope:
                    type: boolean
                    description: >-
                      Whether future subsidiaries are automatically included in
                      usage scope.
                  autoIssue:
                    type: boolean
                    description: >-
                      When true, invoices produced at billing-cycle close are
                      issued automatically instead of waiting in review.
                      Defaults to false when omitted; omitting it on update
                      leaves the current value unchanged.
                  usageScopes:
                    type: array
                    items:
                      type: object
                      description: >-
                        A customer of the usage scope of the contract, whose
                        usage and license balances the contract bills.
                      properties:
                        customerId:
                          type: string
                          format: uuid
                          description: Customer ID that contributes usage to this contract.
                      required:
                        - customerId
                      additionalProperties: false
                    minItems: 1
                    description: >-
                      The usage scope of the contract: the customers whose usage
                      and license balances it bills, which are the individual
                      alone, or a set of the organization and its subsidiaries.
                    uniqueItems: true
                  allocations:
                    type: array
                    description: >-
                      The contract allocation: the payment accounts that receive
                      the invoices of the contract.
                    items:
                      type: object
                      description: >-
                        A payment account that receives invoices of the
                        contract, with its share of each billing act.
                      properties:
                        paymentAccountId:
                          type: string
                          format: uuid
                          description: ID of the payment account.
                        allocationPercentage:
                          type: string
                          description: >-
                            The percentage of each billing act that the payment
                            account receives, from 0 to 100 with up to 6 decimal
                            places, or null, which only a contract that splits
                            its invoices by subsidiary usage allows.
                          nullable: true
                          example: '50.000000'
                      required:
                        - paymentAccountId
                        - allocationPercentage
                      additionalProperties: false
                    minItems: 1
                  billingSettings:
                    type: object
                    description: >-
                      The contract minimum: the least that the contract bills in
                      a billing cycle, across all its plans. When its plans
                      total less, the closing invoice adds the difference.
                    properties:
                      invoiceMinimumAmount:
                        type: number
                        description: >-
                          The least amount, in cents, that the contract bills in
                          a billing cycle across all its plans.
                        minimum: 0
                      productId:
                        type: string
                        format: uuid
                        description: >-
                          Product ID to use for contract minimum amount line
                          items.
                    required:
                      - invoiceMinimumAmount
                      - productId
                    additionalProperties: false
                    nullable: true
                  billingSchedule:
                    type: object
                    description: >-
                      How the billing cycles of the contract repeat: every month
                      or every week, from the billing day of the contract.
                    properties:
                      periodUnit:
                        type: string
                        enum:
                          - week
                          - month
                        description: >-
                          The calendar the contract closes on: month bills on a
                          day of the month, week on a weekday. Every plan on the
                          contract bills on this family; a plan from the other
                          family belongs on a second contract. A draft can
                          change it only while it has no plans.
                      anchorSource:
                        type: string
                        enum:
                          - based_on_contract_start_date
                          - explicit
                          - first_day_of_month
                        description: >-
                          The label the contract screen shows for the billing
                          day. The engine bills on anchorDay alone, so
                          first_day_of_month only describes a schedule that
                          already opens on day 1.
                      anchorDay:
                        type: integer
                        minimum: 1
                        maximum: 31
                        description: >-
                          The billing day, read per family: day of month (1-31)
                          on the month family, day of week
                          (1=Sunday...7=Saturday) on the week family.
                    required:
                      - periodUnit
                      - anchorSource
                      - anchorDay
                    allOf:
                      - if:
                          type: object
                          properties:
                            anchorSource:
                              enum:
                                - first_day_of_month
                          required:
                            - anchorSource
                        then:
                          type: object
                          properties:
                            anchorDay:
                              enum:
                                - 1
                        errorMessage: >-
                          must pair first_day_of_month with anchorDay 1; use
                          another anchorSource to bill on a different day
                      - if:
                          type: object
                          properties:
                            periodUnit:
                              enum:
                                - week
                          required:
                            - periodUnit
                        then:
                          type: object
                          properties:
                            anchorDay:
                              type: integer
                              maximum: 7
                        errorMessage: >-
                          on the week calendar the billing day is a weekday, 1
                          (Sunday) to 7 (Saturday)
                      - if:
                          type: object
                          properties:
                            anchorSource:
                              enum:
                                - first_day_of_month
                          required:
                            - anchorSource
                        then:
                          type: object
                          properties:
                            periodUnit:
                              enum:
                                - month
                        errorMessage: >-
                          first_day_of_month is a month-calendar label; the week
                          calendar bills on a weekday
                    additionalProperties: false
                  paymentGatewaySettings:
                    type: object
                    description: >-
                      The payment conditions of the contract: how its invoices
                      are paid, with the payment method, and the due date as a
                      number of days after the issue or a fixed day of the
                      month.
                    properties:
                      paymentMethod:
                        type: string
                        enum:
                          - bolepix
                          - bank_slip
                          - pix
                          - credit_card
                          - bank_transfer
                        description: >-
                          Payment method to use for this contract. Must be
                          supported by the active payment provider.
                      dueDateMode:
                        type: string
                        enum:
                          - days_after_issue
                          - fixed_day
                        description: >-
                          How invoice due dates are derived: a day offset from
                          the issue date, or a fixed day of the month.
                        default: days_after_issue
                      dueOffsetDays:
                        type: number
                        minimum: 0
                        nullable: true
                        description: >-
                          Number of days after the issue date until payment is
                          due (0 = due on issue day). Used when dueDateMode is
                          days_after_issue.
                      dueDay:
                        type: number
                        minimum: 1
                        maximum: 31
                        nullable: true
                        description: >-
                          Day of the month invoices are due on, clamped to the
                          last day of shorter months. Used when dueDateMode is
                          fixed_day.
                      dueMonthOffset:
                        type: integer
                        enum:
                          - 0
                          - 1
                        description: >-
                          How many months after the issue month the fixed due
                          day falls on: 0 for the same month, 1 for the next.
                          Used when dueDateMode is fixed_day.
                        default: 0
                      rollDueDateToBusinessDay:
                        type: boolean
                        description: >-
                          Whether a due date landing on a weekend moves to the
                          next business day. Off keeps it on the day it falls.
                        default: true
                    required:
                      - paymentMethod
                      - dueDateMode
                    allOf:
                      - if:
                          properties:
                            dueDateMode:
                              enum:
                                - fixed_day
                          required:
                            - dueDateMode
                        then:
                          properties:
                            dueDay:
                              not:
                                enum:
                                  - null
                          required:
                            - dueDay
                        else:
                          properties:
                            dueOffsetDays:
                              not:
                                enum:
                                  - null
                          required:
                            - dueOffsetDays
                    additionalProperties: false
                    nullable: true
                  planInstances:
                    description: >-
                      The plan instances attached to the contract. While the
                      contract is draft or active only its active plan instances
                      are listed; once the contract is completed or canceled,
                      all of them are.
                    type: array
                    items:
                      type: object
                      description: >-
                        A plan put on the contract. It has its own versions, so
                        the prices of one contract can change while the plan
                        stays the same.
                      properties:
                        id:
                          description: >-
                            The unique identifier of the plan instance in our
                            system. Use it to fetch or update the plan instance.
                          type: string
                          format: uuid
                        planId:
                          description: >-
                            The unique identifier of the plan this instance was
                            created from.
                          type: string
                          format: uuid
                        name:
                          description: The name of the plan this instance was created from.
                          type: string
                          example: Plano Essencial
                        status:
                          description: The current status of the plan instance.
                          type: string
                          enum:
                            - active
                            - canceled
                            - completed
                      required:
                        - id
                        - planId
                        - name
                        - status
                      additionalProperties: false
                required:
                  - id
                  - contractNumber
                  - customerId
                  - startDate
                  - endDate
                  - retroactiveDate
                  - invoicingStartDate
                  - status
                  - rateAdjustmentIndex
                  - customFields
                  - invoiceAllocationStrategy
                  - includeNewSubsidiariesOnUsageScope
                  - usageScopes
                  - allocations
                  - billingSchedule
                  - planInstances
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `tax_regime_required`: the tax regime module is on and
            `taxRegimeId` is missing.

            - `customer_is_already_archived`: the customer is archived, or the
            usage scope of an organization names one of its archived
            subsidiaries.

            - `contract_legal_entity_mismatch`: no legal entity has the
            `legalEntityId`.

            - `invalid_customer_hierarchy`: the customer is a subsidiary, the
            usage scope names a customer twice, the contract of an individual
            has another customer in its usage scope or sets
            `includeNewSubsidiariesOnUsageScope`, or the usage scope of an
            organization names a customer other than the organization and its
            subsidiaries.

            - `start_date_after_end_date`: `endDate` is on or before
            `startDate`.

            - `invalid_retroactive_date`: `retroactiveDate` comes before
            `startDate`, after `endDate` or after today, falls in a month more
            than three years before the current month, or is set on a contract
            whose `endDate` has passed.

            - `invalid_custom_fields`: the custom fields leave out a required
            custom field of contracts, name a key that no custom field of
            contracts has, or give a custom field a value that it does not take.

            - `invalid_billing_type`: the allocations name a payment account
            twice, or break `invoiceAllocationStrategy`: `single` takes one
            allocation of 100 percent, and `percent_split` takes a percentage on
            every allocation, with a total of 100.

            - `contract_and_payment_account_must_belong_to_the_same_customer`:
            an allocation names a payment account of a customer other than the
            customer of the contract and its subsidiaries that are not archived.

            - `contract_without_payment_gateway_settings`: every contract must
            have payment conditions, and `paymentGatewaySettings` is missing.

            - `invalid_proration_usage_scope`: the usage scope holds more than
            one customer while a plan of `planIds` charges for a resource whose
            billing model is proration.

            - `invalid_license_proration_allocation`:
            `invoiceAllocationStrategy` is `subsidiary_usage_split` while a plan
            of `planIds` has a license-based charge billed by proration.

            - `mixed_billing_frequency_family`: the plans of `planIds` have plan
            charges with billing frequencies in both months and weeks, or in a
            unit other than `billingSchedule.periodUnit`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - tax_regime_required
                      - customer_is_already_archived
                      - contract_legal_entity_mismatch
                      - invalid_customer_hierarchy
                      - start_date_after_end_date
                      - invalid_retroactive_date
                      - invalid_custom_fields
                      - invalid_billing_type
                      - >-
                        contract_and_payment_account_must_belong_to_the_same_customer
                      - contract_without_payment_gateway_settings
                      - invalid_proration_usage_scope
                      - invalid_license_proration_allocation
                      - mixed_billing_frequency_family
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''customerId'' is required'
                    code: json_schema_validation_error
                tax_regime_required:
                  value:
                    message: >-
                      tax regime is required for contracts when the tax regime
                      module is enabled
                    code: tax_regime_required
                customer_is_already_archived:
                  value:
                    message: customer is archived
                    code: customer_is_already_archived
                contract_legal_entity_mismatch:
                  value:
                    message: legal entity {legalEntityId} not found
                    code: contract_legal_entity_mismatch
                invalid_customer_hierarchy:
                  value:
                    message: contract usage scope must include at least one customer
                    code: invalid_customer_hierarchy
                start_date_after_end_date:
                  value:
                    message: Start date after end date
                    code: start_date_after_end_date
                invalid_retroactive_date:
                  value:
                    message: Retroactive date cannot be before start date
                    code: invalid_retroactive_date
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
                invalid_billing_type:
                  value:
                    message: 'unsupported tier pricing type: {value}'
                    code: invalid_billing_type
                contract_and_payment_account_must_belong_to_the_same_customer:
                  value:
                    message: >-
                      contract and payment account must belong to contract owner
                      or its subsidiaries
                    code: >-
                      contract_and_payment_account_must_belong_to_the_same_customer
                contract_without_payment_gateway_settings:
                  value:
                    message: contract without payment gateway settings
                    code: contract_without_payment_gateway_settings
                invalid_proration_usage_scope:
                  value:
                    message: >-
                      proration metrics are not supported when billing cycle
                      usage scope has more than one customer
                    code: invalid_proration_usage_scope
                invalid_license_proration_allocation:
                  value:
                    message: >-
                      prorated license charges are not supported on contracts
                      that split invoices by subsidiary usage
                    code: invalid_license_proration_allocation
                mixed_billing_frequency_family:
                  value:
                    message: >-
                      the plans of `planIds` have plan charges with billing
                      frequencies in both months and weeks, or in a unit other
                      than `billingSchedule.periodUnit`
                    code: mixed_billing_frequency_family
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `tax_regime_not_found`: no tax regime has the `taxRegimeId`, or
            that tax regime is archived.

            - `customer_not_found`: no customer has the `customerId`.

            - `payment_account_not_found`: an allocation names a payment account
            that does not exist or that is archived.

            - `plan_not_found`: an id of `planIds` names no plan.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - tax_regime_not_found
                      - customer_not_found
                      - payment_account_not_found
                      - plan_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                tax_regime_not_found:
                  value:
                    message: >-
                      tax regime version {taxRegimeVersionId} not found
                      (snapshotted on invoice {id})
                    code: tax_regime_not_found
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
                payment_account_not_found:
                  value:
                    message: payment account not found
                    code: payment_account_not_found
                plan_not_found:
                  value:
                    message: plan "{planId}" not found
                    code: plan_not_found
        '422':
          description: >-
            An outside service refuses the data of the request.


            - `incompatible_payment_method_for_provider`: the payment provider
            does not take `paymentGatewaySettings.paymentMethod`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - incompatible_payment_method_for_provider
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                incompatible_payment_method_for_provider:
                  value:
                    message: >-
                      payment method {method} is not supported by gateway
                      {activeProvider}
                    code: incompatible_payment_method_for_provider
    get:
      summary: List contracts
      tags:
        - Contracts
      description: >-
        Lists the contracts that match the filters, newest first by creation
        time, each with the plan instances attached to it. Filter by customer to
        reach the plan instances of a given customer.


        Requires the role `contracts:read`.
      parameters:
        - schema:
            type: string
          example: MERCA-CTR
          in: query
          name: search
          required: false
          description: >-
            Only return contracts whose contract number, or the name of one of
            the plan instances that the contract lists in planInstances,
            contains this text, ignoring case.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: customerIds[]
          required: false
          description: >-
            Only return contracts of these customers, identified by their id in
            our system.
        - schema:
            type: array
            items:
              type: string
              pattern: ^[a-zA-Z0-9_-]+$
          in: query
          name: customerExternalIds[]
          required: false
          description: >-
            Only return contracts of these customers, identified by their id in
            your system.
        - schema:
            type: array
            items:
              type: string
              enum:
                - active
                - canceled
                - completed
                - draft
          in: query
          name: status[]
          required: false
          description: >-
            Only return contracts in these statuses. All statuses are returned
            when omitted.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: productIds[]
          required: false
          description: >-
            Only return contracts with an active plan instance of a plan of one
            of these products.
        - schema:
            type: string
            format: uuid
          in: query
          name: planId
          required: false
          description: >-
            Only return contracts with a plan instance of this plan, in any
            status.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: legalEntityIds[]
          required: false
          description: Only return contracts that name one of these legal entities.
        - schema:
            type: object
            additionalProperties: false
            properties:
              contract:
                type: object
                description: Values of the custom fields of the contract.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
              customer:
                type: object
                description: Values of the custom fields of the customer of the contract.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
              product:
                type: object
                description: >-
                  Values of the custom fields of a product that an active plan
                  instance of the contract bills.
                additionalProperties:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                default: {}
                examples:
                  - customField1: value1
                    customField2:
                      - value2
                      - value3
          in: query
          name: customField
          required: false
          description: >-
            Only return contracts with these custom field values, each sent as
            customField[<entity>][<key>][]=<value>, where <entity> is contract,
            customer or product. A key matches when its custom field has any of
            the values sent for it, and every key sent must match. The value
            __aira_empty__ matches a custom field with no value.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_custom_fields
          when: '`customField` names a key that no custom field of its entity has'
        - *ref_1
        - *ref_2
      x-required-roles: &ref_13
        - contracts:read
      responses:
        '200':
          description: The contracts that match the filters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        An agreement with an individual or an organization that
                        bills plans, each through at most one active plan
                        instance, with the plan instances attached to it.
                      properties:
                        id:
                          description: The unique identifier of the contract in our system.
                          type: string
                          format: uuid
                        contractNumber:
                          type: string
                          description: >-
                            The number of the contract, which Aira gives it on
                            creation from the prefix of its customer and the
                            sequence of the contracts of that customer.
                          example: MERCA-CTR-01
                        customerId:
                          type: string
                          format: uuid
                          description: ID of the customer associated with this contract.
                        legalEntityId:
                          type: string
                          format: uuid
                          nullable: true
                          description: >-
                            ID of the legal entity that issues the invoices of
                            this contract.
                        startDate:
                          description: The start date of the contract.
                          type: string
                          format: date
                        endDate:
                          description: >-
                            The end date of the contract. Null if the contract
                            has no end date.
                          type:
                            - 'null'
                            - string
                          format: date
                        status:
                          description: The current status of the contract.
                          type: string
                          enum:
                            - active
                            - canceled
                            - completed
                            - draft
                        customFields:
                          type: object
                          description: >-
                            Custom fields that can be associated with the
                            entity. The fields must be previously created in the
                            system before they can be used.
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          default: {}
                          example:
                            customField1: value1
                            customField2:
                              - value2
                              - value3
                        planInstances:
                          description: >-
                            The plan instances attached to the contract. While
                            the contract is draft or active only its active plan
                            instances are listed; once the contract is completed
                            or canceled, all of them are.
                          type: array
                          items:
                            type: object
                            description: >-
                              A plan put on the contract. It has its own
                              versions, so the prices of one contract can change
                              while the plan stays the same.
                            properties:
                              id:
                                description: >-
                                  The unique identifier of the plan instance in
                                  our system. Use it to fetch or update the plan
                                  instance.
                                type: string
                                format: uuid
                              planId:
                                description: >-
                                  The unique identifier of the plan this
                                  instance was created from.
                                type: string
                                format: uuid
                              name:
                                description: >-
                                  The name of the plan this instance was created
                                  from.
                                type: string
                                example: Plano Essencial
                              status:
                                description: The current status of the plan instance.
                                type: string
                                enum:
                                  - active
                                  - canceled
                                  - completed
                            required:
                              - id
                              - planId
                              - name
                              - status
                            additionalProperties: false
                      required:
                        - id
                        - contractNumber
                        - customerId
                        - legalEntityId
                        - startDate
                        - endDate
                        - status
                        - customFields
                        - planInstances
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.

            - `invalid_custom_fields`: `customField` names a key that no custom
            field of its entity has.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''search'' must be string'
                    code: json_schema_validation_error
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/contracts/{id}/draft:
    put:
      summary: Update draft contract
      tags:
        - Contracts
      description: >-
        Replaces every field of a draft contract that can change, such as the
        term, the legal entity, the usage scope, the allocations, the billing
        schedule, the contract minimum and the payment conditions, so the body
        carries all of them.


        Requires the role `contracts:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                legalEntityId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    ID of the legal entity associated with this contract.
                    Optional on create; defaults to the default legal entity
                    when absent.
                startDate:
                  type: string
                  format: date
                  description: The first day of the term of the contract.
                endDate:
                  type: string
                  format: date
                  nullable: true
                  description: >-
                    The last day of the term of the contract, or null when the
                    contract has no end date.
                retroactiveDate:
                  type: string
                  format: date
                  nullable: true
                  description: >-
                    The date since which the contract was served before it
                    reached Aira, or null. Aira records invoices for the billing
                    cycles since that date but does not collect them, because
                    they were charged elsewhere.
                rateAdjustmentIndex:
                  type:
                    - 'null'
                    - string
                  enum:
                    - none
                    - igpm
                    - ipca
                    - other
                    - null
                  description: >-
                    Reference index (e.g. IPCA) used to filter contracts when
                    applying a mass adjustment on contracts.
                customFields:
                  type: object
                  description: >-
                    Custom fields that can be associated with the entity. The
                    fields must be previously created in the system before they
                    can be used.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
                taxRegimeId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    ID of the tax regime applied to invoices generated from this
                    contract. Null when no regime is attached.
                invoiceAllocationStrategy:
                  type: string
                  enum:
                    - single
                    - percent_split
                    - subsidiary_usage_split
                  description: >-
                    How each billing act of the contract becomes invoices:
                    `single` makes one invoice, `percent_split` makes one per
                    payment account by fixed percentages, and
                    `subsidiary_usage_split` makes one per payment account by
                    the share of the usage of its customer.
                includeNewSubsidiariesOnUsageScope:
                  type: boolean
                  description: >-
                    Whether future subsidiaries are automatically included in
                    usage scope.
                autoIssue:
                  type: boolean
                  description: >-
                    When true, invoices produced at billing-cycle close are
                    issued automatically instead of waiting in review. Defaults
                    to false when omitted; omitting it on update leaves the
                    current value unchanged.
                usageScopes:
                  type: array
                  items:
                    type: object
                    description: >-
                      A customer of the usage scope of the contract, whose usage
                      and license balances the contract bills.
                    properties:
                      customerId:
                        type: string
                        format: uuid
                        description: Customer ID that contributes usage to this contract.
                    required:
                      - customerId
                    additionalProperties: false
                  minItems: 1
                  description: >-
                    The usage scope of the contract: the customers whose usage
                    and license balances it bills, which are the individual
                    alone, or a set of the organization and its subsidiaries.
                  uniqueItems: true
                allocations:
                  type: array
                  description: >-
                    The contract allocation: the payment accounts that receive
                    the invoices of the contract.
                  items:
                    type: object
                    description: >-
                      A payment account that receives invoices of the contract,
                      with its share of each billing act.
                    properties:
                      paymentAccountId:
                        type: string
                        format: uuid
                        description: ID of the payment account.
                      allocationPercentage:
                        type: string
                        description: >-
                          The percentage of each billing act that the payment
                          account receives, from 0 to 100 with up to 6 decimal
                          places, or null, which only a contract that splits its
                          invoices by subsidiary usage allows.
                        nullable: true
                        example: '50.000000'
                    required:
                      - paymentAccountId
                      - allocationPercentage
                    additionalProperties: false
                  minItems: 1
                billingSettings:
                  type: object
                  description: >-
                    The contract minimum: the least that the contract bills in a
                    billing cycle, across all its plans. When its plans total
                    less, the closing invoice adds the difference.
                  properties:
                    invoiceMinimumAmount:
                      type: number
                      description: >-
                        The least amount, in cents, that the contract bills in a
                        billing cycle across all its plans.
                      minimum: 0
                    productId:
                      type: string
                      format: uuid
                      description: >-
                        Product ID to use for contract minimum amount line
                        items.
                  required:
                    - invoiceMinimumAmount
                    - productId
                  additionalProperties: false
                  nullable: true
                billingSchedule:
                  type: object
                  description: >-
                    How the billing cycles of the contract repeat: every month
                    or every week, from the billing day of the contract.
                  properties:
                    periodUnit:
                      type: string
                      enum:
                        - week
                        - month
                      description: >-
                        The calendar the contract closes on: month bills on a
                        day of the month, week on a weekday. Every plan on the
                        contract bills on this family; a plan from the other
                        family belongs on a second contract. A draft can change
                        it only while it has no plans.
                    anchorSource:
                      type: string
                      enum:
                        - based_on_contract_start_date
                        - explicit
                        - first_day_of_month
                      description: >-
                        The label the contract screen shows for the billing day.
                        The engine bills on anchorDay alone, so
                        first_day_of_month only describes a schedule that
                        already opens on day 1.
                    anchorDay:
                      type: integer
                      minimum: 1
                      maximum: 31
                      description: >-
                        The billing day, read per family: day of month (1-31) on
                        the month family, day of week (1=Sunday...7=Saturday) on
                        the week family.
                  required:
                    - periodUnit
                    - anchorSource
                    - anchorDay
                  allOf:
                    - if:
                        type: object
                        properties:
                          anchorSource:
                            enum:
                              - first_day_of_month
                        required:
                          - anchorSource
                      then:
                        type: object
                        properties:
                          anchorDay:
                            enum:
                              - 1
                      errorMessage: >-
                        must pair first_day_of_month with anchorDay 1; use
                        another anchorSource to bill on a different day
                    - if:
                        type: object
                        properties:
                          periodUnit:
                            enum:
                              - week
                        required:
                          - periodUnit
                      then:
                        type: object
                        properties:
                          anchorDay:
                            type: integer
                            maximum: 7
                      errorMessage: >-
                        on the week calendar the billing day is a weekday, 1
                        (Sunday) to 7 (Saturday)
                    - if:
                        type: object
                        properties:
                          anchorSource:
                            enum:
                              - first_day_of_month
                        required:
                          - anchorSource
                      then:
                        type: object
                        properties:
                          periodUnit:
                            enum:
                              - month
                      errorMessage: >-
                        first_day_of_month is a month-calendar label; the week
                        calendar bills on a weekday
                  additionalProperties: false
                paymentGatewaySettings:
                  type: object
                  description: >-
                    The payment conditions of the contract: how its invoices are
                    paid, with the payment method, and the due date as a number
                    of days after the issue or a fixed day of the month.
                  properties:
                    paymentMethod:
                      type: string
                      enum:
                        - bolepix
                        - bank_slip
                        - pix
                        - credit_card
                        - bank_transfer
                      description: >-
                        Payment method to use for this contract. Must be
                        supported by the active payment provider.
                    dueDateMode:
                      type: string
                      enum:
                        - days_after_issue
                        - fixed_day
                      description: >-
                        How invoice due dates are derived: a day offset from the
                        issue date, or a fixed day of the month.
                      default: days_after_issue
                    dueOffsetDays:
                      type: number
                      minimum: 0
                      nullable: true
                      description: >-
                        Number of days after the issue date until payment is due
                        (0 = due on issue day). Used when dueDateMode is
                        days_after_issue.
                    dueDay:
                      type: number
                      minimum: 1
                      maximum: 31
                      nullable: true
                      description: >-
                        Day of the month invoices are due on, clamped to the
                        last day of shorter months. Used when dueDateMode is
                        fixed_day.
                    dueMonthOffset:
                      type: integer
                      enum:
                        - 0
                        - 1
                      description: >-
                        How many months after the issue month the fixed due day
                        falls on: 0 for the same month, 1 for the next. Used
                        when dueDateMode is fixed_day.
                      default: 0
                    rollDueDateToBusinessDay:
                      type: boolean
                      description: >-
                        Whether a due date landing on a weekend moves to the
                        next business day. Off keeps it on the day it falls.
                      default: true
                  required:
                    - paymentMethod
                    - dueDateMode
                  allOf:
                    - if:
                        properties:
                          dueDateMode:
                            enum:
                              - fixed_day
                        required:
                          - dueDateMode
                      then:
                        properties:
                          dueDay:
                            not:
                              enum:
                                - null
                        required:
                          - dueDay
                      else:
                        properties:
                          dueOffsetDays:
                            not:
                              enum:
                                - null
                        required:
                          - dueOffsetDays
                  additionalProperties: false
                  nullable: true
              required:
                - startDate
                - endDate
                - retroactiveDate
                - rateAdjustmentIndex
                - customFields
                - invoiceAllocationStrategy
                - includeNewSubsidiariesOnUsageScope
                - usageScopes
                - allocations
                - billingSchedule
              additionalProperties: false
        required: true
        description: The fields of the draft contract, which replace its current ones.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: Unique identifier for the contract.
      x-public-api: true
      x-errors:
        - status: 400
          code: tax_regime_required
          when: the tax regime module is on and `taxRegimeId` is missing
        - status: 400
          code: contract_must_be_draft
          when: the contract is not a draft
        - status: 400
          code: contract_legal_entity_mismatch
          when: no legal entity has the `legalEntityId`
        - status: 400
          code: invalid_license_proration_allocation
          when: >-
            `invoiceAllocationStrategy` is `subsidiary_usage_split` while a plan
            of the contract has a license-based charge billed by proration
        - status: 400
          code: start_date_after_end_date
          when: '`endDate` is on or before `startDate`'
        - status: 400
          code: invalid_retroactive_date
          when: >-
            `retroactiveDate` comes before `startDate`, after `endDate` or after
            today, falls in a month more than three years before the current
            month, or is set on a contract whose `endDate` has passed
        - status: 400
          code: invalid_custom_fields
          when: >-
            the custom fields leave out a required custom field of contracts,
            name a key that no custom field of contracts has, or give a custom
            field a value that it does not take
        - status: 400
          code: invalid_customer_hierarchy
          when: >-
            the usage scope names a customer twice, the contract of an
            individual has another customer in its usage scope or sets
            `includeNewSubsidiariesOnUsageScope`, or the usage scope of an
            organization names a customer other than the organization and its
            subsidiaries that are not archived
        - status: 400
          code: invalid_billing_type
          when: >-
            the allocations name a payment account twice, or break
            `invoiceAllocationStrategy`: `single` takes one allocation of 100
            percent, and `percent_split` takes a percentage on every allocation,
            with a total of 100
        - status: 400
          code: contract_and_payment_account_must_belong_to_the_same_customer
          when: >-
            an allocation names a payment account of a customer other than the
            customer of the contract and its subsidiaries that are not archived
        - status: 400
          code: contract_without_payment_gateway_settings
          when: >-
            every contract must have payment conditions, and
            `paymentGatewaySettings` is missing
        - status: 400
          code: contract_billing_calendar_locked
          when: >-
            `billingSchedule.periodUnit` differs from that of the contract while
            the contract has an active plan instance
        - status: 404
          code: contract_not_found
          when: no contract has the `id`
        - status: 404
          code: tax_regime_not_found
          when: no tax regime has the `taxRegimeId`, or that tax regime is archived
        - status: 404
          code: payment_account_not_found
          when: >-
            an allocation names a payment account that does not exist or that is
            archived
        - status: 422
          code: incompatible_payment_method_for_provider
          when: >-
            the payment provider does not take
            `paymentGatewaySettings.paymentMethod`
      x-required-roles: *ref_12
      responses:
        '200':
          description: >-
            An agreement with an individual or an organization that bills plans,
            each through at most one active plan instance. It holds the term,
            the billing schedule, the usage scope, the payment accounts and the
            payment conditions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: Unique identifier for the contract.
                  contractNumber:
                    type: string
                    description: >-
                      The number of the contract, which Aira gives it on
                      creation from the prefix of its customer and the sequence
                      of the contracts of that customer.
                    example: MERCA-CTR-01
                  customerId:
                    type: string
                    format: uuid
                    description: ID of the customer associated with this contract.
                  legalEntityId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      ID of the legal entity associated with this contract.
                      Optional on create; defaults to the default legal entity
                      when absent.
                  legalEntity:
                    type: object
                    description: >-
                      The legal entity, a registered company, that issues the
                      invoices of the contract.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the legal entity in our
                          system.
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                    required:
                      - id
                      - businessName
                      - tradeName
                    additionalProperties: false
                  startDate:
                    type: string
                    format: date
                    description: The first day of the term of the contract.
                  endDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      The last day of the term of the contract, or null when the
                      contract has no end date.
                  retroactiveDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      The date since which the contract was served before it
                      reached Aira, or null. Aira records invoices for the
                      billing cycles since that date but does not collect them,
                      because they were charged elsewhere.
                  invoicingStartDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Read-only. Start date of the first billing cycle Aira
                      invoices for this contract, recorded when it is activated:
                      the cycle containing the retroactive date when one is set,
                      otherwise the cycle running on the activation day, or the
                      contract start when that is still ahead. Null while the
                      contract is a draft.
                  status:
                    type: string
                    enum:
                      - active
                      - canceled
                      - completed
                      - draft
                    description: Current status of the contract.
                  rateAdjustmentIndex:
                    type:
                      - 'null'
                      - string
                    enum:
                      - none
                      - igpm
                      - ipca
                      - other
                      - null
                    description: >-
                      Reference index (e.g. IPCA) used to filter contracts when
                      applying a mass adjustment on contracts.
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  taxRegimeId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      ID of the tax regime applied to invoices generated from
                      this contract. Null when no regime is attached.
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How each billing act of the contract becomes invoices:
                      `single` makes one invoice, `percent_split` makes one per
                      payment account by fixed percentages, and
                      `subsidiary_usage_split` makes one per payment account by
                      the share of the usage of its customer.
                  includeNewSubsidiariesOnUsageScope:
                    type: boolean
                    description: >-
                      Whether future subsidiaries are automatically included in
                      usage scope.
                  autoIssue:
                    type: boolean
                    description: >-
                      When true, invoices produced at billing-cycle close are
                      issued automatically instead of waiting in review.
                      Defaults to false when omitted; omitting it on update
                      leaves the current value unchanged.
                  usageScopes:
                    type: array
                    items:
                      type: object
                      description: >-
                        A customer of the usage scope of the contract, whose
                        usage and license balances the contract bills.
                      properties:
                        customerId:
                          type: string
                          format: uuid
                          description: Customer ID that contributes usage to this contract.
                      required:
                        - customerId
                      additionalProperties: false
                    minItems: 1
                    description: >-
                      The usage scope of the contract: the customers whose usage
                      and license balances it bills, which are the individual
                      alone, or a set of the organization and its subsidiaries.
                    uniqueItems: true
                  allocations:
                    type: array
                    description: >-
                      The contract allocation: the payment accounts that receive
                      the invoices of the contract.
                    items:
                      type: object
                      description: >-
                        A payment account that receives invoices of the
                        contract, with its share of each billing act.
                      properties:
                        paymentAccountId:
                          type: string
                          format: uuid
                          description: ID of the payment account.
                        allocationPercentage:
                          type: string
                          description: >-
                            The percentage of each billing act that the payment
                            account receives, from 0 to 100 with up to 6 decimal
                            places, or null, which only a contract that splits
                            its invoices by subsidiary usage allows.
                          nullable: true
                          example: '50.000000'
                      required:
                        - paymentAccountId
                        - allocationPercentage
                      additionalProperties: false
                    minItems: 1
                  billingSettings:
                    type: object
                    description: >-
                      The contract minimum: the least that the contract bills in
                      a billing cycle, across all its plans. When its plans
                      total less, the closing invoice adds the difference.
                    properties:
                      invoiceMinimumAmount:
                        type: number
                        description: >-
                          The least amount, in cents, that the contract bills in
                          a billing cycle across all its plans.
                        minimum: 0
                      productId:
                        type: string
                        format: uuid
                        description: >-
                          Product ID to use for contract minimum amount line
                          items.
                    required:
                      - invoiceMinimumAmount
                      - productId
                    additionalProperties: false
                    nullable: true
                  billingSchedule:
                    type: object
                    description: >-
                      How the billing cycles of the contract repeat: every month
                      or every week, from the billing day of the contract.
                    properties:
                      periodUnit:
                        type: string
                        enum:
                          - week
                          - month
                        description: >-
                          The calendar the contract closes on: month bills on a
                          day of the month, week on a weekday. Every plan on the
                          contract bills on this family; a plan from the other
                          family belongs on a second contract. A draft can
                          change it only while it has no plans.
                      anchorSource:
                        type: string
                        enum:
                          - based_on_contract_start_date
                          - explicit
                          - first_day_of_month
                        description: >-
                          The label the contract screen shows for the billing
                          day. The engine bills on anchorDay alone, so
                          first_day_of_month only describes a schedule that
                          already opens on day 1.
                      anchorDay:
                        type: integer
                        minimum: 1
                        maximum: 31
                        description: >-
                          The billing day, read per family: day of month (1-31)
                          on the month family, day of week
                          (1=Sunday...7=Saturday) on the week family.
                    required:
                      - periodUnit
                      - anchorSource
                      - anchorDay
                    allOf:
                      - if:
                          type: object
                          properties:
                            anchorSource:
                              enum:
                                - first_day_of_month
                          required:
                            - anchorSource
                        then:
                          type: object
                          properties:
                            anchorDay:
                              enum:
                                - 1
                        errorMessage: >-
                          must pair first_day_of_month with anchorDay 1; use
                          another anchorSource to bill on a different day
                      - if:
                          type: object
                          properties:
                            periodUnit:
                              enum:
                                - week
                          required:
                            - periodUnit
                        then:
                          type: object
                          properties:
                            anchorDay:
                              type: integer
                              maximum: 7
                        errorMessage: >-
                          on the week calendar the billing day is a weekday, 1
                          (Sunday) to 7 (Saturday)
                      - if:
                          type: object
                          properties:
                            anchorSource:
                              enum:
                                - first_day_of_month
                          required:
                            - anchorSource
                        then:
                          type: object
                          properties:
                            periodUnit:
                              enum:
                                - month
                        errorMessage: >-
                          first_day_of_month is a month-calendar label; the week
                          calendar bills on a weekday
                    additionalProperties: false
                  paymentGatewaySettings:
                    type: object
                    description: >-
                      The payment conditions of the contract: how its invoices
                      are paid, with the payment method, and the due date as a
                      number of days after the issue or a fixed day of the
                      month.
                    properties:
                      paymentMethod:
                        type: string
                        enum:
                          - bolepix
                          - bank_slip
                          - pix
                          - credit_card
                          - bank_transfer
                        description: >-
                          Payment method to use for this contract. Must be
                          supported by the active payment provider.
                      dueDateMode:
                        type: string
                        enum:
                          - days_after_issue
                          - fixed_day
                        description: >-
                          How invoice due dates are derived: a day offset from
                          the issue date, or a fixed day of the month.
                        default: days_after_issue
                      dueOffsetDays:
                        type: number
                        minimum: 0
                        nullable: true
                        description: >-
                          Number of days after the issue date until payment is
                          due (0 = due on issue day). Used when dueDateMode is
                          days_after_issue.
                      dueDay:
                        type: number
                        minimum: 1
                        maximum: 31
                        nullable: true
                        description: >-
                          Day of the month invoices are due on, clamped to the
                          last day of shorter months. Used when dueDateMode is
                          fixed_day.
                      dueMonthOffset:
                        type: integer
                        enum:
                          - 0
                          - 1
                        description: >-
                          How many months after the issue month the fixed due
                          day falls on: 0 for the same month, 1 for the next.
                          Used when dueDateMode is fixed_day.
                        default: 0
                      rollDueDateToBusinessDay:
                        type: boolean
                        description: >-
                          Whether a due date landing on a weekend moves to the
                          next business day. Off keeps it on the day it falls.
                        default: true
                    required:
                      - paymentMethod
                      - dueDateMode
                    allOf:
                      - if:
                          properties:
                            dueDateMode:
                              enum:
                                - fixed_day
                          required:
                            - dueDateMode
                        then:
                          properties:
                            dueDay:
                              not:
                                enum:
                                  - null
                          required:
                            - dueDay
                        else:
                          properties:
                            dueOffsetDays:
                              not:
                                enum:
                                  - null
                          required:
                            - dueOffsetDays
                    additionalProperties: false
                    nullable: true
                  planInstances:
                    description: >-
                      The plan instances attached to the contract. While the
                      contract is draft or active only its active plan instances
                      are listed; once the contract is completed or canceled,
                      all of them are.
                    type: array
                    items:
                      type: object
                      description: >-
                        A plan put on the contract. It has its own versions, so
                        the prices of one contract can change while the plan
                        stays the same.
                      properties:
                        id:
                          description: >-
                            The unique identifier of the plan instance in our
                            system. Use it to fetch or update the plan instance.
                          type: string
                          format: uuid
                        planId:
                          description: >-
                            The unique identifier of the plan this instance was
                            created from.
                          type: string
                          format: uuid
                        name:
                          description: The name of the plan this instance was created from.
                          type: string
                          example: Plano Essencial
                        status:
                          description: The current status of the plan instance.
                          type: string
                          enum:
                            - active
                            - canceled
                            - completed
                      required:
                        - id
                        - planId
                        - name
                        - status
                      additionalProperties: false
                required:
                  - id
                  - contractNumber
                  - customerId
                  - startDate
                  - endDate
                  - retroactiveDate
                  - invoicingStartDate
                  - status
                  - rateAdjustmentIndex
                  - customFields
                  - invoiceAllocationStrategy
                  - includeNewSubsidiariesOnUsageScope
                  - usageScopes
                  - allocations
                  - billingSchedule
                  - planInstances
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `tax_regime_required`: the tax regime module is on and
            `taxRegimeId` is missing.

            - `contract_must_be_draft`: the contract is not a draft.

            - `contract_legal_entity_mismatch`: no legal entity has the
            `legalEntityId`.

            - `invalid_license_proration_allocation`:
            `invoiceAllocationStrategy` is `subsidiary_usage_split` while a plan
            of the contract has a license-based charge billed by proration.

            - `start_date_after_end_date`: `endDate` is on or before
            `startDate`.

            - `invalid_retroactive_date`: `retroactiveDate` comes before
            `startDate`, after `endDate` or after today, falls in a month more
            than three years before the current month, or is set on a contract
            whose `endDate` has passed.

            - `invalid_custom_fields`: the custom fields leave out a required
            custom field of contracts, name a key that no custom field of
            contracts has, or give a custom field a value that it does not take.

            - `invalid_customer_hierarchy`: the usage scope names a customer
            twice, the contract of an individual has another customer in its
            usage scope or sets `includeNewSubsidiariesOnUsageScope`, or the
            usage scope of an organization names a customer other than the
            organization and its subsidiaries that are not archived.

            - `invalid_billing_type`: the allocations name a payment account
            twice, or break `invoiceAllocationStrategy`: `single` takes one
            allocation of 100 percent, and `percent_split` takes a percentage on
            every allocation, with a total of 100.

            - `contract_and_payment_account_must_belong_to_the_same_customer`:
            an allocation names a payment account of a customer other than the
            customer of the contract and its subsidiaries that are not archived.

            - `contract_without_payment_gateway_settings`: every contract must
            have payment conditions, and `paymentGatewaySettings` is missing.

            - `contract_billing_calendar_locked`: `billingSchedule.periodUnit`
            differs from that of the contract while the contract has an active
            plan instance.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - tax_regime_required
                      - contract_must_be_draft
                      - contract_legal_entity_mismatch
                      - invalid_license_proration_allocation
                      - start_date_after_end_date
                      - invalid_retroactive_date
                      - invalid_custom_fields
                      - invalid_customer_hierarchy
                      - invalid_billing_type
                      - >-
                        contract_and_payment_account_must_belong_to_the_same_customer
                      - contract_without_payment_gateway_settings
                      - contract_billing_calendar_locked
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''startDate'' is required'
                    code: json_schema_validation_error
                tax_regime_required:
                  value:
                    message: >-
                      tax regime is required for contracts when the tax regime
                      module is enabled
                    code: tax_regime_required
                contract_must_be_draft:
                  value:
                    message: contract must be draft
                    code: contract_must_be_draft
                contract_legal_entity_mismatch:
                  value:
                    message: legal entity {legalEntityId} not found
                    code: contract_legal_entity_mismatch
                invalid_license_proration_allocation:
                  value:
                    message: >-
                      prorated license charges are not supported on contracts
                      that split invoices by subsidiary usage
                    code: invalid_license_proration_allocation
                start_date_after_end_date:
                  value:
                    message: Start date after end date
                    code: start_date_after_end_date
                invalid_retroactive_date:
                  value:
                    message: Retroactive date cannot be before start date
                    code: invalid_retroactive_date
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
                invalid_customer_hierarchy:
                  value:
                    message: contract usage scope must include at least one customer
                    code: invalid_customer_hierarchy
                invalid_billing_type:
                  value:
                    message: 'unsupported tier pricing type: {value}'
                    code: invalid_billing_type
                contract_and_payment_account_must_belong_to_the_same_customer:
                  value:
                    message: >-
                      contract and payment account must belong to contract owner
                      or its subsidiaries
                    code: >-
                      contract_and_payment_account_must_belong_to_the_same_customer
                contract_without_payment_gateway_settings:
                  value:
                    message: contract without payment gateway settings
                    code: contract_without_payment_gateway_settings
                contract_billing_calendar_locked:
                  value:
                    message: >-
                      the billing calendar cannot change while the contract has
                      plans; remove them first or create a new contract
                    code: contract_billing_calendar_locked
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `contract_not_found`: no contract has the `id`.

            - `tax_regime_not_found`: no tax regime has the `taxRegimeId`, or
            that tax regime is archived.

            - `payment_account_not_found`: an allocation names a payment account
            that does not exist or that is archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                      - tax_regime_not_found
                      - payment_account_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
                tax_regime_not_found:
                  value:
                    message: >-
                      tax regime version {taxRegimeVersionId} not found
                      (snapshotted on invoice {id})
                    code: tax_regime_not_found
                payment_account_not_found:
                  value:
                    message: payment account not found
                    code: payment_account_not_found
        '422':
          description: >-
            An outside service refuses the data of the request.


            - `incompatible_payment_method_for_provider`: the payment provider
            does not take `paymentGatewaySettings.paymentMethod`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - incompatible_payment_method_for_provider
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                incompatible_payment_method_for_provider:
                  value:
                    message: >-
                      payment method {method} is not supported by gateway
                      {activeProvider}
                    code: incompatible_payment_method_for_provider
  /v1/contracts/{id}/active:
    put:
      summary: Update active contract
      tags:
        - Contracts
      description: >-
        Replaces the fields of an active contract that can change, such as the
        end date, the legal entity, the usage scope, the allocations, the
        contract minimum and the payment conditions, so the body carries all of
        them. Send `legalEntityId` to move the contract to another legal entity,
        or leave it out or send null to keep the current one. Aira then
        re-derives the invoices of the open billing cycles of the contract that
        have started, and a new end date moves the end of the open billing
        cycles and cancels those that have not started and start after it. The
        integrations that you connect receive the change.


        Requires the role `contracts:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                legalEntityId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    ID of the legal entity associated with this contract.
                    Optional on create; defaults to the default legal entity
                    when absent.
                endDate:
                  type: string
                  format: date
                  nullable: true
                  description: >-
                    The last day of the term of the contract, or null when the
                    contract has no end date.
                rateAdjustmentIndex:
                  type:
                    - 'null'
                    - string
                  enum:
                    - none
                    - igpm
                    - ipca
                    - other
                    - null
                  description: >-
                    Reference index (e.g. IPCA) used to filter contracts when
                    applying a mass adjustment on contracts.
                customFields:
                  type: object
                  description: >-
                    Custom fields that can be associated with the entity. The
                    fields must be previously created in the system before they
                    can be used.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
                taxRegimeId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    ID of the tax regime applied to invoices generated from this
                    contract. Null when no regime is attached.
                includeNewSubsidiariesOnUsageScope:
                  type: boolean
                  description: >-
                    Whether future subsidiaries are automatically included in
                    usage scope.
                autoIssue:
                  type: boolean
                  description: >-
                    When true, invoices produced at billing-cycle close are
                    issued automatically instead of waiting in review. Defaults
                    to false when omitted; omitting it on update leaves the
                    current value unchanged.
                usageScopes:
                  type: array
                  items:
                    type: object
                    description: >-
                      A customer of the usage scope of the contract, whose usage
                      and license balances the contract bills.
                    properties:
                      customerId:
                        type: string
                        format: uuid
                        description: Customer ID that contributes usage to this contract.
                    required:
                      - customerId
                    additionalProperties: false
                  minItems: 1
                  description: >-
                    The usage scope of the contract: the customers whose usage
                    and license balances it bills, which are the individual
                    alone, or a set of the organization and its subsidiaries.
                  uniqueItems: true
                allocations:
                  type: array
                  description: >-
                    The contract allocation: the payment accounts that receive
                    the invoices of the contract.
                  items:
                    type: object
                    description: >-
                      A payment account that receives invoices of the contract,
                      with its share of each billing act.
                    properties:
                      paymentAccountId:
                        type: string
                        format: uuid
                        description: ID of the payment account.
                      allocationPercentage:
                        type: string
                        description: >-
                          The percentage of each billing act that the payment
                          account receives, from 0 to 100 with up to 6 decimal
                          places, or null, which only a contract that splits its
                          invoices by subsidiary usage allows.
                        nullable: true
                        example: '50.000000'
                    required:
                      - paymentAccountId
                      - allocationPercentage
                    additionalProperties: false
                  minItems: 1
                billingSettings:
                  type: object
                  description: >-
                    The contract minimum: the least that the contract bills in a
                    billing cycle, across all its plans. When its plans total
                    less, the closing invoice adds the difference.
                  properties:
                    invoiceMinimumAmount:
                      type: number
                      description: >-
                        The least amount, in cents, that the contract bills in a
                        billing cycle across all its plans.
                      minimum: 0
                    productId:
                      type: string
                      format: uuid
                      description: >-
                        Product ID to use for contract minimum amount line
                        items.
                  required:
                    - invoiceMinimumAmount
                    - productId
                  additionalProperties: false
                  nullable: true
                paymentGatewaySettings:
                  type: object
                  description: >-
                    The payment conditions of the contract: how its invoices are
                    paid, with the payment method, and the due date as a number
                    of days after the issue or a fixed day of the month.
                  properties:
                    paymentMethod:
                      type: string
                      enum:
                        - bolepix
                        - bank_slip
                        - pix
                        - credit_card
                        - bank_transfer
                      description: >-
                        Payment method to use for this contract. Must be
                        supported by the active payment provider.
                    dueDateMode:
                      type: string
                      enum:
                        - days_after_issue
                        - fixed_day
                      description: >-
                        How invoice due dates are derived: a day offset from the
                        issue date, or a fixed day of the month.
                      default: days_after_issue
                    dueOffsetDays:
                      type: number
                      minimum: 0
                      nullable: true
                      description: >-
                        Number of days after the issue date until payment is due
                        (0 = due on issue day). Used when dueDateMode is
                        days_after_issue.
                    dueDay:
                      type: number
                      minimum: 1
                      maximum: 31
                      nullable: true
                      description: >-
                        Day of the month invoices are due on, clamped to the
                        last day of shorter months. Used when dueDateMode is
                        fixed_day.
                    dueMonthOffset:
                      type: integer
                      enum:
                        - 0
                        - 1
                      description: >-
                        How many months after the issue month the fixed due day
                        falls on: 0 for the same month, 1 for the next. Used
                        when dueDateMode is fixed_day.
                      default: 0
                    rollDueDateToBusinessDay:
                      type: boolean
                      description: >-
                        Whether a due date landing on a weekend moves to the
                        next business day. Off keeps it on the day it falls.
                      default: true
                  required:
                    - paymentMethod
                    - dueDateMode
                  allOf:
                    - if:
                        properties:
                          dueDateMode:
                            enum:
                              - fixed_day
                        required:
                          - dueDateMode
                      then:
                        properties:
                          dueDay:
                            not:
                              enum:
                                - null
                        required:
                          - dueDay
                      else:
                        properties:
                          dueOffsetDays:
                            not:
                              enum:
                                - null
                        required:
                          - dueOffsetDays
                  additionalProperties: false
                  nullable: true
              required:
                - endDate
                - rateAdjustmentIndex
                - customFields
                - includeNewSubsidiariesOnUsageScope
                - usageScopes
                - allocations
              additionalProperties: false
        required: true
        description: >-
          The fields of the active contract that can change, which replace its
          current ones.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: Unique identifier for the contract.
      x-public-api: true
      x-errors:
        - status: 400
          code: tax_regime_required
          when: the tax regime module is on and `taxRegimeId` is missing
        - status: 400
          code: contract_must_be_active
          when: the contract is not active
        - status: 400
          code: contract_legal_entity_mismatch
          when: no legal entity has the `legalEntityId`
        - status: 400
          code: invalid_custom_fields
          when: >-
            the custom fields leave out a required custom field of contracts,
            name a key that no custom field of contracts has, or give a custom
            field a value that it does not take
        - status: 400
          code: invalid_customer_hierarchy
          when: >-
            the usage scope names a customer twice, the contract of an
            individual has another customer in its usage scope or sets
            `includeNewSubsidiariesOnUsageScope`, or the usage scope of an
            organization names a customer other than the organization and its
            subsidiaries that are not archived
        - status: 400
          code: invalid_billing_type
          when: >-
            the allocations name a payment account twice, or break the
            allocation strategy of the contract: `single` takes one allocation
            of 100 percent, and `percent_split` takes a percentage on every
            allocation, with a total of 100
        - status: 400
          code: contract_and_payment_account_must_belong_to_the_same_customer
          when: >-
            an allocation names a payment account of a customer other than the
            customer of the contract and its subsidiaries that are not archived
        - status: 400
          code: contract_without_payment_gateway_settings
          when: >-
            every contract must have payment conditions, and
            `paymentGatewaySettings` is missing
        - status: 400
          code: start_date_after_end_date
          when: the new `endDate` is on or before the start date of the contract
        - status: 400
          code: invalid_retroactive_date
          when: >-
            `endDate` changes while the retroactive date of the contract comes
            after the new `endDate` or falls in a month more than three years
            before the current month, or the new `endDate` has passed while the
            contract has a retroactive date
        - status: 400
          code: end_date_must_be_after_latest_invoice_date
          when: >-
            the new `endDate` is on or before the date of the latest invoice of
            the contract that is not canceled
        - status: 400
          code: invalid_proration_usage_scope
          when: >-
            the new `endDate` moves the end of an open billing cycle, which Aira
            then prices, while the usage scope holds more than one customer and
            a plan of the contract charges for a resource whose billing model is
            proration
        - status: 400
          code: invalid_credit_ledger_entry_for_credit_purchase
          when: >-
            the new `endDate` moves the end of an open billing cycle, which Aira
            then prices, while that billing cycle consumes more credits than a
            credit pool of the customer holds and the credit package that tops
            up that pool holds zero credits
        - status: 404
          code: contract_not_found
          when: no contract has the `id`
        - status: 404
          code: tax_regime_not_found
          when: no tax regime has the `taxRegimeId`, or that tax regime is archived
        - status: 404
          code: payment_account_not_found
          when: >-
            an allocation names a payment account that does not exist or that is
            archived
        - status: 422
          code: incompatible_payment_method_for_provider
          when: >-
            the payment provider does not take
            `paymentGatewaySettings.paymentMethod`
        - status: 503
          code: stale_events_writer
          when: >-
            the new `endDate` moves the end of an open billing cycle, which Aira
            then prices, while a write of events has run for longer than any
            write of events may last
      x-required-roles: *ref_12
      responses:
        '200':
          description: >-
            An agreement with an individual or an organization that bills plans,
            each through at most one active plan instance. It holds the term,
            the billing schedule, the usage scope, the payment accounts and the
            payment conditions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: Unique identifier for the contract.
                  contractNumber:
                    type: string
                    description: >-
                      The number of the contract, which Aira gives it on
                      creation from the prefix of its customer and the sequence
                      of the contracts of that customer.
                    example: MERCA-CTR-01
                  customerId:
                    type: string
                    format: uuid
                    description: ID of the customer associated with this contract.
                  legalEntityId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      ID of the legal entity associated with this contract.
                      Optional on create; defaults to the default legal entity
                      when absent.
                  legalEntity:
                    type: object
                    description: >-
                      The legal entity, a registered company, that issues the
                      invoices of the contract.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the legal entity in our
                          system.
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                    required:
                      - id
                      - businessName
                      - tradeName
                    additionalProperties: false
                  startDate:
                    type: string
                    format: date
                    description: The first day of the term of the contract.
                  endDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      The last day of the term of the contract, or null when the
                      contract has no end date.
                  retroactiveDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      The date since which the contract was served before it
                      reached Aira, or null. Aira records invoices for the
                      billing cycles since that date but does not collect them,
                      because they were charged elsewhere.
                  invoicingStartDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Read-only. Start date of the first billing cycle Aira
                      invoices for this contract, recorded when it is activated:
                      the cycle containing the retroactive date when one is set,
                      otherwise the cycle running on the activation day, or the
                      contract start when that is still ahead. Null while the
                      contract is a draft.
                  status:
                    type: string
                    enum:
                      - active
                      - canceled
                      - completed
                      - draft
                    description: Current status of the contract.
                  rateAdjustmentIndex:
                    type:
                      - 'null'
                      - string
                    enum:
                      - none
                      - igpm
                      - ipca
                      - other
                      - null
                    description: >-
                      Reference index (e.g. IPCA) used to filter contracts when
                      applying a mass adjustment on contracts.
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  taxRegimeId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      ID of the tax regime applied to invoices generated from
                      this contract. Null when no regime is attached.
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How each billing act of the contract becomes invoices:
                      `single` makes one invoice, `percent_split` makes one per
                      payment account by fixed percentages, and
                      `subsidiary_usage_split` makes one per payment account by
                      the share of the usage of its customer.
                  includeNewSubsidiariesOnUsageScope:
                    type: boolean
                    description: >-
                      Whether future subsidiaries are automatically included in
                      usage scope.
                  autoIssue:
                    type: boolean
                    description: >-
                      When true, invoices produced at billing-cycle close are
                      issued automatically instead of waiting in review.
                      Defaults to false when omitted; omitting it on update
                      leaves the current value unchanged.
                  usageScopes:
                    type: array
                    items:
                      type: object
                      description: >-
                        A customer of the usage scope of the contract, whose
                        usage and license balances the contract bills.
                      properties:
                        customerId:
                          type: string
                          format: uuid
                          description: Customer ID that contributes usage to this contract.
                      required:
                        - customerId
                      additionalProperties: false
                    minItems: 1
                    description: >-
                      The usage scope of the contract: the customers whose usage
                      and license balances it bills, which are the individual
                      alone, or a set of the organization and its subsidiaries.
                    uniqueItems: true
                  allocations:
                    type: array
                    description: >-
                      The contract allocation: the payment accounts that receive
                      the invoices of the contract.
                    items:
                      type: object
                      description: >-
                        A payment account that receives invoices of the
                        contract, with its share of each billing act.
                      properties:
                        paymentAccountId:
                          type: string
                          format: uuid
                          description: ID of the payment account.
                        allocationPercentage:
                          type: string
                          description: >-
                            The percentage of each billing act that the payment
                            account receives, from 0 to 100 with up to 6 decimal
                            places, or null, which only a contract that splits
                            its invoices by subsidiary usage allows.
                          nullable: true
                          example: '50.000000'
                      required:
                        - paymentAccountId
                        - allocationPercentage
                      additionalProperties: false
                    minItems: 1
                  billingSettings:
                    type: object
                    description: >-
                      The contract minimum: the least that the contract bills in
                      a billing cycle, across all its plans. When its plans
                      total less, the closing invoice adds the difference.
                    properties:
                      invoiceMinimumAmount:
                        type: number
                        description: >-
                          The least amount, in cents, that the contract bills in
                          a billing cycle across all its plans.
                        minimum: 0
                      productId:
                        type: string
                        format: uuid
                        description: >-
                          Product ID to use for contract minimum amount line
                          items.
                    required:
                      - invoiceMinimumAmount
                      - productId
                    additionalProperties: false
                    nullable: true
                  billingSchedule:
                    type: object
                    description: >-
                      How the billing cycles of the contract repeat: every month
                      or every week, from the billing day of the contract.
                    properties:
                      periodUnit:
                        type: string
                        enum:
                          - week
                          - month
                        description: >-
                          The calendar the contract closes on: month bills on a
                          day of the month, week on a weekday. Every plan on the
                          contract bills on this family; a plan from the other
                          family belongs on a second contract. A draft can
                          change it only while it has no plans.
                      anchorSource:
                        type: string
                        enum:
                          - based_on_contract_start_date
                          - explicit
                          - first_day_of_month
                        description: >-
                          The label the contract screen shows for the billing
                          day. The engine bills on anchorDay alone, so
                          first_day_of_month only describes a schedule that
                          already opens on day 1.
                      anchorDay:
                        type: integer
                        minimum: 1
                        maximum: 31
                        description: >-
                          The billing day, read per family: day of month (1-31)
                          on the month family, day of week
                          (1=Sunday...7=Saturday) on the week family.
                    required:
                      - periodUnit
                      - anchorSource
                      - anchorDay
                    allOf:
                      - if:
                          type: object
                          properties:
                            anchorSource:
                              enum:
                                - first_day_of_month
                          required:
                            - anchorSource
                        then:
                          type: object
                          properties:
                            anchorDay:
                              enum:
                                - 1
                        errorMessage: >-
                          must pair first_day_of_month with anchorDay 1; use
                          another anchorSource to bill on a different day
                      - if:
                          type: object
                          properties:
                            periodUnit:
                              enum:
                                - week
                          required:
                            - periodUnit
                        then:
                          type: object
                          properties:
                            anchorDay:
                              type: integer
                              maximum: 7
                        errorMessage: >-
                          on the week calendar the billing day is a weekday, 1
                          (Sunday) to 7 (Saturday)
                      - if:
                          type: object
                          properties:
                            anchorSource:
                              enum:
                                - first_day_of_month
                          required:
                            - anchorSource
                        then:
                          type: object
                          properties:
                            periodUnit:
                              enum:
                                - month
                        errorMessage: >-
                          first_day_of_month is a month-calendar label; the week
                          calendar bills on a weekday
                    additionalProperties: false
                  paymentGatewaySettings:
                    type: object
                    description: >-
                      The payment conditions of the contract: how its invoices
                      are paid, with the payment method, and the due date as a
                      number of days after the issue or a fixed day of the
                      month.
                    properties:
                      paymentMethod:
                        type: string
                        enum:
                          - bolepix
                          - bank_slip
                          - pix
                          - credit_card
                          - bank_transfer
                        description: >-
                          Payment method to use for this contract. Must be
                          supported by the active payment provider.
                      dueDateMode:
                        type: string
                        enum:
                          - days_after_issue
                          - fixed_day
                        description: >-
                          How invoice due dates are derived: a day offset from
                          the issue date, or a fixed day of the month.
                        default: days_after_issue
                      dueOffsetDays:
                        type: number
                        minimum: 0
                        nullable: true
                        description: >-
                          Number of days after the issue date until payment is
                          due (0 = due on issue day). Used when dueDateMode is
                          days_after_issue.
                      dueDay:
                        type: number
                        minimum: 1
                        maximum: 31
                        nullable: true
                        description: >-
                          Day of the month invoices are due on, clamped to the
                          last day of shorter months. Used when dueDateMode is
                          fixed_day.
                      dueMonthOffset:
                        type: integer
                        enum:
                          - 0
                          - 1
                        description: >-
                          How many months after the issue month the fixed due
                          day falls on: 0 for the same month, 1 for the next.
                          Used when dueDateMode is fixed_day.
                        default: 0
                      rollDueDateToBusinessDay:
                        type: boolean
                        description: >-
                          Whether a due date landing on a weekend moves to the
                          next business day. Off keeps it on the day it falls.
                        default: true
                    required:
                      - paymentMethod
                      - dueDateMode
                    allOf:
                      - if:
                          properties:
                            dueDateMode:
                              enum:
                                - fixed_day
                          required:
                            - dueDateMode
                        then:
                          properties:
                            dueDay:
                              not:
                                enum:
                                  - null
                          required:
                            - dueDay
                        else:
                          properties:
                            dueOffsetDays:
                              not:
                                enum:
                                  - null
                          required:
                            - dueOffsetDays
                    additionalProperties: false
                    nullable: true
                  planInstances:
                    description: >-
                      The plan instances attached to the contract. While the
                      contract is draft or active only its active plan instances
                      are listed; once the contract is completed or canceled,
                      all of them are.
                    type: array
                    items:
                      type: object
                      description: >-
                        A plan put on the contract. It has its own versions, so
                        the prices of one contract can change while the plan
                        stays the same.
                      properties:
                        id:
                          description: >-
                            The unique identifier of the plan instance in our
                            system. Use it to fetch or update the plan instance.
                          type: string
                          format: uuid
                        planId:
                          description: >-
                            The unique identifier of the plan this instance was
                            created from.
                          type: string
                          format: uuid
                        name:
                          description: The name of the plan this instance was created from.
                          type: string
                          example: Plano Essencial
                        status:
                          description: The current status of the plan instance.
                          type: string
                          enum:
                            - active
                            - canceled
                            - completed
                      required:
                        - id
                        - planId
                        - name
                        - status
                      additionalProperties: false
                required:
                  - id
                  - contractNumber
                  - customerId
                  - startDate
                  - endDate
                  - retroactiveDate
                  - invoicingStartDate
                  - status
                  - rateAdjustmentIndex
                  - customFields
                  - invoiceAllocationStrategy
                  - includeNewSubsidiariesOnUsageScope
                  - usageScopes
                  - allocations
                  - billingSchedule
                  - planInstances
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `tax_regime_required`: the tax regime module is on and
            `taxRegimeId` is missing.

            - `contract_must_be_active`: the contract is not active.

            - `contract_legal_entity_mismatch`: no legal entity has the
            `legalEntityId`.

            - `invalid_custom_fields`: the custom fields leave out a required
            custom field of contracts, name a key that no custom field of
            contracts has, or give a custom field a value that it does not take.

            - `invalid_customer_hierarchy`: the usage scope names a customer
            twice, the contract of an individual has another customer in its
            usage scope or sets `includeNewSubsidiariesOnUsageScope`, or the
            usage scope of an organization names a customer other than the
            organization and its subsidiaries that are not archived.

            - `invalid_billing_type`: the allocations name a payment account
            twice, or break the allocation strategy of the contract: `single`
            takes one allocation of 100 percent, and `percent_split` takes a
            percentage on every allocation, with a total of 100.

            - `contract_and_payment_account_must_belong_to_the_same_customer`:
            an allocation names a payment account of a customer other than the
            customer of the contract and its subsidiaries that are not archived.

            - `contract_without_payment_gateway_settings`: every contract must
            have payment conditions, and `paymentGatewaySettings` is missing.

            - `start_date_after_end_date`: the new `endDate` is on or before the
            start date of the contract.

            - `invalid_retroactive_date`: `endDate` changes while the
            retroactive date of the contract comes after the new `endDate` or
            falls in a month more than three years before the current month, or
            the new `endDate` has passed while the contract has a retroactive
            date.

            - `end_date_must_be_after_latest_invoice_date`: the new `endDate` is
            on or before the date of the latest invoice of the contract that is
            not canceled.

            - `invalid_proration_usage_scope`: the new `endDate` moves the end
            of an open billing cycle, which Aira then prices, while the usage
            scope holds more than one customer and a plan of the contract
            charges for a resource whose billing model is proration.

            - `invalid_credit_ledger_entry_for_credit_purchase`: the new
            `endDate` moves the end of an open billing cycle, which Aira then
            prices, while that billing cycle consumes more credits than a credit
            pool of the customer holds and the credit package that tops up that
            pool holds zero credits.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - tax_regime_required
                      - contract_must_be_active
                      - contract_legal_entity_mismatch
                      - invalid_custom_fields
                      - invalid_customer_hierarchy
                      - invalid_billing_type
                      - >-
                        contract_and_payment_account_must_belong_to_the_same_customer
                      - contract_without_payment_gateway_settings
                      - start_date_after_end_date
                      - invalid_retroactive_date
                      - end_date_must_be_after_latest_invoice_date
                      - invalid_proration_usage_scope
                      - invalid_credit_ledger_entry_for_credit_purchase
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''endDate'' is required'
                    code: json_schema_validation_error
                tax_regime_required:
                  value:
                    message: >-
                      tax regime is required for contracts when the tax regime
                      module is enabled
                    code: tax_regime_required
                contract_must_be_active:
                  value:
                    message: contract must be active
                    code: contract_must_be_active
                contract_legal_entity_mismatch:
                  value:
                    message: legal entity {legalEntityId} not found
                    code: contract_legal_entity_mismatch
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
                invalid_customer_hierarchy:
                  value:
                    message: contract usage scope must include at least one customer
                    code: invalid_customer_hierarchy
                invalid_billing_type:
                  value:
                    message: 'unsupported tier pricing type: {value}'
                    code: invalid_billing_type
                contract_and_payment_account_must_belong_to_the_same_customer:
                  value:
                    message: >-
                      contract and payment account must belong to contract owner
                      or its subsidiaries
                    code: >-
                      contract_and_payment_account_must_belong_to_the_same_customer
                contract_without_payment_gateway_settings:
                  value:
                    message: contract without payment gateway settings
                    code: contract_without_payment_gateway_settings
                start_date_after_end_date:
                  value:
                    message: Start date after end date
                    code: start_date_after_end_date
                invalid_retroactive_date:
                  value:
                    message: Retroactive date cannot be before start date
                    code: invalid_retroactive_date
                end_date_must_be_after_latest_invoice_date:
                  value:
                    message: end date must be after latest invoice date
                    code: end_date_must_be_after_latest_invoice_date
                invalid_proration_usage_scope:
                  value:
                    message: >-
                      proration metrics are not supported when billing cycle
                      usage scope has more than one customer
                    code: invalid_proration_usage_scope
                invalid_credit_ledger_entry_for_credit_purchase:
                  value:
                    message: Credit purchase amount must be positive
                    code: invalid_credit_ledger_entry_for_credit_purchase
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `contract_not_found`: no contract has the `id`.

            - `tax_regime_not_found`: no tax regime has the `taxRegimeId`, or
            that tax regime is archived.

            - `payment_account_not_found`: an allocation names a payment account
            that does not exist or that is archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                      - tax_regime_not_found
                      - payment_account_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
                tax_regime_not_found:
                  value:
                    message: >-
                      tax regime version {taxRegimeVersionId} not found
                      (snapshotted on invoice {id})
                    code: tax_regime_not_found
                payment_account_not_found:
                  value:
                    message: payment account not found
                    code: payment_account_not_found
        '422':
          description: >-
            An outside service refuses the data of the request.


            - `incompatible_payment_method_for_provider`: the payment provider
            does not take `paymentGatewaySettings.paymentMethod`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - incompatible_payment_method_for_provider
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                incompatible_payment_method_for_provider:
                  value:
                    message: >-
                      payment method {method} is not supported by gateway
                      {activeProvider}
                    code: incompatible_payment_method_for_provider
        '503':
          description: >-
            A service that the request needs is unavailable.


            - `stale_events_writer`: the new `endDate` moves the end of an open
            billing cycle, which Aira then prices, while a write of events has
            run for longer than any write of events may last.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - stale_events_writer
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                stale_events_writer:
                  value:
                    message: >-
                      an ingest writer transaction has been running longer than
                      the allowed maximum; calculation aborted
                    code: stale_events_writer
  /v1/contracts/{id}/activate:
    post:
      summary: Activate contract
      tags:
        - Contracts
      description: >-
        Activates a draft contract, after which Aira bills it. Aira records the
        invoicing start of the contract and, once the contract has started,
        opens its billing cycle and derives its invoices, with the activation
        invoice when a fixed charge bills in advance. A contract with a
        retroactive date also gets the invoices of its billing cycles since that
        date, which Aira issues as recorded and does not collect, except for the
        latest of them, which stays in review. The integrations that you connect
        receive the activation.


        Requires the role `contracts:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: Unique identifier for the contract.
      x-public-api: true
      x-errors:
        - status: 400
          code: contract_must_have_plan_instances
          when: the contract has no active plan instance
        - status: 400
          code: mixed_billing_frequency_family
          when: >-
            the plan charges of the contract have billing frequencies in both
            months and weeks, or in a unit other than that of the billing
            schedule of the contract
        - status: 400
          code: invalid_custom_fields
          when: >-
            the custom fields of the contract leave out a required custom field
            of contracts, name a key that no custom field of contracts has, or
            give a custom field a value that it does not take
        - status: 400
          code: contract_cannot_be_updated
          when: the contract is completed or canceled
        - status: 400
          code: contract_ended_before_billing_period
          when: >-
            the end date of the contract comes before the start of the billing
            cycle that the activation opens: the one running on the retroactive
            date, or on the day of the activation when the contract has no
            retroactive date
        - status: 400
          code: invalid_proration_usage_scope
          when: >-
            the contract has started, so the activation prices its billing
            cycle, while its usage scope holds more than one customer and a plan
            of the contract charges for a resource whose billing model is
            proration
        - status: 400
          code: invalid_credit_ledger_entry_for_credit_purchase
          when: >-
            the contract has started, so the activation prices its billing
            cycle, while that billing cycle consumes more credits than a credit
            pool of the customer holds and the credit package that tops up that
            pool holds zero credits
        - status: 404
          code: contract_not_found
          when: no contract has the `id`
        - status: 503
          code: stale_events_writer
          when: >-
            the contract has started, so the activation prices its billing
            cycle, while a write of events has run for longer than any write of
            events may last
      x-required-roles: *ref_12
      responses:
        '200':
          description: >-
            An agreement with an individual or an organization that bills plans,
            each through at most one active plan instance. It holds the term,
            the billing schedule, the usage scope, the payment accounts and the
            payment conditions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: Unique identifier for the contract.
                  contractNumber:
                    type: string
                    description: >-
                      The number of the contract, which Aira gives it on
                      creation from the prefix of its customer and the sequence
                      of the contracts of that customer.
                    example: MERCA-CTR-01
                  customerId:
                    type: string
                    format: uuid
                    description: ID of the customer associated with this contract.
                  legalEntityId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      ID of the legal entity associated with this contract.
                      Optional on create; defaults to the default legal entity
                      when absent.
                  legalEntity:
                    type: object
                    description: >-
                      The legal entity, a registered company, that issues the
                      invoices of the contract.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the legal entity in our
                          system.
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                    required:
                      - id
                      - businessName
                      - tradeName
                    additionalProperties: false
                  startDate:
                    type: string
                    format: date
                    description: The first day of the term of the contract.
                  endDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      The last day of the term of the contract, or null when the
                      contract has no end date.
                  retroactiveDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      The date since which the contract was served before it
                      reached Aira, or null. Aira records invoices for the
                      billing cycles since that date but does not collect them,
                      because they were charged elsewhere.
                  invoicingStartDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Read-only. Start date of the first billing cycle Aira
                      invoices for this contract, recorded when it is activated:
                      the cycle containing the retroactive date when one is set,
                      otherwise the cycle running on the activation day, or the
                      contract start when that is still ahead. Null while the
                      contract is a draft.
                  status:
                    type: string
                    enum:
                      - active
                      - canceled
                      - completed
                      - draft
                    description: Current status of the contract.
                  rateAdjustmentIndex:
                    type:
                      - 'null'
                      - string
                    enum:
                      - none
                      - igpm
                      - ipca
                      - other
                      - null
                    description: >-
                      Reference index (e.g. IPCA) used to filter contracts when
                      applying a mass adjustment on contracts.
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  taxRegimeId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      ID of the tax regime applied to invoices generated from
                      this contract. Null when no regime is attached.
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How each billing act of the contract becomes invoices:
                      `single` makes one invoice, `percent_split` makes one per
                      payment account by fixed percentages, and
                      `subsidiary_usage_split` makes one per payment account by
                      the share of the usage of its customer.
                  includeNewSubsidiariesOnUsageScope:
                    type: boolean
                    description: >-
                      Whether future subsidiaries are automatically included in
                      usage scope.
                  autoIssue:
                    type: boolean
                    description: >-
                      When true, invoices produced at billing-cycle close are
                      issued automatically instead of waiting in review.
                      Defaults to false when omitted; omitting it on update
                      leaves the current value unchanged.
                  usageScopes:
                    type: array
                    items:
                      type: object
                      description: >-
                        A customer of the usage scope of the contract, whose
                        usage and license balances the contract bills.
                      properties:
                        customerId:
                          type: string
                          format: uuid
                          description: Customer ID that contributes usage to this contract.
                      required:
                        - customerId
                      additionalProperties: false
                    minItems: 1
                    description: >-
                      The usage scope of the contract: the customers whose usage
                      and license balances it bills, which are the individual
                      alone, or a set of the organization and its subsidiaries.
                    uniqueItems: true
                  allocations:
                    type: array
                    description: >-
                      The contract allocation: the payment accounts that receive
                      the invoices of the contract.
                    items:
                      type: object
                      description: >-
                        A payment account that receives invoices of the
                        contract, with its share of each billing act.
                      properties:
                        paymentAccountId:
                          type: string
                          format: uuid
                          description: ID of the payment account.
                        allocationPercentage:
                          type: string
                          description: >-
                            The percentage of each billing act that the payment
                            account receives, from 0 to 100 with up to 6 decimal
                            places, or null, which only a contract that splits
                            its invoices by subsidiary usage allows.
                          nullable: true
                          example: '50.000000'
                      required:
                        - paymentAccountId
                        - allocationPercentage
                      additionalProperties: false
                    minItems: 1
                  billingSettings:
                    type: object
                    description: >-
                      The contract minimum: the least that the contract bills in
                      a billing cycle, across all its plans. When its plans
                      total less, the closing invoice adds the difference.
                    properties:
                      invoiceMinimumAmount:
                        type: number
                        description: >-
                          The least amount, in cents, that the contract bills in
                          a billing cycle across all its plans.
                        minimum: 0
                      productId:
                        type: string
                        format: uuid
                        description: >-
                          Product ID to use for contract minimum amount line
                          items.
                    required:
                      - invoiceMinimumAmount
                      - productId
                    additionalProperties: false
                    nullable: true
                  billingSchedule:
                    type: object
                    description: >-
                      How the billing cycles of the contract repeat: every month
                      or every week, from the billing day of the contract.
                    properties:
                      periodUnit:
                        type: string
                        enum:
                          - week
                          - month
                        description: >-
                          The calendar the contract closes on: month bills on a
                          day of the month, week on a weekday. Every plan on the
                          contract bills on this family; a plan from the other
                          family belongs on a second contract. A draft can
                          change it only while it has no plans.
                      anchorSource:
                        type: string
                        enum:
                          - based_on_contract_start_date
                          - explicit
                          - first_day_of_month
                        description: >-
                          The label the contract screen shows for the billing
                          day. The engine bills on anchorDay alone, so
                          first_day_of_month only describes a schedule that
                          already opens on day 1.
                      anchorDay:
                        type: integer
                        minimum: 1
                        maximum: 31
                        description: >-
                          The billing day, read per family: day of month (1-31)
                          on the month family, day of week
                          (1=Sunday...7=Saturday) on the week family.
                    required:
                      - periodUnit
                      - anchorSource
                      - anchorDay
                    allOf:
                      - if:
                          type: object
                          properties:
                            anchorSource:
                              enum:
                                - first_day_of_month
                          required:
                            - anchorSource
                        then:
                          type: object
                          properties:
                            anchorDay:
                              enum:
                                - 1
                        errorMessage: >-
                          must pair first_day_of_month with anchorDay 1; use
                          another anchorSource to bill on a different day
                      - if:
                          type: object
                          properties:
                            periodUnit:
                              enum:
                                - week
                          required:
                            - periodUnit
                        then:
                          type: object
                          properties:
                            anchorDay:
                              type: integer
                              maximum: 7
                        errorMessage: >-
                          on the week calendar the billing day is a weekday, 1
                          (Sunday) to 7 (Saturday)
                      - if:
                          type: object
                          properties:
                            anchorSource:
                              enum:
                                - first_day_of_month
                          required:
                            - anchorSource
                        then:
                          type: object
                          properties:
                            periodUnit:
                              enum:
                                - month
                        errorMessage: >-
                          first_day_of_month is a month-calendar label; the week
                          calendar bills on a weekday
                    additionalProperties: false
                  paymentGatewaySettings:
                    type: object
                    description: >-
                      The payment conditions of the contract: how its invoices
                      are paid, with the payment method, and the due date as a
                      number of days after the issue or a fixed day of the
                      month.
                    properties:
                      paymentMethod:
                        type: string
                        enum:
                          - bolepix
                          - bank_slip
                          - pix
                          - credit_card
                          - bank_transfer
                        description: >-
                          Payment method to use for this contract. Must be
                          supported by the active payment provider.
                      dueDateMode:
                        type: string
                        enum:
                          - days_after_issue
                          - fixed_day
                        description: >-
                          How invoice due dates are derived: a day offset from
                          the issue date, or a fixed day of the month.
                        default: days_after_issue
                      dueOffsetDays:
                        type: number
                        minimum: 0
                        nullable: true
                        description: >-
                          Number of days after the issue date until payment is
                          due (0 = due on issue day). Used when dueDateMode is
                          days_after_issue.
                      dueDay:
                        type: number
                        minimum: 1
                        maximum: 31
                        nullable: true
                        description: >-
                          Day of the month invoices are due on, clamped to the
                          last day of shorter months. Used when dueDateMode is
                          fixed_day.
                      dueMonthOffset:
                        type: integer
                        enum:
                          - 0
                          - 1
                        description: >-
                          How many months after the issue month the fixed due
                          day falls on: 0 for the same month, 1 for the next.
                          Used when dueDateMode is fixed_day.
                        default: 0
                      rollDueDateToBusinessDay:
                        type: boolean
                        description: >-
                          Whether a due date landing on a weekend moves to the
                          next business day. Off keeps it on the day it falls.
                        default: true
                    required:
                      - paymentMethod
                      - dueDateMode
                    allOf:
                      - if:
                          properties:
                            dueDateMode:
                              enum:
                                - fixed_day
                          required:
                            - dueDateMode
                        then:
                          properties:
                            dueDay:
                              not:
                                enum:
                                  - null
                          required:
                            - dueDay
                        else:
                          properties:
                            dueOffsetDays:
                              not:
                                enum:
                                  - null
                          required:
                            - dueOffsetDays
                    additionalProperties: false
                    nullable: true
                  planInstances:
                    description: >-
                      The plan instances attached to the contract. While the
                      contract is draft or active only its active plan instances
                      are listed; once the contract is completed or canceled,
                      all of them are.
                    type: array
                    items:
                      type: object
                      description: >-
                        A plan put on the contract. It has its own versions, so
                        the prices of one contract can change while the plan
                        stays the same.
                      properties:
                        id:
                          description: >-
                            The unique identifier of the plan instance in our
                            system. Use it to fetch or update the plan instance.
                          type: string
                          format: uuid
                        planId:
                          description: >-
                            The unique identifier of the plan this instance was
                            created from.
                          type: string
                          format: uuid
                        name:
                          description: The name of the plan this instance was created from.
                          type: string
                          example: Plano Essencial
                        status:
                          description: The current status of the plan instance.
                          type: string
                          enum:
                            - active
                            - canceled
                            - completed
                      required:
                        - id
                        - planId
                        - name
                        - status
                      additionalProperties: false
                required:
                  - id
                  - contractNumber
                  - customerId
                  - startDate
                  - endDate
                  - retroactiveDate
                  - invoicingStartDate
                  - status
                  - rateAdjustmentIndex
                  - customFields
                  - invoiceAllocationStrategy
                  - includeNewSubsidiariesOnUsageScope
                  - usageScopes
                  - allocations
                  - billingSchedule
                  - planInstances
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `contract_must_have_plan_instances`: the contract has no active
            plan instance.

            - `mixed_billing_frequency_family`: the plan charges of the contract
            have billing frequencies in both months and weeks, or in a unit
            other than that of the billing schedule of the contract.

            - `invalid_custom_fields`: the custom fields of the contract leave
            out a required custom field of contracts, name a key that no custom
            field of contracts has, or give a custom field a value that it does
            not take.

            - `contract_cannot_be_updated`: the contract is completed or
            canceled.

            - `contract_ended_before_billing_period`: the end date of the
            contract comes before the start of the billing cycle that the
            activation opens: the one running on the retroactive date, or on the
            day of the activation when the contract has no retroactive date.

            - `invalid_proration_usage_scope`: the contract has started, so the
            activation prices its billing cycle, while its usage scope holds
            more than one customer and a plan of the contract charges for a
            resource whose billing model is proration.

            - `invalid_credit_ledger_entry_for_credit_purchase`: the contract
            has started, so the activation prices its billing cycle, while that
            billing cycle consumes more credits than a credit pool of the
            customer holds and the credit package that tops up that pool holds
            zero credits.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - contract_must_have_plan_instances
                      - mixed_billing_frequency_family
                      - invalid_custom_fields
                      - contract_cannot_be_updated
                      - contract_ended_before_billing_period
                      - invalid_proration_usage_scope
                      - invalid_credit_ledger_entry_for_credit_purchase
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                contract_must_have_plan_instances:
                  value:
                    message: >-
                      contract must have at least one active plan instance to be
                      activated
                    code: contract_must_have_plan_instances
                mixed_billing_frequency_family:
                  value:
                    message: >-
                      the plan charges of the contract have billing frequencies
                      in both months and weeks, or in a unit other than that of
                      the billing schedule of the contract
                    code: mixed_billing_frequency_family
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
                contract_cannot_be_updated:
                  value:
                    message: invalid contract status transition
                    code: contract_cannot_be_updated
                contract_ended_before_billing_period:
                  value:
                    message: contract ended before the current billing period starts
                    code: contract_ended_before_billing_period
                invalid_proration_usage_scope:
                  value:
                    message: >-
                      proration metrics are not supported when billing cycle
                      usage scope has more than one customer
                    code: invalid_proration_usage_scope
                invalid_credit_ledger_entry_for_credit_purchase:
                  value:
                    message: Credit purchase amount must be positive
                    code: invalid_credit_ledger_entry_for_credit_purchase
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `contract_not_found`: no contract has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
        '503':
          description: >-
            A service that the request needs is unavailable.


            - `stale_events_writer`: the contract has started, so the activation
            prices its billing cycle, while a write of events has run for longer
            than any write of events may last.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - stale_events_writer
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                stale_events_writer:
                  value:
                    message: >-
                      an ingest writer transaction has been running longer than
                      the allowed maximum; calculation aborted
                    code: stale_events_writer
  /v1/contracts/{id}/duplicate:
    post:
      summary: Duplicate contract
      tags:
        - Contracts
      description: >-
        Creates a draft contract with the settings of a contract in any status,
        and copies the latest plan instance of each of its plans: from its
        active plan instances when the contract is active, and from all of them
        otherwise. The draft gets a contract number of its own, and leaves out
        the retroactive date when the end date of the contract has passed.


        Requires the role `contracts:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: Unique identifier for the contract.
      x-public-api: true
      x-errors:
        - status: 400
          code: tax_regime_required
          when: the tax regime module is on and the contract has no tax regime
        - status: 400
          code: customer_is_already_archived
          when: >-
            the customer of the contract is archived, or the usage scope of the
            contract names an archived subsidiary of that customer
        - status: 400
          code: invalid_retroactive_date
          when: >-
            the retroactive date of the contract falls in a month more than
            three years before the current month
        - status: 400
          code: contract_and_payment_account_must_belong_to_the_same_customer
          when: >-
            a payment account of the contract belongs to a subsidiary that is
            now archived
        - status: 400
          code: contract_without_payment_gateway_settings
          when: >-
            every contract must have payment conditions, and the contract has
            none
        - status: 400
          code: mixed_billing_frequency_family
          when: >-
            the plan instances that the copy takes have plan charges with
            billing frequencies in both months and weeks, or in a unit other
            than that of the billing schedule of the contract
        - status: 404
          code: contract_not_found
          when: no contract has the `id`
        - status: 404
          code: tax_regime_not_found
          when: the tax regime of the contract is archived
        - status: 404
          code: payment_account_not_found
          when: a payment account of the contract is archived
        - status: 422
          code: incompatible_payment_method_for_provider
          when: >-
            the payment provider does not take the payment method of the
            contract
      x-required-roles: *ref_12
      responses:
        '201':
          description: >-
            An agreement with an individual or an organization that bills plans,
            each through at most one active plan instance. It holds the term,
            the billing schedule, the usage scope, the payment accounts and the
            payment conditions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: Unique identifier for the contract.
                  contractNumber:
                    type: string
                    description: >-
                      The number of the contract, which Aira gives it on
                      creation from the prefix of its customer and the sequence
                      of the contracts of that customer.
                    example: MERCA-CTR-01
                  customerId:
                    type: string
                    format: uuid
                    description: ID of the customer associated with this contract.
                  legalEntityId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      ID of the legal entity associated with this contract.
                      Optional on create; defaults to the default legal entity
                      when absent.
                  legalEntity:
                    type: object
                    description: >-
                      The legal entity, a registered company, that issues the
                      invoices of the contract.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the legal entity in our
                          system.
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                    required:
                      - id
                      - businessName
                      - tradeName
                    additionalProperties: false
                  startDate:
                    type: string
                    format: date
                    description: The first day of the term of the contract.
                  endDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      The last day of the term of the contract, or null when the
                      contract has no end date.
                  retroactiveDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      The date since which the contract was served before it
                      reached Aira, or null. Aira records invoices for the
                      billing cycles since that date but does not collect them,
                      because they were charged elsewhere.
                  invoicingStartDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Read-only. Start date of the first billing cycle Aira
                      invoices for this contract, recorded when it is activated:
                      the cycle containing the retroactive date when one is set,
                      otherwise the cycle running on the activation day, or the
                      contract start when that is still ahead. Null while the
                      contract is a draft.
                  status:
                    type: string
                    enum:
                      - active
                      - canceled
                      - completed
                      - draft
                    description: Current status of the contract.
                  rateAdjustmentIndex:
                    type:
                      - 'null'
                      - string
                    enum:
                      - none
                      - igpm
                      - ipca
                      - other
                      - null
                    description: >-
                      Reference index (e.g. IPCA) used to filter contracts when
                      applying a mass adjustment on contracts.
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  taxRegimeId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      ID of the tax regime applied to invoices generated from
                      this contract. Null when no regime is attached.
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How each billing act of the contract becomes invoices:
                      `single` makes one invoice, `percent_split` makes one per
                      payment account by fixed percentages, and
                      `subsidiary_usage_split` makes one per payment account by
                      the share of the usage of its customer.
                  includeNewSubsidiariesOnUsageScope:
                    type: boolean
                    description: >-
                      Whether future subsidiaries are automatically included in
                      usage scope.
                  autoIssue:
                    type: boolean
                    description: >-
                      When true, invoices produced at billing-cycle close are
                      issued automatically instead of waiting in review.
                      Defaults to false when omitted; omitting it on update
                      leaves the current value unchanged.
                  usageScopes:
                    type: array
                    items:
                      type: object
                      description: >-
                        A customer of the usage scope of the contract, whose
                        usage and license balances the contract bills.
                      properties:
                        customerId:
                          type: string
                          format: uuid
                          description: Customer ID that contributes usage to this contract.
                      required:
                        - customerId
                      additionalProperties: false
                    minItems: 1
                    description: >-
                      The usage scope of the contract: the customers whose usage
                      and license balances it bills, which are the individual
                      alone, or a set of the organization and its subsidiaries.
                    uniqueItems: true
                  allocations:
                    type: array
                    description: >-
                      The contract allocation: the payment accounts that receive
                      the invoices of the contract.
                    items:
                      type: object
                      description: >-
                        A payment account that receives invoices of the
                        contract, with its share of each billing act.
                      properties:
                        paymentAccountId:
                          type: string
                          format: uuid
                          description: ID of the payment account.
                        allocationPercentage:
                          type: string
                          description: >-
                            The percentage of each billing act that the payment
                            account receives, from 0 to 100 with up to 6 decimal
                            places, or null, which only a contract that splits
                            its invoices by subsidiary usage allows.
                          nullable: true
                          example: '50.000000'
                      required:
                        - paymentAccountId
                        - allocationPercentage
                      additionalProperties: false
                    minItems: 1
                  billingSettings:
                    type: object
                    description: >-
                      The contract minimum: the least that the contract bills in
                      a billing cycle, across all its plans. When its plans
                      total less, the closing invoice adds the difference.
                    properties:
                      invoiceMinimumAmount:
                        type: number
                        description: >-
                          The least amount, in cents, that the contract bills in
                          a billing cycle across all its plans.
                        minimum: 0
                      productId:
                        type: string
                        format: uuid
                        description: >-
                          Product ID to use for contract minimum amount line
                          items.
                    required:
                      - invoiceMinimumAmount
                      - productId
                    additionalProperties: false
                    nullable: true
                  billingSchedule:
                    type: object
                    description: >-
                      How the billing cycles of the contract repeat: every month
                      or every week, from the billing day of the contract.
                    properties:
                      periodUnit:
                        type: string
                        enum:
                          - week
                          - month
                        description: >-
                          The calendar the contract closes on: month bills on a
                          day of the month, week on a weekday. Every plan on the
                          contract bills on this family; a plan from the other
                          family belongs on a second contract. A draft can
                          change it only while it has no plans.
                      anchorSource:
                        type: string
                        enum:
                          - based_on_contract_start_date
                          - explicit
                          - first_day_of_month
                        description: >-
                          The label the contract screen shows for the billing
                          day. The engine bills on anchorDay alone, so
                          first_day_of_month only describes a schedule that
                          already opens on day 1.
                      anchorDay:
                        type: integer
                        minimum: 1
                        maximum: 31
                        description: >-
                          The billing day, read per family: day of month (1-31)
                          on the month family, day of week
                          (1=Sunday...7=Saturday) on the week family.
                    required:
                      - periodUnit
                      - anchorSource
                      - anchorDay
                    allOf:
                      - if:
                          type: object
                          properties:
                            anchorSource:
                              enum:
                                - first_day_of_month
                          required:
                            - anchorSource
                        then:
                          type: object
                          properties:
                            anchorDay:
                              enum:
                                - 1
                        errorMessage: >-
                          must pair first_day_of_month with anchorDay 1; use
                          another anchorSource to bill on a different day
                      - if:
                          type: object
                          properties:
                            periodUnit:
                              enum:
                                - week
                          required:
                            - periodUnit
                        then:
                          type: object
                          properties:
                            anchorDay:
                              type: integer
                              maximum: 7
                        errorMessage: >-
                          on the week calendar the billing day is a weekday, 1
                          (Sunday) to 7 (Saturday)
                      - if:
                          type: object
                          properties:
                            anchorSource:
                              enum:
                                - first_day_of_month
                          required:
                            - anchorSource
                        then:
                          type: object
                          properties:
                            periodUnit:
                              enum:
                                - month
                        errorMessage: >-
                          first_day_of_month is a month-calendar label; the week
                          calendar bills on a weekday
                    additionalProperties: false
                  paymentGatewaySettings:
                    type: object
                    description: >-
                      The payment conditions of the contract: how its invoices
                      are paid, with the payment method, and the due date as a
                      number of days after the issue or a fixed day of the
                      month.
                    properties:
                      paymentMethod:
                        type: string
                        enum:
                          - bolepix
                          - bank_slip
                          - pix
                          - credit_card
                          - bank_transfer
                        description: >-
                          Payment method to use for this contract. Must be
                          supported by the active payment provider.
                      dueDateMode:
                        type: string
                        enum:
                          - days_after_issue
                          - fixed_day
                        description: >-
                          How invoice due dates are derived: a day offset from
                          the issue date, or a fixed day of the month.
                        default: days_after_issue
                      dueOffsetDays:
                        type: number
                        minimum: 0
                        nullable: true
                        description: >-
                          Number of days after the issue date until payment is
                          due (0 = due on issue day). Used when dueDateMode is
                          days_after_issue.
                      dueDay:
                        type: number
                        minimum: 1
                        maximum: 31
                        nullable: true
                        description: >-
                          Day of the month invoices are due on, clamped to the
                          last day of shorter months. Used when dueDateMode is
                          fixed_day.
                      dueMonthOffset:
                        type: integer
                        enum:
                          - 0
                          - 1
                        description: >-
                          How many months after the issue month the fixed due
                          day falls on: 0 for the same month, 1 for the next.
                          Used when dueDateMode is fixed_day.
                        default: 0
                      rollDueDateToBusinessDay:
                        type: boolean
                        description: >-
                          Whether a due date landing on a weekend moves to the
                          next business day. Off keeps it on the day it falls.
                        default: true
                    required:
                      - paymentMethod
                      - dueDateMode
                    allOf:
                      - if:
                          properties:
                            dueDateMode:
                              enum:
                                - fixed_day
                          required:
                            - dueDateMode
                        then:
                          properties:
                            dueDay:
                              not:
                                enum:
                                  - null
                          required:
                            - dueDay
                        else:
                          properties:
                            dueOffsetDays:
                              not:
                                enum:
                                  - null
                          required:
                            - dueOffsetDays
                    additionalProperties: false
                    nullable: true
                  planInstances:
                    description: >-
                      The plan instances attached to the contract. While the
                      contract is draft or active only its active plan instances
                      are listed; once the contract is completed or canceled,
                      all of them are.
                    type: array
                    items:
                      type: object
                      description: >-
                        A plan put on the contract. It has its own versions, so
                        the prices of one contract can change while the plan
                        stays the same.
                      properties:
                        id:
                          description: >-
                            The unique identifier of the plan instance in our
                            system. Use it to fetch or update the plan instance.
                          type: string
                          format: uuid
                        planId:
                          description: >-
                            The unique identifier of the plan this instance was
                            created from.
                          type: string
                          format: uuid
                        name:
                          description: The name of the plan this instance was created from.
                          type: string
                          example: Plano Essencial
                        status:
                          description: The current status of the plan instance.
                          type: string
                          enum:
                            - active
                            - canceled
                            - completed
                      required:
                        - id
                        - planId
                        - name
                        - status
                      additionalProperties: false
                required:
                  - id
                  - contractNumber
                  - customerId
                  - startDate
                  - endDate
                  - retroactiveDate
                  - invoicingStartDate
                  - status
                  - rateAdjustmentIndex
                  - customFields
                  - invoiceAllocationStrategy
                  - includeNewSubsidiariesOnUsageScope
                  - usageScopes
                  - allocations
                  - billingSchedule
                  - planInstances
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `tax_regime_required`: the tax regime module is on and the
            contract has no tax regime.

            - `customer_is_already_archived`: the customer of the contract is
            archived, or the usage scope of the contract names an archived
            subsidiary of that customer.

            - `invalid_retroactive_date`: the retroactive date of the contract
            falls in a month more than three years before the current month.

            - `contract_and_payment_account_must_belong_to_the_same_customer`: a
            payment account of the contract belongs to a subsidiary that is now
            archived.

            - `contract_without_payment_gateway_settings`: every contract must
            have payment conditions, and the contract has none.

            - `mixed_billing_frequency_family`: the plan instances that the copy
            takes have plan charges with billing frequencies in both months and
            weeks, or in a unit other than that of the billing schedule of the
            contract.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - tax_regime_required
                      - customer_is_already_archived
                      - invalid_retroactive_date
                      - >-
                        contract_and_payment_account_must_belong_to_the_same_customer
                      - contract_without_payment_gateway_settings
                      - mixed_billing_frequency_family
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                tax_regime_required:
                  value:
                    message: >-
                      tax regime is required for contracts when the tax regime
                      module is enabled
                    code: tax_regime_required
                customer_is_already_archived:
                  value:
                    message: customer is archived
                    code: customer_is_already_archived
                invalid_retroactive_date:
                  value:
                    message: Retroactive date cannot be before start date
                    code: invalid_retroactive_date
                contract_and_payment_account_must_belong_to_the_same_customer:
                  value:
                    message: >-
                      contract and payment account must belong to contract owner
                      or its subsidiaries
                    code: >-
                      contract_and_payment_account_must_belong_to_the_same_customer
                contract_without_payment_gateway_settings:
                  value:
                    message: contract without payment gateway settings
                    code: contract_without_payment_gateway_settings
                mixed_billing_frequency_family:
                  value:
                    message: >-
                      the plan instances that the copy takes have plan charges
                      with billing frequencies in both months and weeks, or in a
                      unit other than that of the billing schedule of the
                      contract
                    code: mixed_billing_frequency_family
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `contract_not_found`: no contract has the `id`.

            - `tax_regime_not_found`: the tax regime of the contract is
            archived.

            - `payment_account_not_found`: a payment account of the contract is
            archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                      - tax_regime_not_found
                      - payment_account_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
                tax_regime_not_found:
                  value:
                    message: >-
                      tax regime version {taxRegimeVersionId} not found
                      (snapshotted on invoice {id})
                    code: tax_regime_not_found
                payment_account_not_found:
                  value:
                    message: payment account not found
                    code: payment_account_not_found
        '422':
          description: >-
            An outside service refuses the data of the request.


            - `incompatible_payment_method_for_provider`: the payment provider
            does not take the payment method of the contract.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - incompatible_payment_method_for_provider
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                incompatible_payment_method_for_provider:
                  value:
                    message: >-
                      payment method {method} is not supported by gateway
                      {activeProvider}
                    code: incompatible_payment_method_for_provider
  /v1/contracts/{id}/recurring-discounts:
    post:
      summary: Create contract recurring discount
      tags:
        - Contracts
      description: >-
        Creates a recurring discount on a contract. From the billing cycle that
        starts on `startDate`, the discount comes off its target on the invoices
        of the next `invoiceCount` billing acts that bill that target, or of all
        of them when `invoiceCount` is null, and Aira applies it at once to the
        invoices of those billing cycles that are not locked.


        Requires the role `contracts:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                planId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    Optional plan to scope the discount to. Required when
                    targetScope is "plan" or "plan_charge".
                planChargeId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    Optional plan charge of the plan in planId to scope the
                    discount to. Required when targetScope is "plan_charge", and
                    left out or null for the other target scopes.
                method:
                  type: string
                  enum:
                    - fixed
                    - percentage
                  description: >-
                    Discount method: "fixed" (amount in cents) or "percentage"
                    (basis points).
                amount:
                  type: number
                  multipleOf: 1
                  minimum: 1
                  description: >-
                    Amount in cents when method is "fixed", or basis points
                    (1-10000, where 10000 = 100%) when method is "percentage".
                description:
                  type: string
                  minLength: 1
                  description: Display text of the discount as it appears on invoices.
                  example: Desconto de fidelidade
                startDate:
                  type: string
                  format: date
                  description: >-
                    Billing-cycle start date the discount starts at. Must match
                    a valid cycle date of the contract.
                invoiceCount:
                  type: number
                  multipleOf: 1
                  minimum: 1
                  maximum: 1200
                  nullable: true
                  description: >-
                    Optional number of invoices the discount applies to, counted
                    from startDate over the open invoices that bill its target;
                    already-issued invoices are frozen and do not consume the
                    count. One unit is one billing act that bills the target,
                    and the split invoices of one act spend one unit together:
                    12 units on a quarterly fee last 12 quarters, and a fixed
                    amount against an annual fee comes off once a year. Null
                    means the discount applies until deactivated.
                distributionMode:
                  type: string
                  enum:
                    - proportional
                    - full
                  default: proportional
                  description: >-
                    For split invoices: "proportional" divides a fixed discount
                    across invoices; "full" applies it in full to each.
                targetScope:
                  type: string
                  enum:
                    - invoice
                    - plan
                    - plan_charge
                    - contract_minimum_amount
                  description: >-
                    Where the discount applies: "invoice", "plan", "plan_charge"
                    (one plan charge of a plan), or "contract_minimum_amount".
                customFields:
                  type: object
                  description: >-
                    Custom fields that can be associated with the entity. The
                    fields must be previously created in the system before they
                    can be used.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
              required:
                - method
                - amount
                - description
                - startDate
                - targetScope
              additionalProperties: false
              allOf:
                - if:
                    properties:
                      method:
                        enum:
                          - percentage
                  then:
                    properties:
                      amount:
                        type: number
                        maximum: 10000
        required: true
        description: The recurring discount to create on the contract.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: Unique identifier for the contract.
      x-public-api: true
      x-errors:
        - status: 400
          code: contract_must_be_active_or_draft
          when: the contract is completed or canceled
        - status: 400
          code: invalid_contract_recurring_discount_target
          when: >-
            `targetScope`, `planId` and `planChargeId` do not name a target that
            the contract offers: the invoice, the plan of an active plan
            instance, a plan charge of that plan, or the contract minimum when
            it is above zero
        - status: 400
          code: invalid_contract_recurring_discount_cycle_date
          when: >-
            `startDate` is not the start date of a billing cycle of the contract
            that starts from the first day of last month on, and on or before
            the end date of the contract
        - status: 400
          code: invalid_custom_fields
          when: >-
            the custom fields leave out a required custom field of invoice
            discounts, name a key that no custom field of invoice discounts has,
            or give a custom field a value that it does not take
        - status: 404
          code: contract_not_found
          when: no contract has the `id`
      x-required-roles: *ref_12
      responses:
        '201':
          description: >-
            A discount that a contract applies from a chosen billing cycle, for
            a number of billings or with no end. It is a fixed amount or a
            percentage on the invoice, a plan, one plan charge or the contract
            minimum.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the recurring discount in our
                      system.
                  planId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the plan that the discount
                      applies to, for the plan and plan_charge target scopes.
                      Null for the invoice and contract_minimum_amount target
                      scopes.
                  planChargeId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the plan charge that the discount
                      applies to, for the plan_charge target scope. Null for the
                      other target scopes.
                  targetScope:
                    type: string
                    enum:
                      - invoice
                      - plan
                      - plan_charge
                      - contract_minimum_amount
                    description: >-
                      What the discount applies to on each invoice: invoice (the
                      whole invoice), plan (the line items of the plan),
                      plan_charge (the line item of one plan charge of the
                      plan), or contract_minimum_amount (the line item that the
                      contract minimum adds).
                  method:
                    type: string
                    enum:
                      - fixed
                      - percentage
                    description: >-
                      How amount reads: fixed takes an amount of money off the
                      target, and percentage takes a percentage of the target
                      off it.
                  amount:
                    type: number
                    multipleOf: 1
                    minimum: 1
                    description: >-
                      The value of the discount, as a positive integer: cents
                      when method is fixed, and basis points when method is
                      percentage, where 1 basis point is 0.01% and 10000 is
                      100%.
                  description:
                    type: string
                    minLength: 1
                    description: The text of the discount as it appears on invoices.
                    example: Desconto de fidelidade
                  startDate:
                    type: string
                    format: date
                    description: >-
                      The start date of the billing cycle from which the
                      discount applies.
                  invoiceCount:
                    type: number
                    multipleOf: 1
                    minimum: 1
                    nullable: true
                    description: >-
                      How many billing acts that bill the target the discount
                      applies to, counted from startDate over the open invoices,
                      because an issued invoice keeps its discounts and spends
                      no count. The invoices that one billing act splits among
                      payment accounts spend one count together, so 12 counts on
                      a quarterly fee last 12 quarters. Null means that the
                      discount applies until it is deactivated.
                  distributionMode:
                    type: string
                    enum:
                      - proportional
                      - full
                    description: >-
                      How a fixed discount reaches the invoices that one billing
                      act splits among payment accounts: full takes the whole
                      amount off each invoice, and proportional splits the
                      amount among them in proportion to their totals. A
                      percentage discount always applies to each invoice.
                  isActive:
                    type: boolean
                    description: >-
                      Whether the discount applies to new billing cycles. A
                      deactivated discount stays on the contract for history.
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                required:
                  - id
                  - planId
                  - planChargeId
                  - targetScope
                  - method
                  - amount
                  - description
                  - startDate
                  - invoiceCount
                  - distributionMode
                  - isActive
                  - customFields
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `contract_must_be_active_or_draft`: the contract is completed or
            canceled.

            - `invalid_contract_recurring_discount_target`: `targetScope`,
            `planId` and `planChargeId` do not name a target that the contract
            offers: the invoice, the plan of an active plan instance, a plan
            charge of that plan, or the contract minimum when it is above zero.

            - `invalid_contract_recurring_discount_cycle_date`: `startDate` is
            not the start date of a billing cycle of the contract that starts
            from the first day of last month on, and on or before the end date
            of the contract.

            - `invalid_custom_fields`: the custom fields leave out a required
            custom field of invoice discounts, name a key that no custom field
            of invoice discounts has, or give a custom field a value that it
            does not take.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - contract_must_be_active_or_draft
                      - invalid_contract_recurring_discount_target
                      - invalid_contract_recurring_discount_cycle_date
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''method'' is required'
                    code: json_schema_validation_error
                contract_must_be_active_or_draft:
                  value:
                    message: contract must be active or draft
                    code: contract_must_be_active_or_draft
                invalid_contract_recurring_discount_target:
                  value:
                    message: target is not valid for this contract
                    code: invalid_contract_recurring_discount_target
                invalid_contract_recurring_discount_cycle_date:
                  value:
                    message: >-
                      start date is not a valid billing cycle date for this
                      contract
                    code: invalid_contract_recurring_discount_cycle_date
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `contract_not_found`: no contract has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
    get:
      summary: List contract recurring discounts
      tags:
        - Contracts
      description: >-
        Lists the recurring discounts of a contract, the active and the inactive
        ones.


        Requires the role `contracts:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: Unique identifier for the contract.
      x-public-api: true
      x-errors:
        - status: 404
          code: contract_not_found
          when: no contract has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_13
      responses:
        '200':
          description: The recurring discounts of the contract.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A discount that a contract applies from a chosen billing
                        cycle, for a number of billings or with no end. It is a
                        fixed amount or a percentage on the invoice, a plan, one
                        plan charge or the contract minimum.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the recurring discount in
                            our system.
                        planId:
                          type: string
                          format: uuid
                          nullable: true
                          description: >-
                            The unique identifier of the plan that the discount
                            applies to, for the plan and plan_charge target
                            scopes. Null for the invoice and
                            contract_minimum_amount target scopes.
                        planChargeId:
                          type: string
                          format: uuid
                          nullable: true
                          description: >-
                            The unique identifier of the plan charge that the
                            discount applies to, for the plan_charge target
                            scope. Null for the other target scopes.
                        targetScope:
                          type: string
                          enum:
                            - invoice
                            - plan
                            - plan_charge
                            - contract_minimum_amount
                          description: >-
                            What the discount applies to on each invoice:
                            invoice (the whole invoice), plan (the line items of
                            the plan), plan_charge (the line item of one plan
                            charge of the plan), or contract_minimum_amount (the
                            line item that the contract minimum adds).
                        method:
                          type: string
                          enum:
                            - fixed
                            - percentage
                          description: >-
                            How amount reads: fixed takes an amount of money off
                            the target, and percentage takes a percentage of the
                            target off it.
                        amount:
                          type: number
                          multipleOf: 1
                          minimum: 1
                          description: >-
                            The value of the discount, as a positive integer:
                            cents when method is fixed, and basis points when
                            method is percentage, where 1 basis point is 0.01%
                            and 10000 is 100%.
                        description:
                          type: string
                          minLength: 1
                          description: The text of the discount as it appears on invoices.
                          example: Desconto de fidelidade
                        startDate:
                          type: string
                          format: date
                          description: >-
                            The start date of the billing cycle from which the
                            discount applies.
                        invoiceCount:
                          type: number
                          multipleOf: 1
                          minimum: 1
                          nullable: true
                          description: >-
                            How many billing acts that bill the target the
                            discount applies to, counted from startDate over the
                            open invoices, because an issued invoice keeps its
                            discounts and spends no count. The invoices that one
                            billing act splits among payment accounts spend one
                            count together, so 12 counts on a quarterly fee last
                            12 quarters. Null means that the discount applies
                            until it is deactivated.
                        distributionMode:
                          type: string
                          enum:
                            - proportional
                            - full
                          description: >-
                            How a fixed discount reaches the invoices that one
                            billing act splits among payment accounts: full
                            takes the whole amount off each invoice, and
                            proportional splits the amount among them in
                            proportion to their totals. A percentage discount
                            always applies to each invoice.
                        isActive:
                          type: boolean
                          description: >-
                            Whether the discount applies to new billing cycles.
                            A deactivated discount stays on the contract for
                            history.
                        customFields:
                          type: object
                          description: >-
                            Custom fields that can be associated with the
                            entity. The fields must be previously created in the
                            system before they can be used.
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          default: {}
                          example:
                            customField1: value1
                            customField2:
                              - value2
                              - value3
                      required:
                        - id
                        - planId
                        - planChargeId
                        - targetScope
                        - method
                        - amount
                        - description
                        - startDate
                        - invoiceCount
                        - distributionMode
                        - isActive
                        - customFields
                      additionalProperties: false
                    description: A list of items.
                required:
                  - items
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `contract_not_found`: no contract has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/contracts/{id}/recurring-discounts/{contractRecurringDiscountId}/deactivate:
    post:
      summary: Deactivate contract recurring discount
      tags:
        - Contracts
      description: >-
        Deactivates a recurring discount of a contract. Aira takes the discount
        off the invoices of the contract that are not locked and recalculates
        their totals, and the locked invoices keep it.


        Requires the role `contracts:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: Unique identifier for the contract.
        - schema:
            type: string
            format: uuid
          in: path
          name: contractRecurringDiscountId
          required: true
          description: The unique identifier of the recurring discount in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: contract_recurring_discount_already_inactive
          when: the recurring discount is already inactive
        - status: 404
          code: contract_not_found
          when: no contract has the `id`
        - status: 404
          code: contract_recurring_discount_not_found
          when: >-
            no recurring discount of the contract has the
            `contractRecurringDiscountId`
      x-required-roles: *ref_12
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `contract_recurring_discount_already_inactive`: the recurring
            discount is already inactive.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - contract_recurring_discount_already_inactive
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                contract_recurring_discount_already_inactive:
                  value:
                    message: contract recurring discount is already inactive
                    code: contract_recurring_discount_already_inactive
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `contract_not_found`: no contract has the `id`.

            - `contract_recurring_discount_not_found`: no recurring discount of
            the contract has the `contractRecurringDiscountId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                      - contract_recurring_discount_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
                contract_recurring_discount_not_found:
                  value:
                    message: contract recurring discount not found
                    code: contract_recurring_discount_not_found
  /v1/contracts/{id}/recurring-discounts/{contractRecurringDiscountId}:
    patch:
      summary: Update contract recurring discount
      tags:
        - Contracts
      description: >-
        Replaces the custom fields of an active recurring discount of a
        contract. The invoices that are not locked carry the new values on the
        discounts that the recurring discount gives them.


        Requires the role `contracts:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                customFields:
                  type: object
                  description: >-
                    Custom fields that can be associated with the entity. The
                    fields must be previously created in the system before they
                    can be used.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
              required:
                - customFields
              additionalProperties: false
        required: true
        description: The custom fields that replace those of the recurring discount.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: Unique identifier for the contract.
        - schema:
            type: string
            format: uuid
          in: path
          name: contractRecurringDiscountId
          required: true
          description: The unique identifier of the recurring discount in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: contract_recurring_discount_already_inactive
          when: the recurring discount is already inactive
        - status: 400
          code: invalid_custom_fields
          when: >-
            the custom fields leave out a required custom field of invoice
            discounts, name a key that no custom field of invoice discounts has,
            or give a custom field a value that it does not take
        - status: 404
          code: contract_not_found
          when: no contract has the `id`
        - status: 404
          code: contract_recurring_discount_not_found
          when: >-
            no recurring discount of the contract has the
            `contractRecurringDiscountId`
      x-required-roles: *ref_12
      responses:
        '200':
          description: >-
            A discount that a contract applies from a chosen billing cycle, for
            a number of billings or with no end. It is a fixed amount or a
            percentage on the invoice, a plan, one plan charge or the contract
            minimum.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the recurring discount in our
                      system.
                  planId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the plan that the discount
                      applies to, for the plan and plan_charge target scopes.
                      Null for the invoice and contract_minimum_amount target
                      scopes.
                  planChargeId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      The unique identifier of the plan charge that the discount
                      applies to, for the plan_charge target scope. Null for the
                      other target scopes.
                  targetScope:
                    type: string
                    enum:
                      - invoice
                      - plan
                      - plan_charge
                      - contract_minimum_amount
                    description: >-
                      What the discount applies to on each invoice: invoice (the
                      whole invoice), plan (the line items of the plan),
                      plan_charge (the line item of one plan charge of the
                      plan), or contract_minimum_amount (the line item that the
                      contract minimum adds).
                  method:
                    type: string
                    enum:
                      - fixed
                      - percentage
                    description: >-
                      How amount reads: fixed takes an amount of money off the
                      target, and percentage takes a percentage of the target
                      off it.
                  amount:
                    type: number
                    multipleOf: 1
                    minimum: 1
                    description: >-
                      The value of the discount, as a positive integer: cents
                      when method is fixed, and basis points when method is
                      percentage, where 1 basis point is 0.01% and 10000 is
                      100%.
                  description:
                    type: string
                    minLength: 1
                    description: The text of the discount as it appears on invoices.
                    example: Desconto de fidelidade
                  startDate:
                    type: string
                    format: date
                    description: >-
                      The start date of the billing cycle from which the
                      discount applies.
                  invoiceCount:
                    type: number
                    multipleOf: 1
                    minimum: 1
                    nullable: true
                    description: >-
                      How many billing acts that bill the target the discount
                      applies to, counted from startDate over the open invoices,
                      because an issued invoice keeps its discounts and spends
                      no count. The invoices that one billing act splits among
                      payment accounts spend one count together, so 12 counts on
                      a quarterly fee last 12 quarters. Null means that the
                      discount applies until it is deactivated.
                  distributionMode:
                    type: string
                    enum:
                      - proportional
                      - full
                    description: >-
                      How a fixed discount reaches the invoices that one billing
                      act splits among payment accounts: full takes the whole
                      amount off each invoice, and proportional splits the
                      amount among them in proportion to their totals. A
                      percentage discount always applies to each invoice.
                  isActive:
                    type: boolean
                    description: >-
                      Whether the discount applies to new billing cycles. A
                      deactivated discount stays on the contract for history.
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                required:
                  - id
                  - planId
                  - planChargeId
                  - targetScope
                  - method
                  - amount
                  - description
                  - startDate
                  - invoiceCount
                  - distributionMode
                  - isActive
                  - customFields
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `contract_recurring_discount_already_inactive`: the recurring
            discount is already inactive.

            - `invalid_custom_fields`: the custom fields leave out a required
            custom field of invoice discounts, name a key that no custom field
            of invoice discounts has, or give a custom field a value that it
            does not take.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - contract_recurring_discount_already_inactive
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''customFields'' is required'
                    code: json_schema_validation_error
                contract_recurring_discount_already_inactive:
                  value:
                    message: contract recurring discount is already inactive
                    code: contract_recurring_discount_already_inactive
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `contract_not_found`: no contract has the `id`.

            - `contract_recurring_discount_not_found`: no recurring discount of
            the contract has the `contractRecurringDiscountId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                      - contract_recurring_discount_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
                contract_recurring_discount_not_found:
                  value:
                    message: contract recurring discount not found
                    code: contract_recurring_discount_not_found
  /v1/contracts/{id}:
    get:
      summary: Fetch contract
      tags:
        - Contracts
      description: |-
        Fetches a contract with the plan instances attached to it.

        Requires the role `contracts:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: Unique identifier for the contract.
      x-public-api: true
      x-errors:
        - status: 404
          code: contract_not_found
          when: no contract has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_13
      responses:
        '200':
          description: >-
            An agreement with an individual or an organization that bills plans,
            each through at most one active plan instance. It holds the term,
            the billing schedule, the usage scope, the payment accounts and the
            payment conditions.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: Unique identifier for the contract.
                  contractNumber:
                    type: string
                    description: >-
                      The number of the contract, which Aira gives it on
                      creation from the prefix of its customer and the sequence
                      of the contracts of that customer.
                    example: MERCA-CTR-01
                  customerId:
                    type: string
                    format: uuid
                    description: ID of the customer associated with this contract.
                  legalEntityId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      ID of the legal entity associated with this contract.
                      Optional on create; defaults to the default legal entity
                      when absent.
                  legalEntity:
                    type: object
                    description: >-
                      The legal entity, a registered company, that issues the
                      invoices of the contract.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the legal entity in our
                          system.
                      businessName:
                        type: string
                        description: >-
                          Registered business name (razão social) of the legal
                          entity.
                        example: Padaria Central Ltda
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          Trade name (nome fantasia) of the legal entity. Null
                          when absent.
                        example: Padaria Central
                    required:
                      - id
                      - businessName
                      - tradeName
                    additionalProperties: false
                  startDate:
                    type: string
                    format: date
                    description: The first day of the term of the contract.
                  endDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      The last day of the term of the contract, or null when the
                      contract has no end date.
                  retroactiveDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      The date since which the contract was served before it
                      reached Aira, or null. Aira records invoices for the
                      billing cycles since that date but does not collect them,
                      because they were charged elsewhere.
                  invoicingStartDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Read-only. Start date of the first billing cycle Aira
                      invoices for this contract, recorded when it is activated:
                      the cycle containing the retroactive date when one is set,
                      otherwise the cycle running on the activation day, or the
                      contract start when that is still ahead. Null while the
                      contract is a draft.
                  status:
                    type: string
                    enum:
                      - active
                      - canceled
                      - completed
                      - draft
                    description: Current status of the contract.
                  rateAdjustmentIndex:
                    type:
                      - 'null'
                      - string
                    enum:
                      - none
                      - igpm
                      - ipca
                      - other
                      - null
                    description: >-
                      Reference index (e.g. IPCA) used to filter contracts when
                      applying a mass adjustment on contracts.
                  customFields:
                    type: object
                    description: >-
                      Custom fields that can be associated with the entity. The
                      fields must be previously created in the system before
                      they can be used.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  taxRegimeId:
                    type: string
                    format: uuid
                    nullable: true
                    description: >-
                      ID of the tax regime applied to invoices generated from
                      this contract. Null when no regime is attached.
                  invoiceAllocationStrategy:
                    type: string
                    enum:
                      - single
                      - percent_split
                      - subsidiary_usage_split
                    description: >-
                      How each billing act of the contract becomes invoices:
                      `single` makes one invoice, `percent_split` makes one per
                      payment account by fixed percentages, and
                      `subsidiary_usage_split` makes one per payment account by
                      the share of the usage of its customer.
                  includeNewSubsidiariesOnUsageScope:
                    type: boolean
                    description: >-
                      Whether future subsidiaries are automatically included in
                      usage scope.
                  autoIssue:
                    type: boolean
                    description: >-
                      When true, invoices produced at billing-cycle close are
                      issued automatically instead of waiting in review.
                      Defaults to false when omitted; omitting it on update
                      leaves the current value unchanged.
                  usageScopes:
                    type: array
                    items:
                      type: object
                      description: >-
                        A customer of the usage scope of the contract, whose
                        usage and license balances the contract bills.
                      properties:
                        customerId:
                          type: string
                          format: uuid
                          description: Customer ID that contributes usage to this contract.
                      required:
                        - customerId
                      additionalProperties: false
                    minItems: 1
                    description: >-
                      The usage scope of the contract: the customers whose usage
                      and license balances it bills, which are the individual
                      alone, or a set of the organization and its subsidiaries.
                    uniqueItems: true
                  allocations:
                    type: array
                    description: >-
                      The contract allocation: the payment accounts that receive
                      the invoices of the contract.
                    items:
                      type: object
                      description: >-
                        A payment account that receives invoices of the
                        contract, with its share of each billing act.
                      properties:
                        paymentAccountId:
                          type: string
                          format: uuid
                          description: ID of the payment account.
                        allocationPercentage:
                          type: string
                          description: >-
                            The percentage of each billing act that the payment
                            account receives, from 0 to 100 with up to 6 decimal
                            places, or null, which only a contract that splits
                            its invoices by subsidiary usage allows.
                          nullable: true
                          example: '50.000000'
                      required:
                        - paymentAccountId
                        - allocationPercentage
                      additionalProperties: false
                    minItems: 1
                  billingSettings:
                    type: object
                    description: >-
                      The contract minimum: the least that the contract bills in
                      a billing cycle, across all its plans. When its plans
                      total less, the closing invoice adds the difference.
                    properties:
                      invoiceMinimumAmount:
                        type: number
                        description: >-
                          The least amount, in cents, that the contract bills in
                          a billing cycle across all its plans.
                        minimum: 0
                      productId:
                        type: string
                        format: uuid
                        description: >-
                          Product ID to use for contract minimum amount line
                          items.
                    required:
                      - invoiceMinimumAmount
                      - productId
                    additionalProperties: false
                    nullable: true
                  billingSchedule:
                    type: object
                    description: >-
                      How the billing cycles of the contract repeat: every month
                      or every week, from the billing day of the contract.
                    properties:
                      periodUnit:
                        type: string
                        enum:
                          - week
                          - month
                        description: >-
                          The calendar the contract closes on: month bills on a
                          day of the month, week on a weekday. Every plan on the
                          contract bills on this family; a plan from the other
                          family belongs on a second contract. A draft can
                          change it only while it has no plans.
                      anchorSource:
                        type: string
                        enum:
                          - based_on_contract_start_date
                          - explicit
                          - first_day_of_month
                        description: >-
                          The label the contract screen shows for the billing
                          day. The engine bills on anchorDay alone, so
                          first_day_of_month only describes a schedule that
                          already opens on day 1.
                      anchorDay:
                        type: integer
                        minimum: 1
                        maximum: 31
                        description: >-
                          The billing day, read per family: day of month (1-31)
                          on the month family, day of week
                          (1=Sunday...7=Saturday) on the week family.
                    required:
                      - periodUnit
                      - anchorSource
                      - anchorDay
                    allOf:
                      - if:
                          type: object
                          properties:
                            anchorSource:
                              enum:
                                - first_day_of_month
                          required:
                            - anchorSource
                        then:
                          type: object
                          properties:
                            anchorDay:
                              enum:
                                - 1
                        errorMessage: >-
                          must pair first_day_of_month with anchorDay 1; use
                          another anchorSource to bill on a different day
                      - if:
                          type: object
                          properties:
                            periodUnit:
                              enum:
                                - week
                          required:
                            - periodUnit
                        then:
                          type: object
                          properties:
                            anchorDay:
                              type: integer
                              maximum: 7
                        errorMessage: >-
                          on the week calendar the billing day is a weekday, 1
                          (Sunday) to 7 (Saturday)
                      - if:
                          type: object
                          properties:
                            anchorSource:
                              enum:
                                - first_day_of_month
                          required:
                            - anchorSource
                        then:
                          type: object
                          properties:
                            periodUnit:
                              enum:
                                - month
                        errorMessage: >-
                          first_day_of_month is a month-calendar label; the week
                          calendar bills on a weekday
                    additionalProperties: false
                  paymentGatewaySettings:
                    type: object
                    description: >-
                      The payment conditions of the contract: how its invoices
                      are paid, with the payment method, and the due date as a
                      number of days after the issue or a fixed day of the
                      month.
                    properties:
                      paymentMethod:
                        type: string
                        enum:
                          - bolepix
                          - bank_slip
                          - pix
                          - credit_card
                          - bank_transfer
                        description: >-
                          Payment method to use for this contract. Must be
                          supported by the active payment provider.
                      dueDateMode:
                        type: string
                        enum:
                          - days_after_issue
                          - fixed_day
                        description: >-
                          How invoice due dates are derived: a day offset from
                          the issue date, or a fixed day of the month.
                        default: days_after_issue
                      dueOffsetDays:
                        type: number
                        minimum: 0
                        nullable: true
                        description: >-
                          Number of days after the issue date until payment is
                          due (0 = due on issue day). Used when dueDateMode is
                          days_after_issue.
                      dueDay:
                        type: number
                        minimum: 1
                        maximum: 31
                        nullable: true
                        description: >-
                          Day of the month invoices are due on, clamped to the
                          last day of shorter months. Used when dueDateMode is
                          fixed_day.
                      dueMonthOffset:
                        type: integer
                        enum:
                          - 0
                          - 1
                        description: >-
                          How many months after the issue month the fixed due
                          day falls on: 0 for the same month, 1 for the next.
                          Used when dueDateMode is fixed_day.
                        default: 0
                      rollDueDateToBusinessDay:
                        type: boolean
                        description: >-
                          Whether a due date landing on a weekend moves to the
                          next business day. Off keeps it on the day it falls.
                        default: true
                    required:
                      - paymentMethod
                      - dueDateMode
                    allOf:
                      - if:
                          properties:
                            dueDateMode:
                              enum:
                                - fixed_day
                          required:
                            - dueDateMode
                        then:
                          properties:
                            dueDay:
                              not:
                                enum:
                                  - null
                          required:
                            - dueDay
                        else:
                          properties:
                            dueOffsetDays:
                              not:
                                enum:
                                  - null
                          required:
                            - dueOffsetDays
                    additionalProperties: false
                    nullable: true
                  planInstances:
                    description: >-
                      The plan instances attached to the contract. While the
                      contract is draft or active only its active plan instances
                      are listed; once the contract is completed or canceled,
                      all of them are.
                    type: array
                    items:
                      type: object
                      description: >-
                        A plan put on the contract. It has its own versions, so
                        the prices of one contract can change while the plan
                        stays the same.
                      properties:
                        id:
                          description: >-
                            The unique identifier of the plan instance in our
                            system. Use it to fetch or update the plan instance.
                          type: string
                          format: uuid
                        planId:
                          description: >-
                            The unique identifier of the plan this instance was
                            created from.
                          type: string
                          format: uuid
                        name:
                          description: The name of the plan this instance was created from.
                          type: string
                          example: Plano Essencial
                        status:
                          description: The current status of the plan instance.
                          type: string
                          enum:
                            - active
                            - canceled
                            - completed
                      required:
                        - id
                        - planId
                        - name
                        - status
                      additionalProperties: false
                required:
                  - id
                  - contractNumber
                  - customerId
                  - startDate
                  - endDate
                  - retroactiveDate
                  - invoicingStartDate
                  - status
                  - rateAdjustmentIndex
                  - customFields
                  - invoiceAllocationStrategy
                  - includeNewSubsidiariesOnUsageScope
                  - usageScopes
                  - allocations
                  - billingSchedule
                  - planInstances
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role contracts:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `contract_not_found`: no contract has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/plan-instances/:
    post:
      summary: Create plan instance
      tags:
        - Plan Instances
      description: >-
        Puts a plan on a contract: creates an active plan instance whose first
        plan instance version has the plan charges of the active plan version of
        the plan, so the contract bills those plan charges.


        Requires the role `plan_instances:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                planId:
                  type: string
                  format: uuid
                  description: The unique identifier of the plan to instantiate.
                contractId:
                  type: string
                  format: uuid
                  description: >-
                    The unique identifier of the contract to attach the plan
                    instance to.
                startDate:
                  type: string
                  format: date-time
                  description: >-
                    Optional date the plan instance starts being billed. Must
                    fall within the contract period; when omitted, the instance
                    follows the contract's start.
                endDate:
                  type: string
                  format: date-time
                  description: >-
                    Optional date the plan instance stops being billed. Must
                    fall within the contract period; when omitted, the instance
                    follows the contract's end.
              required:
                - planId
                - contractId
              additionalProperties: false
        required: true
        description: >-
          Schema for creating a plan instance on a contract using the plan's
          current active version settings. A contract can have at most one
          active instance of a given plan.
      x-public-api: true
      x-errors:
        - status: 400
          code: contract_cannot_be_updated
          when: the contract is completed or canceled
        - status: 400
          code: invalid_date
          when: >-
            `startDate` is before the start of the contract or after its end, or
            `endDate` is after the end of the contract or before today
        - status: 400
          code: start_date_after_end_date
          when: '`endDate` is before `startDate`'
        - status: 400
          code: plan_instance_already_exists
          when: the contract already has an active plan instance of the plan
        - status: 400
          code: invalid_proration_usage_scope
          when: >-
            the plan has a usage-based charge on a resource with the billing
            model `proration`, and the usage scope of the contract has more than
            one customer
        - status: 400
          code: invalid_license_proration_allocation
          when: >-
            the plan has a license-based charge with the billing model
            `proration`, and the contract splits its invoices by the share of
            the usage of each customer
        - status: 400
          code: mixed_billing_frequency_family
          when: >-
            the billing frequencies of the plan charges of the plan are in weeks
            and the billing schedule of the contract repeats every month, or the
            reverse
        - status: 404
          code: contract_not_found
          when: no contract has the `contractId`
        - status: 404
          code: plan_not_found
          when: no plan has the `planId`
      x-required-roles: &ref_14
        - plan_instances:write
      responses:
        '201':
          description: >-
            A plan instance: a plan put on one contract. It has its own
            versions, so the prices of one contract can change while the plan
            stays the same.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the plan instance in our system.
                  contractId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the contract the plan instance
                      belongs to.
                  planId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the plan this instance was
                      created from.
                  activePlanInstanceVersionId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the plan instance version
                      currently used for billing.
                  activePlanVersionId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the plan version the active plan
                      instance version derives from.
                  activePlanInstanceVersionReason:
                    type: string
                    enum:
                      - created_from_plan_version
                      - duplicated_from_contract
                      - manual_override
                      - readjustment
                      - rollback
                    description: >-
                      Why the active plan instance version exists:
                      created_from_plan_version (instantiated from the plan's
                      version), duplicated_from_contract (copied when the
                      contract was duplicated), manual_override (pricing
                      overridden manually or through the API), readjustment (a
                      percentage rate adjustment was applied), or rollback
                      (rolled back to a previous version).
                  status:
                    type: string
                    enum:
                      - active
                      - canceled
                      - completed
                    description: >-
                      Current status of the plan instance: active (billed on the
                      contract's cycles), canceled (interrupted before its end;
                      no longer billed), or completed (ran through its end).
                  plan:
                    type: object
                    description: >-
                      Base properties of the plan this instance was created
                      from.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the plan in our system.
                      name:
                        type: string
                        minLength: 1
                        description: The name of the plan.
                        example: Plano Essencial
                      description:
                        description: The description of the plan, or null when it has none.
                        type:
                          - 'null'
                          - string
                        example: Assinatura mensal com entrega diária de pães.
                      productId:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the product that the plan
                          belongs to.
                    required:
                      - id
                      - name
                      - description
                      - productId
                    additionalProperties: false
                  activePlanInstanceVersion:
                    type: object
                    description: >-
                      The plan instance version currently used for billing,
                      including its plan charges, without its custom field
                      values.
                    properties:
                      id:
                        description: >-
                          The unique identifier of the plan instance version in
                          our system.
                        type: string
                        format: uuid
                      planInstanceId:
                        description: >-
                          The unique identifier of the plan instance that the
                          version belongs to.
                        type: string
                        format: uuid
                      planVersionId:
                        description: >-
                          The unique identifier of the plan version that the
                          version comes from.
                        type: string
                        format: uuid
                      versionNumber:
                        description: >-
                          The number of the version in its plan instance, from
                          1, one more for each new version.
                        type: integer
                        minimum: 1
                      isActive:
                        description: >-
                          Whether billing uses this version. A plan instance has
                          one active version.
                        type: boolean
                      planInstanceVersionReason:
                        description: >-
                          Why the version exists: created_from_plan_version (it
                          comes from a plan version of the plan),
                          duplicated_from_contract (a copy of a plan instance of
                          another contract), manual_override (an update of the
                          charges of the plan instance), readjustment (a rate
                          adjustment) or rollback (a restore of an earlier
                          version).
                        type: string
                        enum:
                          - created_from_plan_version
                          - duplicated_from_contract
                          - manual_override
                          - readjustment
                          - rollback
                      metadata:
                        anyOf:
                          - type: object
                            description: >-
                              The details of a version that comes from a plan
                              version of the plan.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - created_from_plan_version
                                description: >-
                                  The reason of the version:
                                  created_from_plan_version.
                              sourcePlanVersionId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan version that
                                  the version comes from.
                            required:
                              - reason
                              - sourcePlanVersionId
                            additionalProperties: false
                          - type: object
                            description: >-
                              The details of a version that copies a plan
                              instance of another contract, from a duplication
                              of that contract.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - duplicated_from_contract
                                description: >-
                                  The reason of the version:
                                  duplicated_from_contract.
                              sourceContractId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the contract that the
                                  duplication copied.
                              sourcePlanInstanceId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan instance
                                  that the version copies.
                            required:
                              - reason
                              - sourceContractId
                              - sourcePlanInstanceId
                            additionalProperties: false
                          - type: object
                            description: >-
                              The details of a version from an update of the
                              charges of the plan instance, in the billing app
                              or through the API.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - manual_override
                                description: 'The reason of the version: manual_override.'
                              previousPlanInstanceVersionId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan instance
                                  version that was active before the update.
                            required:
                              - reason
                              - previousPlanInstanceVersionId
                            additionalProperties: false
                          - type: object
                            description: >-
                              The details of a version from a rate adjustment,
                              which applies a percentage to the prices of the
                              plan instance.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - readjustment
                                description: 'The reason of the version: readjustment.'
                              previousPlanInstanceVersionId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan instance
                                  version that was active before the rate
                                  adjustment.
                              percentage:
                                type: string
                                description: >-
                                  The percentage that the rate adjustment
                                  applied to the prices, as a decimal string,
                                  such as "5" for a rise of 5%.
                                examples:
                                  - '5'
                            required:
                              - reason
                              - previousPlanInstanceVersionId
                              - percentage
                            additionalProperties: false
                          - type: object
                            description: >-
                              The details of a version from a restore of an
                              earlier version.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - rollback
                                description: 'The reason of the version: rollback.'
                              rolledBackFromPlanInstanceVersionId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan instance
                                  version whose charges the restore brought
                                  back.
                            required:
                              - reason
                              - rolledBackFromPlanInstanceVersionId
                            additionalProperties: false
                          - type: 'null'
                            description: Aira recorded no details for the version.
                        description: >-
                          The details of how the version came to exist, by
                          reason, such as the plan version that it comes from,
                          the version before it or the percentage of a rate
                          adjustment, or null when Aira recorded none.
                      createdAt:
                        description: The moment when Aira created the version.
                        type: string
                        format: date-time
                      planCharges:
                        description: The plan charges of the version.
                        type: array
                        items:
                          type: object
                          description: >-
                            Schema representing a plan charge, one priced line
                            of a plan: its item names what it bills, its
                            category says what it bills from, its pricing model
                            turns a quantity into money, and its billing
                            frequency says how often it bills. The fields of a
                            charge depend on its category. An amount is an
                            integer number of cents, and a price is a decimal
                            string with up to 6 decimal places, in BRL or in the
                            credit unit of the charge.
                          discriminator:
                            propertyName: category
                          oneOf:
                            - type: object
                              description: >-
                                A fixed charge: the same amount in every charge
                                period, billed on the invoice that its billing
                                timing names.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: fixed.'
                                  enum:
                                    - fixed
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    fixed.
                                  enum:
                                    - fixed
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a fixed charge or of a minimum
                                    commitment.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: fixed.'
                                      enum:
                                        - fixed
                                    amount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The amount that the charge bills in each
                                        charge period, in cents, or the amount
                                        of one unit when the charge has a
                                        quantity. For a minimum commitment, the
                                        least that the charges of the plan with
                                        its billing frequency bill.
                                    quantity:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units that a fixed charge
                                        bills in each charge period, when it has
                                        one, so that each charge period bills
                                        quantity times amount. A minimum
                                        commitment has none.
                                  required:
                                    - model
                                    - amount
                                  additionalProperties: false
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    When the charge bills a charge period:
                                    in_arrears bills it on the closing invoice
                                    of its last cycle, and in_advance bills it
                                    before it starts, on the activation invoice
                                    or on the closing invoice of the cycle
                                    before. The billing timing moves the
                                    invoice, never the amount.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - billingTiming
                              additionalProperties: false
                            - type: object
                              description: >-
                                A minimum commitment: the least that the plan
                                bills in a charge period. When the charges of
                                the plan with the same billing frequency total
                                less, the charge bills the difference. A plan
                                has at most one for each billing frequency.
                              properties:
                                category:
                                  type: string
                                  description: >-
                                    The category of the charge:
                                    minimum_commitment.
                                  enum:
                                    - minimum_commitment
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    fixed.
                                  enum:
                                    - fixed
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a fixed charge or of a minimum
                                    commitment.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: fixed.'
                                      enum:
                                        - fixed
                                    amount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The amount that the charge bills in each
                                        charge period, in cents, or the amount
                                        of one unit when the charge has a
                                        quantity. For a minimum commitment, the
                                        least that the charges of the plan with
                                        its billing frequency bill.
                                    quantity:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units that a fixed charge
                                        bills in each charge period, when it has
                                        one, so that each charge period bills
                                        quantity times amount. A minimum
                                        commitment has none.
                                  required:
                                    - model
                                    - amount
                                  additionalProperties: false
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                              additionalProperties: false
                            - type: object
                              description: >-
                                A usage-based charge: a charge on the usage of a
                                resource in its charge period, priced by its
                                pricing model.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: usage_based.'
                                  enum:
                                    - usage_based
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  enum:
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                  description: >-
                                    The pricing model of the charge, the same as
                                    pricing.model. per_unit, per_package and
                                    tiered_per_unit price a resource in units,
                                    percentage and tiered_percentage price a
                                    resource in money, and tiered_fixed and
                                    advanced price either.
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a usage-based or license-based
                                    charge, by pricing model. Its model is the
                                    pricingModel of the charge.
                                  discriminator:
                                    propertyName: model
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per unit: each unit of the charge period
                                        past the included quantity costs
                                        unitPrice. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_unit.
                                          enum:
                                            - per_unit
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit, as a decimal
                                            string.
                                          examples:
                                            - '0.25'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - unitPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per package: the units of the charge
                                        period past the included quantity bill
                                        packagePrice for each package of
                                        packageSize units that they start. A
                                        charge on a resource in money cannot
                                        have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_package.
                                          enum:
                                            - per_package
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: The number of units in one package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one package, as a decimal
                                            string.
                                          examples:
                                            - '50.00'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage: the charge bills a
                                        percentage of the usage of its resource
                                        in the charge period. Only a charge on a
                                        resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            percentage.
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage that the
                                            charge bills, as a decimal string from 0
                                            to 100.
                                          examples:
                                            - '2.5'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered per unit: the tiers of the charge
                                        price its units, and each tier prices
                                        them per unit. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_per_unit.
                                          enum:
                                            - tiered_per_unit
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered percentage: the tiers of the
                                        charge price its usage, and each tier
                                        bills a percentage of it. Only a charge
                                        on a resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_percentage.
                                          enum:
                                            - tiered_percentage
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered fixed: the tier that the whole
                                        quantity reaches bills its flat amount.
                                        When the last tier has an end,
                                        unitOverage or percentageOverage prices
                                        the quantity past it, and a charge never
                                        has both.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_fixed.
                                          enum:
                                            - tiered_fixed
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            Always volume, because the tier that the
                                            whole quantity reaches bills its flat
                                            amount.
                                        unitOverage:
                                          type: object
                                          description: >-
                                            The price of the units past the last
                                            tier, for a charge on a resource in
                                            units or on a license, when the charge
                                            has one.
                                          properties:
                                            excessUnitPrice:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                The price of one unit past the last
                                                tier, as a decimal string.
                                              examples:
                                                - '0.30'
                                          required:
                                            - excessUnitPrice
                                          additionalProperties: false
                                        percentageOverage:
                                          type: object
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, for a
                                            charge on a resource in money, when the
                                            charge has one.
                                          properties:
                                            excessPercentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                The percentage of the usage past the
                                                last tier that the charge bills, as a
                                                decimal string from 0 to 100.
                                              examples:
                                                - '1.5'
                                          required:
                                            - excessPercentage
                                          additionalProperties: false
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      not:
                                        required:
                                          - unitOverage
                                          - percentageOverage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Advanced: tiers of mixed types price the
                                        quantity. The tiers of a charge on a
                                        resource in units are per_unit,
                                        per_package or flat, and those of a
                                        charge on a resource in money are
                                        percentage or flat. A charge priced
                                        before the other pricing models existed
                                        has it too.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            advanced.
                                          enum:
                                            - advanced
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                resourceId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the resource whose
                                    usage the charge prices.
                                currencyUnit:
                                  type: object
                                  description: >-
                                    The currency unit that the charge is priced
                                    in, or null when the charge has none. A
                                    charge with no currency unit or in BRL, the
                                    default currency unit, bills money. A charge
                                    in any other currency unit, a credit unit,
                                    decreases the balance of a credit pool in
                                    that unit and bills no money.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the currency
                                        unit in our system.
                                    name:
                                      type: string
                                      description: The name of the currency unit.
                                      examples:
                                        - Real
                                    code:
                                      type: string
                                      description: The short code of the currency unit.
                                      examples:
                                        - BRL
                                  required:
                                    - id
                                    - name
                                    - code
                                  additionalProperties: false
                                  nullable: true
                                tiers:
                                  type: array
                                  items:
                                    type: object
                                    description: >-
                                      A price tier of the charge: a band of
                                      quantity, from one number to another, with
                                      its own price. The first tier starts at 0
                                      or 1, and each tier starts at the to of
                                      the tier before it plus 1.
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                        description: >-
                                          The unique identifier of the tier in our
                                          system.
                                      position:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The position of the tier in the charge,
                                          from 0, from the lowest band to the
                                          highest.
                                      from:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The first quantity of the band, which
                                          the band includes: a number of units of
                                          the resource or of the license, or of
                                          cents for a resource in money.
                                      to:
                                        type: integer
                                        minimum: 0
                                        nullable: true
                                        description: >-
                                          The last quantity of the band, which the
                                          band includes, in the unit of from, or
                                          null when the band has no end. The last
                                          tier has an end only on a charge with
                                          the pricing model tiered_fixed and an
                                          overage.
                                      pricing:
                                        type: object
                                        description: >-
                                          The price of the quantity that falls in
                                          the tier, by type: per_unit, percentage,
                                          per_package or flat.
                                        discriminator:
                                          propertyName: type
                                        oneOf:
                                          - type: object
                                            description: >-
                                              Per unit: each unit in the tier costs
                                              unitPrice. A charge on a resource in
                                              money cannot have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_unit.'
                                                enum:
                                                  - per_unit
                                              unitPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one unit in the tier, as a
                                                  decimal string.
                                                examples:
                                                  - '0.20'
                                              fixedPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                nullable: true
                                                description: >-
                                                  An amount that the tier bills on top of
                                                  its units when the tier applies, as a
                                                  decimal string, or null when it has
                                                  none. Only a tier of a charge with the
                                                  pricing model tiered_per_unit has an
                                                  amount other than zero.
                                                examples:
                                                  - '10.00'
                                            required:
                                              - type
                                              - unitPrice
                                              - fixedPrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Percentage: the tier bills a percentage
                                              of the usage that falls in it. Only a
                                              charge on a resource in money has it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: percentage.'
                                                enum:
                                                  - percentage
                                              percentage:
                                                type: string
                                                pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                description: >-
                                                  The percentage of the usage in the tier
                                                  that the tier bills, as a decimal string
                                                  from 0 to 100.
                                                examples:
                                                  - '1.5'
                                            required:
                                              - type
                                              - percentage
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Per package: the units in the tier bill
                                              packagePrice for each package of
                                              packageSize units that they start. A
                                              charge on a resource in money cannot
                                              have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_package.'
                                                enum:
                                                  - per_package
                                              packageSize:
                                                type: integer
                                                minimum: 1
                                                description: The number of units in one package.
                                              packagePrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one package, as a decimal
                                                  string.
                                                examples:
                                                  - '45.00'
                                            required:
                                              - type
                                              - packageSize
                                              - packagePrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Flat: the tier bills one amount,
                                              whatever the quantity that falls in it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: flat.'
                                                enum:
                                                  - flat
                                              amount:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The amount that the tier bills, as a
                                                  decimal string.
                                                examples:
                                                  - '199.90'
                                            required:
                                              - type
                                              - amount
                                            additionalProperties: false
                                    required:
                                      - id
                                      - position
                                      - from
                                      - to
                                      - pricing
                                    additionalProperties: false
                                  description: >-
                                    The price tiers of the charge, from the
                                    lowest band to the highest, for the pricing
                                    models tiered_per_unit, tiered_percentage,
                                    tiered_fixed and advanced, or an empty list
                                    for the other pricing models.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - resourceId
                                - currencyUnit
                                - tiers
                              additionalProperties: false
                            - type: object
                              description: >-
                                A license-based charge: a charge on the balance
                                of a license in its charge period, read by its
                                billing model and priced by its pricing model.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: license_based.'
                                  enum:
                                    - license_based
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  enum:
                                    - per_unit
                                    - per_package
                                    - tiered_per_unit
                                    - tiered_fixed
                                  description: >-
                                    The pricing model of the charge, the same as
                                    pricing.model: per_unit, per_package,
                                    tiered_per_unit or tiered_fixed. No
                                    percentage applies, because the balance of a
                                    license is a count, not an amount of money.
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a usage-based or license-based
                                    charge, by pricing model. Its model is the
                                    pricingModel of the charge.
                                  discriminator:
                                    propertyName: model
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per unit: each unit of the charge period
                                        past the included quantity costs
                                        unitPrice. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_unit.
                                          enum:
                                            - per_unit
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit, as a decimal
                                            string.
                                          examples:
                                            - '0.25'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - unitPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per package: the units of the charge
                                        period past the included quantity bill
                                        packagePrice for each package of
                                        packageSize units that they start. A
                                        charge on a resource in money cannot
                                        have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_package.
                                          enum:
                                            - per_package
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: The number of units in one package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one package, as a decimal
                                            string.
                                          examples:
                                            - '50.00'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage: the charge bills a
                                        percentage of the usage of its resource
                                        in the charge period. Only a charge on a
                                        resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            percentage.
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage that the
                                            charge bills, as a decimal string from 0
                                            to 100.
                                          examples:
                                            - '2.5'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered per unit: the tiers of the charge
                                        price its units, and each tier prices
                                        them per unit. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_per_unit.
                                          enum:
                                            - tiered_per_unit
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered percentage: the tiers of the
                                        charge price its usage, and each tier
                                        bills a percentage of it. Only a charge
                                        on a resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_percentage.
                                          enum:
                                            - tiered_percentage
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered fixed: the tier that the whole
                                        quantity reaches bills its flat amount.
                                        When the last tier has an end,
                                        unitOverage or percentageOverage prices
                                        the quantity past it, and a charge never
                                        has both.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_fixed.
                                          enum:
                                            - tiered_fixed
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            Always volume, because the tier that the
                                            whole quantity reaches bills its flat
                                            amount.
                                        unitOverage:
                                          type: object
                                          description: >-
                                            The price of the units past the last
                                            tier, for a charge on a resource in
                                            units or on a license, when the charge
                                            has one.
                                          properties:
                                            excessUnitPrice:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                The price of one unit past the last
                                                tier, as a decimal string.
                                              examples:
                                                - '0.30'
                                          required:
                                            - excessUnitPrice
                                          additionalProperties: false
                                        percentageOverage:
                                          type: object
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, for a
                                            charge on a resource in money, when the
                                            charge has one.
                                          properties:
                                            excessPercentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                The percentage of the usage past the
                                                last tier that the charge bills, as a
                                                decimal string from 0 to 100.
                                              examples:
                                                - '1.5'
                                          required:
                                            - excessPercentage
                                          additionalProperties: false
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      not:
                                        required:
                                          - unitOverage
                                          - percentageOverage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Advanced: tiers of mixed types price the
                                        quantity. The tiers of a charge on a
                                        resource in units are per_unit,
                                        per_package or flat, and those of a
                                        charge on a resource in money are
                                        percentage or flat. A charge priced
                                        before the other pricing models existed
                                        has it too.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            advanced.
                                          enum:
                                            - advanced
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                licenseId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the license whose
                                    balance the charge bills.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the charge reads the balance of its
                                    license in a charge period: in_full bills
                                    the last balance, and proration weighs each
                                    balance by the days that it was in effect.
                                tiers:
                                  type: array
                                  items:
                                    type: object
                                    description: >-
                                      A price tier of the charge: a band of
                                      quantity, from one number to another, with
                                      its own price. The first tier starts at 0
                                      or 1, and each tier starts at the to of
                                      the tier before it plus 1.
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                        description: >-
                                          The unique identifier of the tier in our
                                          system.
                                      position:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The position of the tier in the charge,
                                          from 0, from the lowest band to the
                                          highest.
                                      from:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The first quantity of the band, which
                                          the band includes: a number of units of
                                          the resource or of the license, or of
                                          cents for a resource in money.
                                      to:
                                        type: integer
                                        minimum: 0
                                        nullable: true
                                        description: >-
                                          The last quantity of the band, which the
                                          band includes, in the unit of from, or
                                          null when the band has no end. The last
                                          tier has an end only on a charge with
                                          the pricing model tiered_fixed and an
                                          overage.
                                      pricing:
                                        type: object
                                        description: >-
                                          The price of the quantity that falls in
                                          the tier, by type: per_unit, percentage,
                                          per_package or flat.
                                        discriminator:
                                          propertyName: type
                                        oneOf:
                                          - type: object
                                            description: >-
                                              Per unit: each unit in the tier costs
                                              unitPrice. A charge on a resource in
                                              money cannot have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_unit.'
                                                enum:
                                                  - per_unit
                                              unitPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one unit in the tier, as a
                                                  decimal string.
                                                examples:
                                                  - '0.20'
                                              fixedPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                nullable: true
                                                description: >-
                                                  An amount that the tier bills on top of
                                                  its units when the tier applies, as a
                                                  decimal string, or null when it has
                                                  none. Only a tier of a charge with the
                                                  pricing model tiered_per_unit has an
                                                  amount other than zero.
                                                examples:
                                                  - '10.00'
                                            required:
                                              - type
                                              - unitPrice
                                              - fixedPrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Percentage: the tier bills a percentage
                                              of the usage that falls in it. Only a
                                              charge on a resource in money has it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: percentage.'
                                                enum:
                                                  - percentage
                                              percentage:
                                                type: string
                                                pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                description: >-
                                                  The percentage of the usage in the tier
                                                  that the tier bills, as a decimal string
                                                  from 0 to 100.
                                                examples:
                                                  - '1.5'
                                            required:
                                              - type
                                              - percentage
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Per package: the units in the tier bill
                                              packagePrice for each package of
                                              packageSize units that they start. A
                                              charge on a resource in money cannot
                                              have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_package.'
                                                enum:
                                                  - per_package
                                              packageSize:
                                                type: integer
                                                minimum: 1
                                                description: The number of units in one package.
                                              packagePrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one package, as a decimal
                                                  string.
                                                examples:
                                                  - '45.00'
                                            required:
                                              - type
                                              - packageSize
                                              - packagePrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Flat: the tier bills one amount,
                                              whatever the quantity that falls in it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: flat.'
                                                enum:
                                                  - flat
                                              amount:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The amount that the tier bills, as a
                                                  decimal string.
                                                examples:
                                                  - '199.90'
                                            required:
                                              - type
                                              - amount
                                            additionalProperties: false
                                    required:
                                      - id
                                      - position
                                      - from
                                      - to
                                      - pricing
                                    additionalProperties: false
                                  description: >-
                                    The price tiers of the charge, from the
                                    lowest band to the highest, for the pricing
                                    models tiered_per_unit and tiered_fixed, or
                                    an empty list for the other pricing models.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - licenseId
                                - billingModel
                                - tiers
                              additionalProperties: false
                            - type: object
                              description: >-
                                A custom plan charge: a charge whose price comes
                                from code that Aira writes for you, from the
                                custom charge definition that the charge follows
                                and from the parameter values of the charge. It
                                bills in arrears, in money.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: custom.'
                                  enum:
                                    - custom
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    custom.
                                  enum:
                                    - custom
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a custom plan charge: the
                                    parameter values that the code that Aira
                                    writes for you turns into an amount.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: custom.'
                                      enum:
                                        - custom
                                    parameters:
                                      type: object
                                      additionalProperties: true
                                      description: >-
                                        The parameter values of the charge, by
                                        the keys of the parameter schema of its
                                        custom charge definition.
                                  required:
                                    - model
                                    - parameters
                                  additionalProperties: false
                                customChargeDefinitionId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the custom charge
                                    definition that the charge follows.
                                chosenResourceIds:
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                  description: >-
                                    The unique identifiers of the resources that
                                    the charge chose as its inputs, from the
                                    input resources of its custom charge
                                    definition.
                                chosenLicenseIds:
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                  description: >-
                                    The unique identifiers of the licenses that
                                    the charge chose as its inputs, from the
                                    input licenses of its custom charge
                                    definition.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - customChargeDefinitionId
                                - chosenResourceIds
                                - chosenLicenseIds
                              additionalProperties: false
                    required:
                      - id
                      - planInstanceId
                      - planVersionId
                      - versionNumber
                      - isActive
                      - planInstanceVersionReason
                      - metadata
                      - createdAt
                      - planCharges
                    additionalProperties: false
                required:
                  - id
                  - contractId
                  - planId
                  - activePlanInstanceVersionId
                  - activePlanVersionId
                  - activePlanInstanceVersionReason
                  - status
                  - plan
                  - activePlanInstanceVersion
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `contract_cannot_be_updated`: the contract is completed or
            canceled.

            - `invalid_date`: `startDate` is before the start of the contract or
            after its end, or `endDate` is after the end of the contract or
            before today.

            - `start_date_after_end_date`: `endDate` is before `startDate`.

            - `plan_instance_already_exists`: the contract already has an active
            plan instance of the plan.

            - `invalid_proration_usage_scope`: the plan has a usage-based charge
            on a resource with the billing model `proration`, and the usage
            scope of the contract has more than one customer.

            - `invalid_license_proration_allocation`: the plan has a
            license-based charge with the billing model `proration`, and the
            contract splits its invoices by the share of the usage of each
            customer.

            - `mixed_billing_frequency_family`: the billing frequencies of the
            plan charges of the plan are in weeks and the billing schedule of
            the contract repeats every month, or the reverse.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - contract_cannot_be_updated
                      - invalid_date
                      - start_date_after_end_date
                      - plan_instance_already_exists
                      - invalid_proration_usage_scope
                      - invalid_license_proration_allocation
                      - mixed_billing_frequency_family
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''planId'' is required'
                    code: json_schema_validation_error
                contract_cannot_be_updated:
                  value:
                    message: invalid contract status transition
                    code: contract_cannot_be_updated
                invalid_date:
                  value:
                    message: invalid due date from omie account receivable
                    code: invalid_date
                start_date_after_end_date:
                  value:
                    message: Start date after end date
                    code: start_date_after_end_date
                plan_instance_already_exists:
                  value:
                    message: plan instance already exists for this contract and plan
                    code: plan_instance_already_exists
                invalid_proration_usage_scope:
                  value:
                    message: >-
                      proration metrics are not supported when billing cycle
                      usage scope has more than one customer
                    code: invalid_proration_usage_scope
                invalid_license_proration_allocation:
                  value:
                    message: >-
                      prorated license charges are not supported on contracts
                      that split invoices by subsidiary usage
                    code: invalid_license_proration_allocation
                mixed_billing_frequency_family:
                  value:
                    message: >-
                      the billing frequencies of the plan charges of the plan
                      are in weeks and the billing schedule of the contract
                      repeats every month, or the reverse
                    code: mixed_billing_frequency_family
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plan_instances:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `contract_not_found`: no contract has the `contractId`.
            - `plan_not_found`: no plan has the `planId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_not_found
                      - plan_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_not_found:
                  value:
                    message: contract not found
                    code: contract_not_found
                plan_not_found:
                  value:
                    message: plan "{planId}" not found
                    code: plan_not_found
    get:
      summary: List plan instances
      tags:
        - Plan Instances
      description: >-
        Lists the plan instances, newest first, each with the ids of its
        contract, its customer and its plan. The list holds the active plan
        instances unless `status[]` names other statuses. Fetch a plan instance
        by id to read its plan charges.


        Requires the role `plan_instances:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: query
          name: contractId
          required: false
          description: Only return the plan instances of this contract.
        - schema:
            type: string
            format: uuid
          in: query
          name: planId
          required: false
          description: Only return the plan instances of this plan.
        - schema:
            type: array
            items:
              type: string
              format: uuid
          in: query
          name: customerIds[]
          required: false
          description: >-
            Only return the plan instances of the contracts of these customers,
            identified by their id in our system.
        - schema:
            type: array
            items:
              type: string
              pattern: ^[a-zA-Z0-9_-]+$
          in: query
          name: customerExternalIds[]
          required: false
          description: >-
            Only return the plan instances of the contracts of these customers,
            identified by their id in your system.
        - schema:
            type: array
            items:
              type: string
              enum:
                - active
                - canceled
                - completed
          in: query
          name: status[]
          required: false
          description: >-
            Only return the plan instances in these statuses. Active plan
            instances are returned when omitted.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: &ref_15
        - plan_instances:read
      responses:
        '200':
          description: The plan instances that match the filters, newest first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a plan instance in a list: a plan
                        put on one contract, with the ids of the contract, the
                        customer and the plan that it belongs to. Fetch the plan
                        instance by id to read its charges.
                      properties:
                        id:
                          description: >-
                            The unique identifier of the plan instance in our
                            system.
                          type: string
                          format: uuid
                        contractId:
                          description: >-
                            The unique identifier of the contract that the plan
                            instance belongs to.
                          type: string
                          format: uuid
                        customerId:
                          description: >-
                            The unique identifier of the customer that the
                            contract belongs to.
                          type: string
                          format: uuid
                        planId:
                          description: >-
                            The unique identifier of the plan that the plan
                            instance comes from.
                          type: string
                          format: uuid
                        status:
                          description: >-
                            The status of the plan instance: active (billed in
                            the cycles of the contract), completed (reached its
                            end) or canceled (stopped before its end).
                          type: string
                          enum:
                            - active
                            - canceled
                            - completed
                        activePlanInstanceVersionId:
                          description: >-
                            The unique identifier of the plan instance version
                            that billing uses.
                          type: string
                          format: uuid
                        plan:
                          type: object
                          description: The plan that the plan instance comes from.
                          properties:
                            id:
                              type: string
                              format: uuid
                              description: The unique identifier of the plan in our system.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the plan.
                              example: Plano Essencial
                          required:
                            - id
                            - name
                          additionalProperties: false
                      required:
                        - id
                        - contractId
                        - customerId
                        - planId
                        - status
                        - activePlanInstanceVersionId
                        - plan
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''contractId'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plan_instances:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/plan-instances/{id}:
    put:
      summary: Update plan instance
      tags:
        - Plan Instances
      description: >-
        Replaces the plan charges of a plan instance: a new plan instance
        version, with the plan charges and the custom field values of the body
        and the reason manual_override, becomes its active plan instance
        version. The earlier plan instance versions stay, so a restore can bring
        one back.


        Requires the role `plan_instances:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                planCharges:
                  type: array
                  description: >-
                    The full set of charges the plan instance will bill from now
                    on, keyed by category. Replaces the existing charges
                    entirely.
                  items:
                    type: object
                    discriminator:
                      propertyName: category
                    oneOf:
                      - type: object
                        description: >-
                          A fixed charge: bills a flat amount once per period of
                          its billingFrequency, at the boundary its
                          billingTiming picks.
                        properties:
                          category:
                            description: 'Discriminator: fixed charge.'
                            enum:
                              - fixed
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          itemId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the catalog item this
                              charge bills.
                          pricingModel:
                            type: string
                            description: >-
                              Fixed and minimum_commitment charges always use
                              fixed pricing.
                            enum:
                              - fixed
                          pricing:
                            type: object
                            description: >-
                              Fixed pricing: a flat amount billed once per
                              period of the charge's billingFrequency. The only
                              pricing available for fixed and minimum_commitment
                              charges.
                            properties:
                              model:
                                description: 'Discriminator: fixed pricing.'
                                enum:
                                  - fixed
                              amount:
                                type: integer
                                minimum: 0
                                description: >-
                                  The flat amount billed per period, in cents.
                                  For minimum_commitment charges, the minimum
                                  the charges sharing its frequency are topped
                                  up to.
                              quantity:
                                type: integer
                                minimum: 1
                                description: >-
                                  Optional, fixed charges only: the quantity
                                  billed. When set, amount is the amount of one
                                  unit and each period of the charge's
                                  billingFrequency bills quantity x amount.
                            required:
                              - model
                              - amount
                            additionalProperties: false
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                          billingTiming:
                            type: string
                            enum:
                              - in_advance
                              - in_arrears
                            description: >-
                              Optional. When the charge's flat fee is billed
                              relative to the period it covers (see
                              billingFrequency): in_arrears (the default) bills
                              the period at the close of the cycle that ends it;
                              in_advance bills it at the boundary that opens it
                              (the contract's activation invoice for the periods
                              its first cycle opens, otherwise the close of the
                              cycle just before the period). Only the timing
                              shifts, never the amount. Valid only on fixed
                              charges. Defaults to in_arrears when omitted.
                        required:
                          - category
                          - itemId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                      - type: object
                        description: >-
                          A minimum commitment charge: at the close of each
                          period of its billingFrequency, tops the plan's
                          charges sharing that frequency up to the configured
                          amount when their total on that calculation stays
                          below it. A plan can have at most one minimum per
                          billing frequency.
                        properties:
                          category:
                            description: 'Discriminator: minimum commitment charge.'
                            enum:
                              - minimum_commitment
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          itemId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the catalog item this
                              charge bills.
                          pricingModel:
                            type: string
                            description: >-
                              Fixed and minimum_commitment charges always use
                              fixed pricing.
                            enum:
                              - fixed
                          pricing:
                            type: object
                            description: >-
                              Fixed pricing: a flat amount billed once per
                              period of the charge's billingFrequency. The only
                              pricing available for fixed and minimum_commitment
                              charges.
                            properties:
                              model:
                                description: 'Discriminator: fixed pricing.'
                                enum:
                                  - fixed
                              amount:
                                type: integer
                                minimum: 0
                                description: >-
                                  The flat amount billed per period, in cents.
                                  For minimum_commitment charges, the minimum
                                  the charges sharing its frequency are topped
                                  up to.
                              quantity:
                                type: integer
                                minimum: 1
                                description: >-
                                  Optional, fixed charges only: the quantity
                                  billed. When set, amount is the amount of one
                                  unit and each period of the charge's
                                  billingFrequency bills quantity x amount.
                            required:
                              - model
                              - amount
                            additionalProperties: false
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                        required:
                          - category
                          - itemId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                      - type: object
                        description: >-
                          A usage-based charge: prices the consumption of a
                          metered resource according to pricingModel.
                        properties:
                          category:
                            description: 'Discriminator: usage-based charge.'
                            enum:
                              - usage_based
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          resourceId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the metered resource
                              whose usage the charge prices.
                          pricingModel:
                            type: string
                            enum:
                              - per_unit
                              - per_package
                              - percentage
                              - tiered_per_unit
                              - tiered_percentage
                              - tiered_fixed
                              - advanced
                            description: >-
                              How the charge is priced: per_unit (price per unit
                              with optional included quantity), per_package
                              (price per started package of units), percentage
                              (a percentage of a monetary base amount),
                              tiered_per_unit / tiered_percentage / tiered_fixed
                              (tier ladder where every tier uses that pricing
                              type), or advanced (tier ladder mixing tier
                              pricing types). per_unit, per_package and
                              tiered_per_unit require a Unit-type resource;
                              percentage and tiered_percentage require a
                              Currency-type resource; tiered_fixed and advanced
                              accept either. Always matches pricing.model.
                          pricing:
                            type: object
                            description: >-
                              Pricing configuration of a usage-based charge,
                              keyed by model. Must match the charge's
                              pricingModel.
                            discriminator:
                              propertyName: model
                            oneOf:
                              - type: object
                                description: >-
                                  Per-unit pricing: every billable unit costs
                                  unitPrice, after deducting the included
                                  quantity. Not valid for charges on
                                  Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: per-unit pricing.'
                                    enum:
                                      - per_unit
                                  includedQuantity:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional number of units included at no
                                      charge before billing starts.
                                  unitPrice:
                                    type: string
                                    pattern: ^\d+(\.\d{1,6})?$
                                    description: >-
                                      Price per unit, as a decimal currency-unit
                                      string (up to 6 decimal places).
                                    examples:
                                      - '0.25'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - unitPrice
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Per-package pricing: billable units are
                                  charged per started package of packageSize
                                  units, after deducting the included quantity.
                                  Not valid for charges on Currency-type
                                  resources.
                                properties:
                                  model:
                                    description: 'Discriminator: per-package pricing.'
                                    enum:
                                      - per_package
                                  includedQuantity:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional number of units included at no
                                      charge before billing starts.
                                  packageSize:
                                    type: integer
                                    minimum: 1
                                    description: Number of resource units per package.
                                  packagePrice:
                                    type: string
                                    pattern: ^\d+(\.\d{1,6})?$
                                    description: >-
                                      Price per package, as a decimal
                                      currency-unit string (up to 6 decimal
                                      places).
                                    examples:
                                      - '50.00'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - packageSize
                                  - packagePrice
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Percentage pricing: a percentage taken over
                                  the monetary base amount consumed. Only valid
                                  for charges on Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: percentage pricing.'
                                    enum:
                                      - percentage
                                  percentage:
                                    type: string
                                    pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                    description: >-
                                      Percentage applied to the base amount, as
                                      a decimal string from 0 to 100 (up to 6
                                      decimal places).
                                    examples:
                                      - '2.5'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - percentage
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered per-unit pricing: units are priced by
                                  the tier ladder defined in the charge's tiers,
                                  every tier priced per unit. Not valid for
                                  charges on Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered per-unit pricing.'
                                    enum:
                                      - tiered_per_unit
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered percentage pricing: the monetary base
                                  amount is priced by the tier ladder defined in
                                  the charge's tiers, every tier priced as a
                                  percentage. Only valid for charges on
                                  Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered percentage pricing.'
                                    enum:
                                      - tiered_percentage
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered fixed pricing: the tier containing the
                                  total usage bills its flat amount. Always
                                  volume mode. Usage beyond the last tier can be
                                  billed through unitOverage or
                                  percentageOverage (mutually exclusive);
                                  configuring one requires a bounded final tier.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered fixed pricing.'
                                    enum:
                                      - tiered_fixed
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      Must be volume for tiered fixed pricing:
                                      the single tier containing the total usage
                                      bills its flat amount.
                                  unitOverage:
                                    type: object
                                    description: >-
                                      Optional overage price for units beyond
                                      the last tier, for charges on Unit-type
                                      resources. Mutually exclusive with
                                      percentageOverage.
                                    properties:
                                      excessUnitPrice:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit beyond the last tier, as
                                          a decimal currency-unit string (up to 6
                                          decimal places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - excessUnitPrice
                                    additionalProperties: false
                                  percentageOverage:
                                    type: object
                                    description: >-
                                      Optional overage percentage for the base
                                      amount beyond the last tier, for charges
                                      on Currency-type resources. Mutually
                                      exclusive with unitOverage.
                                    properties:
                                      excessPercentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          beyond the last tier, as a decimal
                                          string from 0 to 100 (up to 6 decimal
                                          places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - excessPercentage
                                    additionalProperties: false
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                not:
                                  required:
                                    - unitOverage
                                    - percentageOverage
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Advanced pricing: a tier ladder mixing tier
                                  pricing types (per unit, percentage, per
                                  package, flat). On a Unit-type resource the
                                  tiers can be per_unit, per_package or flat; on
                                  a Currency-type resource, percentage or flat.
                                  Also used for charges priced before single
                                  pricing models existed.
                                properties:
                                  model:
                                    description: >-
                                      Discriminator: advanced (mixed-tier)
                                      pricing.
                                    enum:
                                      - advanced
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                          tiers:
                            type: array
                            items:
                              type: object
                              description: >-
                                A price tier: a band of quantity, from one
                                number to another, with its own price. The tiers
                                of a plan charge form a contiguous ladder over
                                its quantity.
                              properties:
                                from:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    Lower bound of the tier band (inclusive), in
                                    resource units — or cents of the monetary
                                    base amount for percentage-priced tiers. The
                                    first tier starts at 0 or 1; each subsequent
                                    tier starts at the previous tier's to + 1.
                                to:
                                  type: integer
                                  minimum: 0
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band (inclusive), in
                                    the same unit as from. Null makes the final
                                    tier unbounded; a finite final bound is only
                                    allowed on tiered_fixed charges with an
                                    overage price configured.
                                pricing:
                                  type: object
                                  description: >-
                                    How usage falling in this tier is priced,
                                    keyed by type: per_unit (price per unit),
                                    percentage (percentage of the base amount),
                                    per_package (price per started package), or
                                    flat (fixed amount for the band).
                                  discriminator:
                                    propertyName: type
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per-unit tier pricing: every unit in the
                                        tier band costs unitPrice. Not valid for
                                        charges on Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: per-unit tier pricing.'
                                          enum:
                                            - per_unit
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            Price per unit within the tier, as a
                                            decimal currency-unit string (up to 6
                                            decimal places).
                                          examples:
                                            - '0.20'
                                        fixedPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          nullable: true
                                          description: >-
                                            Optional flat fee billed on top when the
                                            tier applies, as a decimal currency-unit
                                            string. Only valid on pricingModel
                                            tiered_per_unit. Null when the tier has
                                            no flat fee.
                                          examples:
                                            - '10.00'
                                      required:
                                        - type
                                        - unitPrice
                                        - fixedPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage tier pricing: the base amount
                                        in the tier band is billed at a
                                        percentage. Only valid for charges on
                                        Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: percentage tier pricing.'
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            Percentage applied to the base amount
                                            within the tier, as a decimal string
                                            from 0 to 100 (up to 6 decimal places).
                                          examples:
                                            - '1.5'
                                      required:
                                        - type
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per-package tier pricing: units in the
                                        tier band are charged per started
                                        package of packageSize units. Not valid
                                        for charges on Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: per-package tier pricing.'
                                          enum:
                                            - per_package
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: Number of resource units per package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            Price per package, as a decimal
                                            currency-unit string (up to 6 decimal
                                            places).
                                          examples:
                                            - '45.00'
                                      required:
                                        - type
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Flat tier pricing: usage falling in the
                                        tier band is billed a flat amount,
                                        regardless of the exact quantity.
                                      properties:
                                        type:
                                          description: 'Discriminator: flat tier pricing.'
                                          enum:
                                            - flat
                                        amount:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The flat amount billed for the tier, as
                                            a decimal currency-unit string (up to 6
                                            decimal places).
                                          examples:
                                            - '199.90'
                                      required:
                                        - type
                                        - amount
                                      additionalProperties: false
                              required:
                                - from
                                - to
                                - pricing
                              additionalProperties: false
                            description: >-
                              The tier ladder of the charge, ordered from the
                              lowest band to the highest. Required non-empty for
                              tier-based pricing models (tiered_per_unit,
                              tiered_percentage, tiered_fixed, advanced); must
                              be empty otherwise.
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                          currencyUnitCode:
                            type: string
                            description: >-
                              Code of the currency unit the charge's usage is
                              denominated in, when the credits module is on.
                              Defaults to BRL when omitted.
                            examples:
                              - BRL
                        required:
                          - category
                          - resourceId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                          - tiers
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                      - type: object
                        description: >-
                          A license-based charge: bills the license balance once
                          per period of its billingFrequency, at the close of
                          the period. By default it bills in full the last
                          balance reported before the close; when billingModel
                          is proration, it prorates each change of the balance
                          over the days held.
                        properties:
                          category:
                            description: 'Discriminator: license-based charge.'
                            enum:
                              - license_based
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          licenseId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the license whose
                              reported count the charge bills. The charge bills
                              as the license's own catalog item.
                          pricingModel:
                            type: string
                            enum:
                              - per_unit
                              - per_package
                              - tiered_per_unit
                              - tiered_fixed
                            description: >-
                              How the license count is priced: per_unit (price
                              per license with optional included quantity),
                              per_package (price per started package of
                              licenses), or tiered_per_unit / tiered_fixed (tier
                              ladder over the count). Percentage models do not
                              apply: a license count carries no monetary base.
                              Always matches pricing.model.
                          pricing:
                            type: object
                            description: >-
                              Pricing configuration of a usage-based charge,
                              keyed by model. Must match the charge's
                              pricingModel.
                            discriminator:
                              propertyName: model
                            oneOf:
                              - type: object
                                description: >-
                                  Per-unit pricing: every billable unit costs
                                  unitPrice, after deducting the included
                                  quantity. Not valid for charges on
                                  Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: per-unit pricing.'
                                    enum:
                                      - per_unit
                                  includedQuantity:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional number of units included at no
                                      charge before billing starts.
                                  unitPrice:
                                    type: string
                                    pattern: ^\d+(\.\d{1,6})?$
                                    description: >-
                                      Price per unit, as a decimal currency-unit
                                      string (up to 6 decimal places).
                                    examples:
                                      - '0.25'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - unitPrice
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Per-package pricing: billable units are
                                  charged per started package of packageSize
                                  units, after deducting the included quantity.
                                  Not valid for charges on Currency-type
                                  resources.
                                properties:
                                  model:
                                    description: 'Discriminator: per-package pricing.'
                                    enum:
                                      - per_package
                                  includedQuantity:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional number of units included at no
                                      charge before billing starts.
                                  packageSize:
                                    type: integer
                                    minimum: 1
                                    description: Number of resource units per package.
                                  packagePrice:
                                    type: string
                                    pattern: ^\d+(\.\d{1,6})?$
                                    description: >-
                                      Price per package, as a decimal
                                      currency-unit string (up to 6 decimal
                                      places).
                                    examples:
                                      - '50.00'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - packageSize
                                  - packagePrice
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Percentage pricing: a percentage taken over
                                  the monetary base amount consumed. Only valid
                                  for charges on Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: percentage pricing.'
                                    enum:
                                      - percentage
                                  percentage:
                                    type: string
                                    pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                    description: >-
                                      Percentage applied to the base amount, as
                                      a decimal string from 0 to 100 (up to 6
                                      decimal places).
                                    examples:
                                      - '2.5'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - percentage
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered per-unit pricing: units are priced by
                                  the tier ladder defined in the charge's tiers,
                                  every tier priced per unit. Not valid for
                                  charges on Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered per-unit pricing.'
                                    enum:
                                      - tiered_per_unit
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered percentage pricing: the monetary base
                                  amount is priced by the tier ladder defined in
                                  the charge's tiers, every tier priced as a
                                  percentage. Only valid for charges on
                                  Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered percentage pricing.'
                                    enum:
                                      - tiered_percentage
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered fixed pricing: the tier containing the
                                  total usage bills its flat amount. Always
                                  volume mode. Usage beyond the last tier can be
                                  billed through unitOverage or
                                  percentageOverage (mutually exclusive);
                                  configuring one requires a bounded final tier.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered fixed pricing.'
                                    enum:
                                      - tiered_fixed
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      Must be volume for tiered fixed pricing:
                                      the single tier containing the total usage
                                      bills its flat amount.
                                  unitOverage:
                                    type: object
                                    description: >-
                                      Optional overage price for units beyond
                                      the last tier, for charges on Unit-type
                                      resources. Mutually exclusive with
                                      percentageOverage.
                                    properties:
                                      excessUnitPrice:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit beyond the last tier, as
                                          a decimal currency-unit string (up to 6
                                          decimal places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - excessUnitPrice
                                    additionalProperties: false
                                  percentageOverage:
                                    type: object
                                    description: >-
                                      Optional overage percentage for the base
                                      amount beyond the last tier, for charges
                                      on Currency-type resources. Mutually
                                      exclusive with unitOverage.
                                    properties:
                                      excessPercentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          beyond the last tier, as a decimal
                                          string from 0 to 100 (up to 6 decimal
                                          places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - excessPercentage
                                    additionalProperties: false
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                not:
                                  required:
                                    - unitOverage
                                    - percentageOverage
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Advanced pricing: a tier ladder mixing tier
                                  pricing types (per unit, percentage, per
                                  package, flat). On a Unit-type resource the
                                  tiers can be per_unit, per_package or flat; on
                                  a Currency-type resource, percentage or flat.
                                  Also used for charges priced before single
                                  pricing models existed.
                                properties:
                                  model:
                                    description: >-
                                      Discriminator: advanced (mixed-tier)
                                      pricing.
                                    enum:
                                      - advanced
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                          billingModel:
                            type: string
                            enum:
                              - in_full
                              - proration
                            description: >-
                              Optional. How the license balance bills over the
                              charge's period: in_full (the default) bills the
                              last balance reported before the period closes,
                              for the whole period; proration bills the opening
                              balance at full price plus one prorated delta per
                              change during the cycle. Proration requires
                              per_unit pricing, or tiered_per_unit in
                              progressive mode: only tier unit prices prorate,
                              and tier flat prices bill in full for the bands
                              that the closing balance reaches.
                          tiers:
                            type: array
                            items:
                              type: object
                              description: >-
                                A price tier: a band of quantity, from one
                                number to another, with its own price. The tiers
                                of a plan charge form a contiguous ladder over
                                its quantity.
                              properties:
                                from:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    Lower bound of the tier band (inclusive), in
                                    resource units — or cents of the monetary
                                    base amount for percentage-priced tiers. The
                                    first tier starts at 0 or 1; each subsequent
                                    tier starts at the previous tier's to + 1.
                                to:
                                  type: integer
                                  minimum: 0
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band (inclusive), in
                                    the same unit as from. Null makes the final
                                    tier unbounded; a finite final bound is only
                                    allowed on tiered_fixed charges with an
                                    overage price configured.
                                pricing:
                                  type: object
                                  description: >-
                                    How usage falling in this tier is priced,
                                    keyed by type: per_unit (price per unit),
                                    percentage (percentage of the base amount),
                                    per_package (price per started package), or
                                    flat (fixed amount for the band).
                                  discriminator:
                                    propertyName: type
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per-unit tier pricing: every unit in the
                                        tier band costs unitPrice. Not valid for
                                        charges on Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: per-unit tier pricing.'
                                          enum:
                                            - per_unit
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            Price per unit within the tier, as a
                                            decimal currency-unit string (up to 6
                                            decimal places).
                                          examples:
                                            - '0.20'
                                        fixedPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          nullable: true
                                          description: >-
                                            Optional flat fee billed on top when the
                                            tier applies, as a decimal currency-unit
                                            string. Only valid on pricingModel
                                            tiered_per_unit. Null when the tier has
                                            no flat fee.
                                          examples:
                                            - '10.00'
                                      required:
                                        - type
                                        - unitPrice
                                        - fixedPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage tier pricing: the base amount
                                        in the tier band is billed at a
                                        percentage. Only valid for charges on
                                        Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: percentage tier pricing.'
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            Percentage applied to the base amount
                                            within the tier, as a decimal string
                                            from 0 to 100 (up to 6 decimal places).
                                          examples:
                                            - '1.5'
                                      required:
                                        - type
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per-package tier pricing: units in the
                                        tier band are charged per started
                                        package of packageSize units. Not valid
                                        for charges on Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: per-package tier pricing.'
                                          enum:
                                            - per_package
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: Number of resource units per package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            Price per package, as a decimal
                                            currency-unit string (up to 6 decimal
                                            places).
                                          examples:
                                            - '45.00'
                                      required:
                                        - type
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Flat tier pricing: usage falling in the
                                        tier band is billed a flat amount,
                                        regardless of the exact quantity.
                                      properties:
                                        type:
                                          description: 'Discriminator: flat tier pricing.'
                                          enum:
                                            - flat
                                        amount:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The flat amount billed for the tier, as
                                            a decimal currency-unit string (up to 6
                                            decimal places).
                                          examples:
                                            - '199.90'
                                      required:
                                        - type
                                        - amount
                                      additionalProperties: false
                              required:
                                - from
                                - to
                                - pricing
                              additionalProperties: false
                            description: >-
                              The tier ladder of the charge, ordered from the
                              lowest band to the highest. Required non-empty for
                              tier-based pricing models (tiered_per_unit,
                              tiered_fixed); must be empty otherwise.
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                        required:
                          - category
                          - licenseId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                          - tiers
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                      - type: object
                        description: >-
                          A custom charge: bills the amount that the calculator
                          that Aira writes for you computes from the inputs the
                          charge chooses among its custom charge definition's
                          inputs and from the charge's parameter values. Bills
                          in arrears in the default currency.
                        properties:
                          category:
                            description: 'Discriminator: custom charge.'
                            enum:
                              - custom
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          itemId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the catalog item this
                              charge bills.
                          customChargeDefinitionId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the custom charge
                              definition the charge follows.
                          chosenResourceIds:
                            type: array
                            items:
                              type: string
                              format: uuid
                            uniqueItems: true
                            description: >-
                              The unique identifiers of the metered resources
                              that the charge chooses as its inputs, from the
                              definition's inputResourceIds. Together with
                              chosenLicenseIds, the charge chooses exactly the
                              definition's chosenInputCount inputs. Omitting it
                              chooses no resource.
                          chosenLicenseIds:
                            type: array
                            items:
                              type: string
                              format: uuid
                            uniqueItems: true
                            description: >-
                              The unique identifiers of the licenses that the
                              charge chooses as its inputs, from the
                              definition's inputLicenseIds. Together with
                              chosenResourceIds, the charge chooses exactly the
                              definition's chosenInputCount inputs. Omitting it
                              chooses no license.
                          pricingModel:
                            type: string
                            description: >-
                              Custom charges always use custom pricing: the
                              calculator that Aira writes for you computes the
                              amount from the charge's parameter values.
                            enum:
                              - custom
                          pricing:
                            type: object
                            description: >-
                              Custom pricing: schema-defined commercial
                              parameters priced by the calculator that Aira
                              writes for you. The only pricing available for
                              custom charges.
                            properties:
                              model:
                                description: 'Discriminator: custom pricing.'
                                enum:
                                  - custom
                              parameters:
                                type: object
                                additionalProperties: true
                                description: >-
                                  The charge's commercial parameter values,
                                  keyed by the field keys of the referenced
                                  custom charge definition's parameter schema.
                                  Validated against that parameter schema when
                                  the charge is saved.
                            required:
                              - model
                              - parameters
                            additionalProperties: false
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                        required:
                          - category
                          - itemId
                          - customChargeDefinitionId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                customFields:
                  type: object
                  description: >-
                    The custom field values of the plan instance version that
                    the update creates, checked against the custom fields of
                    plan instance versions. An update without them answers 400
                    when one of those custom fields is required, and creates the
                    version with no values otherwise.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
              required:
                - planCharges
              additionalProperties: false
        required: true
        description: >-
          Schema for overriding the pricing of a plan instance. The provided
          charges replace the instance's full charge set and a new plan instance
          version is created.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the plan instance in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: currency_unit_not_found
          when: no currency unit has the `currencyUnitCode` of a usage-based charge
        - status: 400
          code: invalid_custom_fields
          when: >-
            `customFields` leaves out a required custom field of plan instance
            versions, has a key that no custom field of plan instance versions
            has, or has a value that its custom field does not accept
        - status: 400
          code: invalid_plan_charges
          when: >-
            `planCharges` is empty, or a plan charge breaks a rule of plan
            charges, such as tiers that leave a gap, an item, a resource or a
            license that does not exist, two minimum commitments with the same
            billing frequency, or billing frequencies in both months and weeks
        - status: 400
          code: billing_frequency_not_yet_supported
          when: >-
            a license-based charge with the billing model `proration`, or a
            usage-based charge on a resource with the billing model `proration`,
            has a billing frequency of more than one month or one week
        - status: 400
          code: invalid_proration_usage_scope
          when: >-
            `planCharges` has a usage-based charge on a resource with the
            billing model `proration`, and the usage scope of the contract of
            the plan instance has more than one customer
        - status: 400
          code: invalid_license_proration_allocation
          when: >-
            `planCharges` has a license-based charge with the billing model
            `proration`, and the contract of the plan instance splits its
            invoices by the share of the usage of each customer
        - status: 400
          code: mixed_billing_frequency_family
          when: >-
            the billing frequencies of `planCharges` are in weeks and the
            billing schedule of the contract of the plan instance repeats every
            month, or the reverse
        - status: 404
          code: plan_instance_not_found
          when: no plan instance has the `id`
        - status: 404
          code: plan_not_found
          when: the plan of the plan instance was deleted
      x-required-roles: *ref_14
      responses:
        '200':
          description: >-
            A plan instance: a plan put on one contract. It has its own
            versions, so the prices of one contract can change while the plan
            stays the same.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the plan instance in our system.
                  contractId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the contract the plan instance
                      belongs to.
                  planId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the plan this instance was
                      created from.
                  activePlanInstanceVersionId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the plan instance version
                      currently used for billing.
                  activePlanVersionId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the plan version the active plan
                      instance version derives from.
                  activePlanInstanceVersionReason:
                    type: string
                    enum:
                      - created_from_plan_version
                      - duplicated_from_contract
                      - manual_override
                      - readjustment
                      - rollback
                    description: >-
                      Why the active plan instance version exists:
                      created_from_plan_version (instantiated from the plan's
                      version), duplicated_from_contract (copied when the
                      contract was duplicated), manual_override (pricing
                      overridden manually or through the API), readjustment (a
                      percentage rate adjustment was applied), or rollback
                      (rolled back to a previous version).
                  status:
                    type: string
                    enum:
                      - active
                      - canceled
                      - completed
                    description: >-
                      Current status of the plan instance: active (billed on the
                      contract's cycles), canceled (interrupted before its end;
                      no longer billed), or completed (ran through its end).
                  plan:
                    type: object
                    description: >-
                      Base properties of the plan this instance was created
                      from.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the plan in our system.
                      name:
                        type: string
                        minLength: 1
                        description: The name of the plan.
                        example: Plano Essencial
                      description:
                        description: The description of the plan, or null when it has none.
                        type:
                          - 'null'
                          - string
                        example: Assinatura mensal com entrega diária de pães.
                      productId:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the product that the plan
                          belongs to.
                    required:
                      - id
                      - name
                      - description
                      - productId
                    additionalProperties: false
                  activePlanInstanceVersion:
                    type: object
                    description: >-
                      The plan instance version currently used for billing,
                      including its plan charges, without its custom field
                      values.
                    properties:
                      id:
                        description: >-
                          The unique identifier of the plan instance version in
                          our system.
                        type: string
                        format: uuid
                      planInstanceId:
                        description: >-
                          The unique identifier of the plan instance that the
                          version belongs to.
                        type: string
                        format: uuid
                      planVersionId:
                        description: >-
                          The unique identifier of the plan version that the
                          version comes from.
                        type: string
                        format: uuid
                      versionNumber:
                        description: >-
                          The number of the version in its plan instance, from
                          1, one more for each new version.
                        type: integer
                        minimum: 1
                      isActive:
                        description: >-
                          Whether billing uses this version. A plan instance has
                          one active version.
                        type: boolean
                      planInstanceVersionReason:
                        description: >-
                          Why the version exists: created_from_plan_version (it
                          comes from a plan version of the plan),
                          duplicated_from_contract (a copy of a plan instance of
                          another contract), manual_override (an update of the
                          charges of the plan instance), readjustment (a rate
                          adjustment) or rollback (a restore of an earlier
                          version).
                        type: string
                        enum:
                          - created_from_plan_version
                          - duplicated_from_contract
                          - manual_override
                          - readjustment
                          - rollback
                      metadata:
                        anyOf:
                          - type: object
                            description: >-
                              The details of a version that comes from a plan
                              version of the plan.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - created_from_plan_version
                                description: >-
                                  The reason of the version:
                                  created_from_plan_version.
                              sourcePlanVersionId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan version that
                                  the version comes from.
                            required:
                              - reason
                              - sourcePlanVersionId
                            additionalProperties: false
                          - type: object
                            description: >-
                              The details of a version that copies a plan
                              instance of another contract, from a duplication
                              of that contract.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - duplicated_from_contract
                                description: >-
                                  The reason of the version:
                                  duplicated_from_contract.
                              sourceContractId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the contract that the
                                  duplication copied.
                              sourcePlanInstanceId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan instance
                                  that the version copies.
                            required:
                              - reason
                              - sourceContractId
                              - sourcePlanInstanceId
                            additionalProperties: false
                          - type: object
                            description: >-
                              The details of a version from an update of the
                              charges of the plan instance, in the billing app
                              or through the API.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - manual_override
                                description: 'The reason of the version: manual_override.'
                              previousPlanInstanceVersionId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan instance
                                  version that was active before the update.
                            required:
                              - reason
                              - previousPlanInstanceVersionId
                            additionalProperties: false
                          - type: object
                            description: >-
                              The details of a version from a rate adjustment,
                              which applies a percentage to the prices of the
                              plan instance.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - readjustment
                                description: 'The reason of the version: readjustment.'
                              previousPlanInstanceVersionId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan instance
                                  version that was active before the rate
                                  adjustment.
                              percentage:
                                type: string
                                description: >-
                                  The percentage that the rate adjustment
                                  applied to the prices, as a decimal string,
                                  such as "5" for a rise of 5%.
                                examples:
                                  - '5'
                            required:
                              - reason
                              - previousPlanInstanceVersionId
                              - percentage
                            additionalProperties: false
                          - type: object
                            description: >-
                              The details of a version from a restore of an
                              earlier version.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - rollback
                                description: 'The reason of the version: rollback.'
                              rolledBackFromPlanInstanceVersionId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan instance
                                  version whose charges the restore brought
                                  back.
                            required:
                              - reason
                              - rolledBackFromPlanInstanceVersionId
                            additionalProperties: false
                          - type: 'null'
                            description: Aira recorded no details for the version.
                        description: >-
                          The details of how the version came to exist, by
                          reason, such as the plan version that it comes from,
                          the version before it or the percentage of a rate
                          adjustment, or null when Aira recorded none.
                      createdAt:
                        description: The moment when Aira created the version.
                        type: string
                        format: date-time
                      planCharges:
                        description: The plan charges of the version.
                        type: array
                        items:
                          type: object
                          description: >-
                            Schema representing a plan charge, one priced line
                            of a plan: its item names what it bills, its
                            category says what it bills from, its pricing model
                            turns a quantity into money, and its billing
                            frequency says how often it bills. The fields of a
                            charge depend on its category. An amount is an
                            integer number of cents, and a price is a decimal
                            string with up to 6 decimal places, in BRL or in the
                            credit unit of the charge.
                          discriminator:
                            propertyName: category
                          oneOf:
                            - type: object
                              description: >-
                                A fixed charge: the same amount in every charge
                                period, billed on the invoice that its billing
                                timing names.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: fixed.'
                                  enum:
                                    - fixed
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    fixed.
                                  enum:
                                    - fixed
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a fixed charge or of a minimum
                                    commitment.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: fixed.'
                                      enum:
                                        - fixed
                                    amount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The amount that the charge bills in each
                                        charge period, in cents, or the amount
                                        of one unit when the charge has a
                                        quantity. For a minimum commitment, the
                                        least that the charges of the plan with
                                        its billing frequency bill.
                                    quantity:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units that a fixed charge
                                        bills in each charge period, when it has
                                        one, so that each charge period bills
                                        quantity times amount. A minimum
                                        commitment has none.
                                  required:
                                    - model
                                    - amount
                                  additionalProperties: false
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    When the charge bills a charge period:
                                    in_arrears bills it on the closing invoice
                                    of its last cycle, and in_advance bills it
                                    before it starts, on the activation invoice
                                    or on the closing invoice of the cycle
                                    before. The billing timing moves the
                                    invoice, never the amount.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - billingTiming
                              additionalProperties: false
                            - type: object
                              description: >-
                                A minimum commitment: the least that the plan
                                bills in a charge period. When the charges of
                                the plan with the same billing frequency total
                                less, the charge bills the difference. A plan
                                has at most one for each billing frequency.
                              properties:
                                category:
                                  type: string
                                  description: >-
                                    The category of the charge:
                                    minimum_commitment.
                                  enum:
                                    - minimum_commitment
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    fixed.
                                  enum:
                                    - fixed
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a fixed charge or of a minimum
                                    commitment.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: fixed.'
                                      enum:
                                        - fixed
                                    amount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The amount that the charge bills in each
                                        charge period, in cents, or the amount
                                        of one unit when the charge has a
                                        quantity. For a minimum commitment, the
                                        least that the charges of the plan with
                                        its billing frequency bill.
                                    quantity:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units that a fixed charge
                                        bills in each charge period, when it has
                                        one, so that each charge period bills
                                        quantity times amount. A minimum
                                        commitment has none.
                                  required:
                                    - model
                                    - amount
                                  additionalProperties: false
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                              additionalProperties: false
                            - type: object
                              description: >-
                                A usage-based charge: a charge on the usage of a
                                resource in its charge period, priced by its
                                pricing model.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: usage_based.'
                                  enum:
                                    - usage_based
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  enum:
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                  description: >-
                                    The pricing model of the charge, the same as
                                    pricing.model. per_unit, per_package and
                                    tiered_per_unit price a resource in units,
                                    percentage and tiered_percentage price a
                                    resource in money, and tiered_fixed and
                                    advanced price either.
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a usage-based or license-based
                                    charge, by pricing model. Its model is the
                                    pricingModel of the charge.
                                  discriminator:
                                    propertyName: model
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per unit: each unit of the charge period
                                        past the included quantity costs
                                        unitPrice. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_unit.
                                          enum:
                                            - per_unit
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit, as a decimal
                                            string.
                                          examples:
                                            - '0.25'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - unitPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per package: the units of the charge
                                        period past the included quantity bill
                                        packagePrice for each package of
                                        packageSize units that they start. A
                                        charge on a resource in money cannot
                                        have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_package.
                                          enum:
                                            - per_package
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: The number of units in one package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one package, as a decimal
                                            string.
                                          examples:
                                            - '50.00'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage: the charge bills a
                                        percentage of the usage of its resource
                                        in the charge period. Only a charge on a
                                        resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            percentage.
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage that the
                                            charge bills, as a decimal string from 0
                                            to 100.
                                          examples:
                                            - '2.5'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered per unit: the tiers of the charge
                                        price its units, and each tier prices
                                        them per unit. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_per_unit.
                                          enum:
                                            - tiered_per_unit
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered percentage: the tiers of the
                                        charge price its usage, and each tier
                                        bills a percentage of it. Only a charge
                                        on a resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_percentage.
                                          enum:
                                            - tiered_percentage
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered fixed: the tier that the whole
                                        quantity reaches bills its flat amount.
                                        When the last tier has an end,
                                        unitOverage or percentageOverage prices
                                        the quantity past it, and a charge never
                                        has both.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_fixed.
                                          enum:
                                            - tiered_fixed
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            Always volume, because the tier that the
                                            whole quantity reaches bills its flat
                                            amount.
                                        unitOverage:
                                          type: object
                                          description: >-
                                            The price of the units past the last
                                            tier, for a charge on a resource in
                                            units or on a license, when the charge
                                            has one.
                                          properties:
                                            excessUnitPrice:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                The price of one unit past the last
                                                tier, as a decimal string.
                                              examples:
                                                - '0.30'
                                          required:
                                            - excessUnitPrice
                                          additionalProperties: false
                                        percentageOverage:
                                          type: object
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, for a
                                            charge on a resource in money, when the
                                            charge has one.
                                          properties:
                                            excessPercentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                The percentage of the usage past the
                                                last tier that the charge bills, as a
                                                decimal string from 0 to 100.
                                              examples:
                                                - '1.5'
                                          required:
                                            - excessPercentage
                                          additionalProperties: false
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      not:
                                        required:
                                          - unitOverage
                                          - percentageOverage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Advanced: tiers of mixed types price the
                                        quantity. The tiers of a charge on a
                                        resource in units are per_unit,
                                        per_package or flat, and those of a
                                        charge on a resource in money are
                                        percentage or flat. A charge priced
                                        before the other pricing models existed
                                        has it too.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            advanced.
                                          enum:
                                            - advanced
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                resourceId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the resource whose
                                    usage the charge prices.
                                currencyUnit:
                                  type: object
                                  description: >-
                                    The currency unit that the charge is priced
                                    in, or null when the charge has none. A
                                    charge with no currency unit or in BRL, the
                                    default currency unit, bills money. A charge
                                    in any other currency unit, a credit unit,
                                    decreases the balance of a credit pool in
                                    that unit and bills no money.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the currency
                                        unit in our system.
                                    name:
                                      type: string
                                      description: The name of the currency unit.
                                      examples:
                                        - Real
                                    code:
                                      type: string
                                      description: The short code of the currency unit.
                                      examples:
                                        - BRL
                                  required:
                                    - id
                                    - name
                                    - code
                                  additionalProperties: false
                                  nullable: true
                                tiers:
                                  type: array
                                  items:
                                    type: object
                                    description: >-
                                      A price tier of the charge: a band of
                                      quantity, from one number to another, with
                                      its own price. The first tier starts at 0
                                      or 1, and each tier starts at the to of
                                      the tier before it plus 1.
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                        description: >-
                                          The unique identifier of the tier in our
                                          system.
                                      position:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The position of the tier in the charge,
                                          from 0, from the lowest band to the
                                          highest.
                                      from:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The first quantity of the band, which
                                          the band includes: a number of units of
                                          the resource or of the license, or of
                                          cents for a resource in money.
                                      to:
                                        type: integer
                                        minimum: 0
                                        nullable: true
                                        description: >-
                                          The last quantity of the band, which the
                                          band includes, in the unit of from, or
                                          null when the band has no end. The last
                                          tier has an end only on a charge with
                                          the pricing model tiered_fixed and an
                                          overage.
                                      pricing:
                                        type: object
                                        description: >-
                                          The price of the quantity that falls in
                                          the tier, by type: per_unit, percentage,
                                          per_package or flat.
                                        discriminator:
                                          propertyName: type
                                        oneOf:
                                          - type: object
                                            description: >-
                                              Per unit: each unit in the tier costs
                                              unitPrice. A charge on a resource in
                                              money cannot have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_unit.'
                                                enum:
                                                  - per_unit
                                              unitPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one unit in the tier, as a
                                                  decimal string.
                                                examples:
                                                  - '0.20'
                                              fixedPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                nullable: true
                                                description: >-
                                                  An amount that the tier bills on top of
                                                  its units when the tier applies, as a
                                                  decimal string, or null when it has
                                                  none. Only a tier of a charge with the
                                                  pricing model tiered_per_unit has an
                                                  amount other than zero.
                                                examples:
                                                  - '10.00'
                                            required:
                                              - type
                                              - unitPrice
                                              - fixedPrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Percentage: the tier bills a percentage
                                              of the usage that falls in it. Only a
                                              charge on a resource in money has it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: percentage.'
                                                enum:
                                                  - percentage
                                              percentage:
                                                type: string
                                                pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                description: >-
                                                  The percentage of the usage in the tier
                                                  that the tier bills, as a decimal string
                                                  from 0 to 100.
                                                examples:
                                                  - '1.5'
                                            required:
                                              - type
                                              - percentage
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Per package: the units in the tier bill
                                              packagePrice for each package of
                                              packageSize units that they start. A
                                              charge on a resource in money cannot
                                              have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_package.'
                                                enum:
                                                  - per_package
                                              packageSize:
                                                type: integer
                                                minimum: 1
                                                description: The number of units in one package.
                                              packagePrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one package, as a decimal
                                                  string.
                                                examples:
                                                  - '45.00'
                                            required:
                                              - type
                                              - packageSize
                                              - packagePrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Flat: the tier bills one amount,
                                              whatever the quantity that falls in it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: flat.'
                                                enum:
                                                  - flat
                                              amount:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The amount that the tier bills, as a
                                                  decimal string.
                                                examples:
                                                  - '199.90'
                                            required:
                                              - type
                                              - amount
                                            additionalProperties: false
                                    required:
                                      - id
                                      - position
                                      - from
                                      - to
                                      - pricing
                                    additionalProperties: false
                                  description: >-
                                    The price tiers of the charge, from the
                                    lowest band to the highest, for the pricing
                                    models tiered_per_unit, tiered_percentage,
                                    tiered_fixed and advanced, or an empty list
                                    for the other pricing models.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - resourceId
                                - currencyUnit
                                - tiers
                              additionalProperties: false
                            - type: object
                              description: >-
                                A license-based charge: a charge on the balance
                                of a license in its charge period, read by its
                                billing model and priced by its pricing model.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: license_based.'
                                  enum:
                                    - license_based
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  enum:
                                    - per_unit
                                    - per_package
                                    - tiered_per_unit
                                    - tiered_fixed
                                  description: >-
                                    The pricing model of the charge, the same as
                                    pricing.model: per_unit, per_package,
                                    tiered_per_unit or tiered_fixed. No
                                    percentage applies, because the balance of a
                                    license is a count, not an amount of money.
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a usage-based or license-based
                                    charge, by pricing model. Its model is the
                                    pricingModel of the charge.
                                  discriminator:
                                    propertyName: model
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per unit: each unit of the charge period
                                        past the included quantity costs
                                        unitPrice. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_unit.
                                          enum:
                                            - per_unit
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit, as a decimal
                                            string.
                                          examples:
                                            - '0.25'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - unitPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per package: the units of the charge
                                        period past the included quantity bill
                                        packagePrice for each package of
                                        packageSize units that they start. A
                                        charge on a resource in money cannot
                                        have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_package.
                                          enum:
                                            - per_package
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: The number of units in one package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one package, as a decimal
                                            string.
                                          examples:
                                            - '50.00'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage: the charge bills a
                                        percentage of the usage of its resource
                                        in the charge period. Only a charge on a
                                        resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            percentage.
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage that the
                                            charge bills, as a decimal string from 0
                                            to 100.
                                          examples:
                                            - '2.5'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered per unit: the tiers of the charge
                                        price its units, and each tier prices
                                        them per unit. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_per_unit.
                                          enum:
                                            - tiered_per_unit
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered percentage: the tiers of the
                                        charge price its usage, and each tier
                                        bills a percentage of it. Only a charge
                                        on a resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_percentage.
                                          enum:
                                            - tiered_percentage
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered fixed: the tier that the whole
                                        quantity reaches bills its flat amount.
                                        When the last tier has an end,
                                        unitOverage or percentageOverage prices
                                        the quantity past it, and a charge never
                                        has both.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_fixed.
                                          enum:
                                            - tiered_fixed
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            Always volume, because the tier that the
                                            whole quantity reaches bills its flat
                                            amount.
                                        unitOverage:
                                          type: object
                                          description: >-
                                            The price of the units past the last
                                            tier, for a charge on a resource in
                                            units or on a license, when the charge
                                            has one.
                                          properties:
                                            excessUnitPrice:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                The price of one unit past the last
                                                tier, as a decimal string.
                                              examples:
                                                - '0.30'
                                          required:
                                            - excessUnitPrice
                                          additionalProperties: false
                                        percentageOverage:
                                          type: object
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, for a
                                            charge on a resource in money, when the
                                            charge has one.
                                          properties:
                                            excessPercentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                The percentage of the usage past the
                                                last tier that the charge bills, as a
                                                decimal string from 0 to 100.
                                              examples:
                                                - '1.5'
                                          required:
                                            - excessPercentage
                                          additionalProperties: false
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      not:
                                        required:
                                          - unitOverage
                                          - percentageOverage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Advanced: tiers of mixed types price the
                                        quantity. The tiers of a charge on a
                                        resource in units are per_unit,
                                        per_package or flat, and those of a
                                        charge on a resource in money are
                                        percentage or flat. A charge priced
                                        before the other pricing models existed
                                        has it too.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            advanced.
                                          enum:
                                            - advanced
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                licenseId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the license whose
                                    balance the charge bills.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the charge reads the balance of its
                                    license in a charge period: in_full bills
                                    the last balance, and proration weighs each
                                    balance by the days that it was in effect.
                                tiers:
                                  type: array
                                  items:
                                    type: object
                                    description: >-
                                      A price tier of the charge: a band of
                                      quantity, from one number to another, with
                                      its own price. The first tier starts at 0
                                      or 1, and each tier starts at the to of
                                      the tier before it plus 1.
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                        description: >-
                                          The unique identifier of the tier in our
                                          system.
                                      position:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The position of the tier in the charge,
                                          from 0, from the lowest band to the
                                          highest.
                                      from:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The first quantity of the band, which
                                          the band includes: a number of units of
                                          the resource or of the license, or of
                                          cents for a resource in money.
                                      to:
                                        type: integer
                                        minimum: 0
                                        nullable: true
                                        description: >-
                                          The last quantity of the band, which the
                                          band includes, in the unit of from, or
                                          null when the band has no end. The last
                                          tier has an end only on a charge with
                                          the pricing model tiered_fixed and an
                                          overage.
                                      pricing:
                                        type: object
                                        description: >-
                                          The price of the quantity that falls in
                                          the tier, by type: per_unit, percentage,
                                          per_package or flat.
                                        discriminator:
                                          propertyName: type
                                        oneOf:
                                          - type: object
                                            description: >-
                                              Per unit: each unit in the tier costs
                                              unitPrice. A charge on a resource in
                                              money cannot have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_unit.'
                                                enum:
                                                  - per_unit
                                              unitPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one unit in the tier, as a
                                                  decimal string.
                                                examples:
                                                  - '0.20'
                                              fixedPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                nullable: true
                                                description: >-
                                                  An amount that the tier bills on top of
                                                  its units when the tier applies, as a
                                                  decimal string, or null when it has
                                                  none. Only a tier of a charge with the
                                                  pricing model tiered_per_unit has an
                                                  amount other than zero.
                                                examples:
                                                  - '10.00'
                                            required:
                                              - type
                                              - unitPrice
                                              - fixedPrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Percentage: the tier bills a percentage
                                              of the usage that falls in it. Only a
                                              charge on a resource in money has it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: percentage.'
                                                enum:
                                                  - percentage
                                              percentage:
                                                type: string
                                                pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                description: >-
                                                  The percentage of the usage in the tier
                                                  that the tier bills, as a decimal string
                                                  from 0 to 100.
                                                examples:
                                                  - '1.5'
                                            required:
                                              - type
                                              - percentage
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Per package: the units in the tier bill
                                              packagePrice for each package of
                                              packageSize units that they start. A
                                              charge on a resource in money cannot
                                              have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_package.'
                                                enum:
                                                  - per_package
                                              packageSize:
                                                type: integer
                                                minimum: 1
                                                description: The number of units in one package.
                                              packagePrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one package, as a decimal
                                                  string.
                                                examples:
                                                  - '45.00'
                                            required:
                                              - type
                                              - packageSize
                                              - packagePrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Flat: the tier bills one amount,
                                              whatever the quantity that falls in it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: flat.'
                                                enum:
                                                  - flat
                                              amount:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The amount that the tier bills, as a
                                                  decimal string.
                                                examples:
                                                  - '199.90'
                                            required:
                                              - type
                                              - amount
                                            additionalProperties: false
                                    required:
                                      - id
                                      - position
                                      - from
                                      - to
                                      - pricing
                                    additionalProperties: false
                                  description: >-
                                    The price tiers of the charge, from the
                                    lowest band to the highest, for the pricing
                                    models tiered_per_unit and tiered_fixed, or
                                    an empty list for the other pricing models.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - licenseId
                                - billingModel
                                - tiers
                              additionalProperties: false
                            - type: object
                              description: >-
                                A custom plan charge: a charge whose price comes
                                from code that Aira writes for you, from the
                                custom charge definition that the charge follows
                                and from the parameter values of the charge. It
                                bills in arrears, in money.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: custom.'
                                  enum:
                                    - custom
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    custom.
                                  enum:
                                    - custom
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a custom plan charge: the
                                    parameter values that the code that Aira
                                    writes for you turns into an amount.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: custom.'
                                      enum:
                                        - custom
                                    parameters:
                                      type: object
                                      additionalProperties: true
                                      description: >-
                                        The parameter values of the charge, by
                                        the keys of the parameter schema of its
                                        custom charge definition.
                                  required:
                                    - model
                                    - parameters
                                  additionalProperties: false
                                customChargeDefinitionId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the custom charge
                                    definition that the charge follows.
                                chosenResourceIds:
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                  description: >-
                                    The unique identifiers of the resources that
                                    the charge chose as its inputs, from the
                                    input resources of its custom charge
                                    definition.
                                chosenLicenseIds:
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                  description: >-
                                    The unique identifiers of the licenses that
                                    the charge chose as its inputs, from the
                                    input licenses of its custom charge
                                    definition.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - customChargeDefinitionId
                                - chosenResourceIds
                                - chosenLicenseIds
                              additionalProperties: false
                    required:
                      - id
                      - planInstanceId
                      - planVersionId
                      - versionNumber
                      - isActive
                      - planInstanceVersionReason
                      - metadata
                      - createdAt
                      - planCharges
                    additionalProperties: false
                required:
                  - id
                  - contractId
                  - planId
                  - activePlanInstanceVersionId
                  - activePlanVersionId
                  - activePlanInstanceVersionReason
                  - status
                  - plan
                  - activePlanInstanceVersion
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `currency_unit_not_found`: no currency unit has the
            `currencyUnitCode` of a usage-based charge.

            - `invalid_custom_fields`: `customFields` leaves out a required
            custom field of plan instance versions, has a key that no custom
            field of plan instance versions has, or has a value that its custom
            field does not accept.

            - `invalid_plan_charges`: `planCharges` is empty, or a plan charge
            breaks a rule of plan charges, such as tiers that leave a gap, an
            item, a resource or a license that does not exist, two minimum
            commitments with the same billing frequency, or billing frequencies
            in both months and weeks.

            - `billing_frequency_not_yet_supported`: a license-based charge with
            the billing model `proration`, or a usage-based charge on a resource
            with the billing model `proration`, has a billing frequency of more
            than one month or one week.

            - `invalid_proration_usage_scope`: `planCharges` has a usage-based
            charge on a resource with the billing model `proration`, and the
            usage scope of the contract of the plan instance has more than one
            customer.

            - `invalid_license_proration_allocation`: `planCharges` has a
            license-based charge with the billing model `proration`, and the
            contract of the plan instance splits its invoices by the share of
            the usage of each customer.

            - `mixed_billing_frequency_family`: the billing frequencies of
            `planCharges` are in weeks and the billing schedule of the contract
            of the plan instance repeats every month, or the reverse.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - currency_unit_not_found
                      - invalid_custom_fields
                      - invalid_plan_charges
                      - billing_frequency_not_yet_supported
                      - invalid_proration_usage_scope
                      - invalid_license_proration_allocation
                      - mixed_billing_frequency_family
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''planCharges'' is required'
                    code: json_schema_validation_error
                currency_unit_not_found:
                  value:
                    message: currency unit not found
                    code: currency_unit_not_found
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
                invalid_plan_charges:
                  value:
                    message: 'plan charge "{itemName}": {reason}'
                    code: invalid_plan_charges
                billing_frequency_not_yet_supported:
                  value:
                    message: >-
                      a license-based charge with the billing model `proration`,
                      or a usage-based charge on a resource with the billing
                      model `proration`, has a billing frequency of more than
                      one month or one week
                    code: billing_frequency_not_yet_supported
                invalid_proration_usage_scope:
                  value:
                    message: >-
                      proration metrics are not supported when billing cycle
                      usage scope has more than one customer
                    code: invalid_proration_usage_scope
                invalid_license_proration_allocation:
                  value:
                    message: >-
                      prorated license charges are not supported on contracts
                      that split invoices by subsidiary usage
                    code: invalid_license_proration_allocation
                mixed_billing_frequency_family:
                  value:
                    message: >-
                      the billing frequencies of `planCharges` are in weeks and
                      the billing schedule of the contract of the plan instance
                      repeats every month, or the reverse
                    code: mixed_billing_frequency_family
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plan_instances:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `plan_instance_not_found`: no plan instance has the `id`.
            - `plan_not_found`: the plan of the plan instance was deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_instance_not_found
                      - plan_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_instance_not_found:
                  value:
                    message: plan instance not found
                    code: plan_instance_not_found
                plan_not_found:
                  value:
                    message: plan "{planId}" not found
                    code: plan_not_found
    delete:
      summary: Delete plan instance
      tags:
        - Plan Instances
      description: >-
        Deletes a plan instance of a draft contract, together with its plan
        instance versions, so the contract no longer bills its plan. To stop
        billing a plan instance of an active contract, cancel it instead.


        Requires the role `plan_instances:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the plan instance in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: contract_must_be_draft
          when: the contract of the plan instance is not a draft
        - status: 404
          code: plan_instance_not_found
          when: no plan instance has the `id`
      x-required-roles: *ref_14
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `contract_must_be_draft`: the contract of the plan instance is not
            a draft.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - contract_must_be_draft
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                contract_must_be_draft:
                  value:
                    message: contract must be draft
                    code: contract_must_be_draft
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plan_instances:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `plan_instance_not_found`: no plan instance has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_instance_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_instance_not_found:
                  value:
                    message: plan instance not found
                    code: plan_instance_not_found
    get:
      summary: Fetch plan instance
      tags:
        - Plan Instances
      description: >-
        Fetches a plan instance by id, with its plan and the plan charges of its
        active plan instance version.


        Requires the role `plan_instances:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the plan instance in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: plan_instance_not_found
          when: no plan instance has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_15
      responses:
        '200':
          description: >-
            A plan instance: a plan put on one contract. It has its own
            versions, so the prices of one contract can change while the plan
            stays the same.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the plan instance in our system.
                  contractId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the contract the plan instance
                      belongs to.
                  planId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the plan this instance was
                      created from.
                  activePlanInstanceVersionId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the plan instance version
                      currently used for billing.
                  activePlanVersionId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the plan version the active plan
                      instance version derives from.
                  activePlanInstanceVersionReason:
                    type: string
                    enum:
                      - created_from_plan_version
                      - duplicated_from_contract
                      - manual_override
                      - readjustment
                      - rollback
                    description: >-
                      Why the active plan instance version exists:
                      created_from_plan_version (instantiated from the plan's
                      version), duplicated_from_contract (copied when the
                      contract was duplicated), manual_override (pricing
                      overridden manually or through the API), readjustment (a
                      percentage rate adjustment was applied), or rollback
                      (rolled back to a previous version).
                  status:
                    type: string
                    enum:
                      - active
                      - canceled
                      - completed
                    description: >-
                      Current status of the plan instance: active (billed on the
                      contract's cycles), canceled (interrupted before its end;
                      no longer billed), or completed (ran through its end).
                  plan:
                    type: object
                    description: >-
                      Base properties of the plan this instance was created
                      from.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the plan in our system.
                      name:
                        type: string
                        minLength: 1
                        description: The name of the plan.
                        example: Plano Essencial
                      description:
                        description: The description of the plan, or null when it has none.
                        type:
                          - 'null'
                          - string
                        example: Assinatura mensal com entrega diária de pães.
                      productId:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the product that the plan
                          belongs to.
                    required:
                      - id
                      - name
                      - description
                      - productId
                    additionalProperties: false
                  activePlanInstanceVersion:
                    type: object
                    description: >-
                      The plan instance version currently used for billing,
                      including its plan charges, without its custom field
                      values.
                    properties:
                      id:
                        description: >-
                          The unique identifier of the plan instance version in
                          our system.
                        type: string
                        format: uuid
                      planInstanceId:
                        description: >-
                          The unique identifier of the plan instance that the
                          version belongs to.
                        type: string
                        format: uuid
                      planVersionId:
                        description: >-
                          The unique identifier of the plan version that the
                          version comes from.
                        type: string
                        format: uuid
                      versionNumber:
                        description: >-
                          The number of the version in its plan instance, from
                          1, one more for each new version.
                        type: integer
                        minimum: 1
                      isActive:
                        description: >-
                          Whether billing uses this version. A plan instance has
                          one active version.
                        type: boolean
                      planInstanceVersionReason:
                        description: >-
                          Why the version exists: created_from_plan_version (it
                          comes from a plan version of the plan),
                          duplicated_from_contract (a copy of a plan instance of
                          another contract), manual_override (an update of the
                          charges of the plan instance), readjustment (a rate
                          adjustment) or rollback (a restore of an earlier
                          version).
                        type: string
                        enum:
                          - created_from_plan_version
                          - duplicated_from_contract
                          - manual_override
                          - readjustment
                          - rollback
                      metadata:
                        anyOf:
                          - type: object
                            description: >-
                              The details of a version that comes from a plan
                              version of the plan.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - created_from_plan_version
                                description: >-
                                  The reason of the version:
                                  created_from_plan_version.
                              sourcePlanVersionId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan version that
                                  the version comes from.
                            required:
                              - reason
                              - sourcePlanVersionId
                            additionalProperties: false
                          - type: object
                            description: >-
                              The details of a version that copies a plan
                              instance of another contract, from a duplication
                              of that contract.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - duplicated_from_contract
                                description: >-
                                  The reason of the version:
                                  duplicated_from_contract.
                              sourceContractId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the contract that the
                                  duplication copied.
                              sourcePlanInstanceId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan instance
                                  that the version copies.
                            required:
                              - reason
                              - sourceContractId
                              - sourcePlanInstanceId
                            additionalProperties: false
                          - type: object
                            description: >-
                              The details of a version from an update of the
                              charges of the plan instance, in the billing app
                              or through the API.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - manual_override
                                description: 'The reason of the version: manual_override.'
                              previousPlanInstanceVersionId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan instance
                                  version that was active before the update.
                            required:
                              - reason
                              - previousPlanInstanceVersionId
                            additionalProperties: false
                          - type: object
                            description: >-
                              The details of a version from a rate adjustment,
                              which applies a percentage to the prices of the
                              plan instance.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - readjustment
                                description: 'The reason of the version: readjustment.'
                              previousPlanInstanceVersionId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan instance
                                  version that was active before the rate
                                  adjustment.
                              percentage:
                                type: string
                                description: >-
                                  The percentage that the rate adjustment
                                  applied to the prices, as a decimal string,
                                  such as "5" for a rise of 5%.
                                examples:
                                  - '5'
                            required:
                              - reason
                              - previousPlanInstanceVersionId
                              - percentage
                            additionalProperties: false
                          - type: object
                            description: >-
                              The details of a version from a restore of an
                              earlier version.
                            properties:
                              reason:
                                type: string
                                enum:
                                  - rollback
                                description: 'The reason of the version: rollback.'
                              rolledBackFromPlanInstanceVersionId:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the plan instance
                                  version whose charges the restore brought
                                  back.
                            required:
                              - reason
                              - rolledBackFromPlanInstanceVersionId
                            additionalProperties: false
                          - type: 'null'
                            description: Aira recorded no details for the version.
                        description: >-
                          The details of how the version came to exist, by
                          reason, such as the plan version that it comes from,
                          the version before it or the percentage of a rate
                          adjustment, or null when Aira recorded none.
                      createdAt:
                        description: The moment when Aira created the version.
                        type: string
                        format: date-time
                      planCharges:
                        description: The plan charges of the version.
                        type: array
                        items:
                          type: object
                          description: >-
                            Schema representing a plan charge, one priced line
                            of a plan: its item names what it bills, its
                            category says what it bills from, its pricing model
                            turns a quantity into money, and its billing
                            frequency says how often it bills. The fields of a
                            charge depend on its category. An amount is an
                            integer number of cents, and a price is a decimal
                            string with up to 6 decimal places, in BRL or in the
                            credit unit of the charge.
                          discriminator:
                            propertyName: category
                          oneOf:
                            - type: object
                              description: >-
                                A fixed charge: the same amount in every charge
                                period, billed on the invoice that its billing
                                timing names.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: fixed.'
                                  enum:
                                    - fixed
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    fixed.
                                  enum:
                                    - fixed
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a fixed charge or of a minimum
                                    commitment.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: fixed.'
                                      enum:
                                        - fixed
                                    amount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The amount that the charge bills in each
                                        charge period, in cents, or the amount
                                        of one unit when the charge has a
                                        quantity. For a minimum commitment, the
                                        least that the charges of the plan with
                                        its billing frequency bill.
                                    quantity:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units that a fixed charge
                                        bills in each charge period, when it has
                                        one, so that each charge period bills
                                        quantity times amount. A minimum
                                        commitment has none.
                                  required:
                                    - model
                                    - amount
                                  additionalProperties: false
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    When the charge bills a charge period:
                                    in_arrears bills it on the closing invoice
                                    of its last cycle, and in_advance bills it
                                    before it starts, on the activation invoice
                                    or on the closing invoice of the cycle
                                    before. The billing timing moves the
                                    invoice, never the amount.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - billingTiming
                              additionalProperties: false
                            - type: object
                              description: >-
                                A minimum commitment: the least that the plan
                                bills in a charge period. When the charges of
                                the plan with the same billing frequency total
                                less, the charge bills the difference. A plan
                                has at most one for each billing frequency.
                              properties:
                                category:
                                  type: string
                                  description: >-
                                    The category of the charge:
                                    minimum_commitment.
                                  enum:
                                    - minimum_commitment
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    fixed.
                                  enum:
                                    - fixed
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a fixed charge or of a minimum
                                    commitment.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: fixed.'
                                      enum:
                                        - fixed
                                    amount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The amount that the charge bills in each
                                        charge period, in cents, or the amount
                                        of one unit when the charge has a
                                        quantity. For a minimum commitment, the
                                        least that the charges of the plan with
                                        its billing frequency bill.
                                    quantity:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units that a fixed charge
                                        bills in each charge period, when it has
                                        one, so that each charge period bills
                                        quantity times amount. A minimum
                                        commitment has none.
                                  required:
                                    - model
                                    - amount
                                  additionalProperties: false
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                              additionalProperties: false
                            - type: object
                              description: >-
                                A usage-based charge: a charge on the usage of a
                                resource in its charge period, priced by its
                                pricing model.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: usage_based.'
                                  enum:
                                    - usage_based
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  enum:
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                  description: >-
                                    The pricing model of the charge, the same as
                                    pricing.model. per_unit, per_package and
                                    tiered_per_unit price a resource in units,
                                    percentage and tiered_percentage price a
                                    resource in money, and tiered_fixed and
                                    advanced price either.
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a usage-based or license-based
                                    charge, by pricing model. Its model is the
                                    pricingModel of the charge.
                                  discriminator:
                                    propertyName: model
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per unit: each unit of the charge period
                                        past the included quantity costs
                                        unitPrice. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_unit.
                                          enum:
                                            - per_unit
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit, as a decimal
                                            string.
                                          examples:
                                            - '0.25'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - unitPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per package: the units of the charge
                                        period past the included quantity bill
                                        packagePrice for each package of
                                        packageSize units that they start. A
                                        charge on a resource in money cannot
                                        have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_package.
                                          enum:
                                            - per_package
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: The number of units in one package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one package, as a decimal
                                            string.
                                          examples:
                                            - '50.00'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage: the charge bills a
                                        percentage of the usage of its resource
                                        in the charge period. Only a charge on a
                                        resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            percentage.
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage that the
                                            charge bills, as a decimal string from 0
                                            to 100.
                                          examples:
                                            - '2.5'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered per unit: the tiers of the charge
                                        price its units, and each tier prices
                                        them per unit. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_per_unit.
                                          enum:
                                            - tiered_per_unit
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered percentage: the tiers of the
                                        charge price its usage, and each tier
                                        bills a percentage of it. Only a charge
                                        on a resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_percentage.
                                          enum:
                                            - tiered_percentage
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered fixed: the tier that the whole
                                        quantity reaches bills its flat amount.
                                        When the last tier has an end,
                                        unitOverage or percentageOverage prices
                                        the quantity past it, and a charge never
                                        has both.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_fixed.
                                          enum:
                                            - tiered_fixed
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            Always volume, because the tier that the
                                            whole quantity reaches bills its flat
                                            amount.
                                        unitOverage:
                                          type: object
                                          description: >-
                                            The price of the units past the last
                                            tier, for a charge on a resource in
                                            units or on a license, when the charge
                                            has one.
                                          properties:
                                            excessUnitPrice:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                The price of one unit past the last
                                                tier, as a decimal string.
                                              examples:
                                                - '0.30'
                                          required:
                                            - excessUnitPrice
                                          additionalProperties: false
                                        percentageOverage:
                                          type: object
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, for a
                                            charge on a resource in money, when the
                                            charge has one.
                                          properties:
                                            excessPercentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                The percentage of the usage past the
                                                last tier that the charge bills, as a
                                                decimal string from 0 to 100.
                                              examples:
                                                - '1.5'
                                          required:
                                            - excessPercentage
                                          additionalProperties: false
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      not:
                                        required:
                                          - unitOverage
                                          - percentageOverage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Advanced: tiers of mixed types price the
                                        quantity. The tiers of a charge on a
                                        resource in units are per_unit,
                                        per_package or flat, and those of a
                                        charge on a resource in money are
                                        percentage or flat. A charge priced
                                        before the other pricing models existed
                                        has it too.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            advanced.
                                          enum:
                                            - advanced
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                resourceId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the resource whose
                                    usage the charge prices.
                                currencyUnit:
                                  type: object
                                  description: >-
                                    The currency unit that the charge is priced
                                    in, or null when the charge has none. A
                                    charge with no currency unit or in BRL, the
                                    default currency unit, bills money. A charge
                                    in any other currency unit, a credit unit,
                                    decreases the balance of a credit pool in
                                    that unit and bills no money.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the currency
                                        unit in our system.
                                    name:
                                      type: string
                                      description: The name of the currency unit.
                                      examples:
                                        - Real
                                    code:
                                      type: string
                                      description: The short code of the currency unit.
                                      examples:
                                        - BRL
                                  required:
                                    - id
                                    - name
                                    - code
                                  additionalProperties: false
                                  nullable: true
                                tiers:
                                  type: array
                                  items:
                                    type: object
                                    description: >-
                                      A price tier of the charge: a band of
                                      quantity, from one number to another, with
                                      its own price. The first tier starts at 0
                                      or 1, and each tier starts at the to of
                                      the tier before it plus 1.
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                        description: >-
                                          The unique identifier of the tier in our
                                          system.
                                      position:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The position of the tier in the charge,
                                          from 0, from the lowest band to the
                                          highest.
                                      from:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The first quantity of the band, which
                                          the band includes: a number of units of
                                          the resource or of the license, or of
                                          cents for a resource in money.
                                      to:
                                        type: integer
                                        minimum: 0
                                        nullable: true
                                        description: >-
                                          The last quantity of the band, which the
                                          band includes, in the unit of from, or
                                          null when the band has no end. The last
                                          tier has an end only on a charge with
                                          the pricing model tiered_fixed and an
                                          overage.
                                      pricing:
                                        type: object
                                        description: >-
                                          The price of the quantity that falls in
                                          the tier, by type: per_unit, percentage,
                                          per_package or flat.
                                        discriminator:
                                          propertyName: type
                                        oneOf:
                                          - type: object
                                            description: >-
                                              Per unit: each unit in the tier costs
                                              unitPrice. A charge on a resource in
                                              money cannot have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_unit.'
                                                enum:
                                                  - per_unit
                                              unitPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one unit in the tier, as a
                                                  decimal string.
                                                examples:
                                                  - '0.20'
                                              fixedPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                nullable: true
                                                description: >-
                                                  An amount that the tier bills on top of
                                                  its units when the tier applies, as a
                                                  decimal string, or null when it has
                                                  none. Only a tier of a charge with the
                                                  pricing model tiered_per_unit has an
                                                  amount other than zero.
                                                examples:
                                                  - '10.00'
                                            required:
                                              - type
                                              - unitPrice
                                              - fixedPrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Percentage: the tier bills a percentage
                                              of the usage that falls in it. Only a
                                              charge on a resource in money has it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: percentage.'
                                                enum:
                                                  - percentage
                                              percentage:
                                                type: string
                                                pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                description: >-
                                                  The percentage of the usage in the tier
                                                  that the tier bills, as a decimal string
                                                  from 0 to 100.
                                                examples:
                                                  - '1.5'
                                            required:
                                              - type
                                              - percentage
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Per package: the units in the tier bill
                                              packagePrice for each package of
                                              packageSize units that they start. A
                                              charge on a resource in money cannot
                                              have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_package.'
                                                enum:
                                                  - per_package
                                              packageSize:
                                                type: integer
                                                minimum: 1
                                                description: The number of units in one package.
                                              packagePrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one package, as a decimal
                                                  string.
                                                examples:
                                                  - '45.00'
                                            required:
                                              - type
                                              - packageSize
                                              - packagePrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Flat: the tier bills one amount,
                                              whatever the quantity that falls in it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: flat.'
                                                enum:
                                                  - flat
                                              amount:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The amount that the tier bills, as a
                                                  decimal string.
                                                examples:
                                                  - '199.90'
                                            required:
                                              - type
                                              - amount
                                            additionalProperties: false
                                    required:
                                      - id
                                      - position
                                      - from
                                      - to
                                      - pricing
                                    additionalProperties: false
                                  description: >-
                                    The price tiers of the charge, from the
                                    lowest band to the highest, for the pricing
                                    models tiered_per_unit, tiered_percentage,
                                    tiered_fixed and advanced, or an empty list
                                    for the other pricing models.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - resourceId
                                - currencyUnit
                                - tiers
                              additionalProperties: false
                            - type: object
                              description: >-
                                A license-based charge: a charge on the balance
                                of a license in its charge period, read by its
                                billing model and priced by its pricing model.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: license_based.'
                                  enum:
                                    - license_based
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  enum:
                                    - per_unit
                                    - per_package
                                    - tiered_per_unit
                                    - tiered_fixed
                                  description: >-
                                    The pricing model of the charge, the same as
                                    pricing.model: per_unit, per_package,
                                    tiered_per_unit or tiered_fixed. No
                                    percentage applies, because the balance of a
                                    license is a count, not an amount of money.
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a usage-based or license-based
                                    charge, by pricing model. Its model is the
                                    pricingModel of the charge.
                                  discriminator:
                                    propertyName: model
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per unit: each unit of the charge period
                                        past the included quantity costs
                                        unitPrice. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_unit.
                                          enum:
                                            - per_unit
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit, as a decimal
                                            string.
                                          examples:
                                            - '0.25'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - unitPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per package: the units of the charge
                                        period past the included quantity bill
                                        packagePrice for each package of
                                        packageSize units that they start. A
                                        charge on a resource in money cannot
                                        have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_package.
                                          enum:
                                            - per_package
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: The number of units in one package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one package, as a decimal
                                            string.
                                          examples:
                                            - '50.00'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage: the charge bills a
                                        percentage of the usage of its resource
                                        in the charge period. Only a charge on a
                                        resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            percentage.
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage that the
                                            charge bills, as a decimal string from 0
                                            to 100.
                                          examples:
                                            - '2.5'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered per unit: the tiers of the charge
                                        price its units, and each tier prices
                                        them per unit. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_per_unit.
                                          enum:
                                            - tiered_per_unit
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered percentage: the tiers of the
                                        charge price its usage, and each tier
                                        bills a percentage of it. Only a charge
                                        on a resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_percentage.
                                          enum:
                                            - tiered_percentage
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered fixed: the tier that the whole
                                        quantity reaches bills its flat amount.
                                        When the last tier has an end,
                                        unitOverage or percentageOverage prices
                                        the quantity past it, and a charge never
                                        has both.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_fixed.
                                          enum:
                                            - tiered_fixed
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            Always volume, because the tier that the
                                            whole quantity reaches bills its flat
                                            amount.
                                        unitOverage:
                                          type: object
                                          description: >-
                                            The price of the units past the last
                                            tier, for a charge on a resource in
                                            units or on a license, when the charge
                                            has one.
                                          properties:
                                            excessUnitPrice:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                The price of one unit past the last
                                                tier, as a decimal string.
                                              examples:
                                                - '0.30'
                                          required:
                                            - excessUnitPrice
                                          additionalProperties: false
                                        percentageOverage:
                                          type: object
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, for a
                                            charge on a resource in money, when the
                                            charge has one.
                                          properties:
                                            excessPercentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                The percentage of the usage past the
                                                last tier that the charge bills, as a
                                                decimal string from 0 to 100.
                                              examples:
                                                - '1.5'
                                          required:
                                            - excessPercentage
                                          additionalProperties: false
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      not:
                                        required:
                                          - unitOverage
                                          - percentageOverage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Advanced: tiers of mixed types price the
                                        quantity. The tiers of a charge on a
                                        resource in units are per_unit,
                                        per_package or flat, and those of a
                                        charge on a resource in money are
                                        percentage or flat. A charge priced
                                        before the other pricing models existed
                                        has it too.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            advanced.
                                          enum:
                                            - advanced
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                licenseId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the license whose
                                    balance the charge bills.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the charge reads the balance of its
                                    license in a charge period: in_full bills
                                    the last balance, and proration weighs each
                                    balance by the days that it was in effect.
                                tiers:
                                  type: array
                                  items:
                                    type: object
                                    description: >-
                                      A price tier of the charge: a band of
                                      quantity, from one number to another, with
                                      its own price. The first tier starts at 0
                                      or 1, and each tier starts at the to of
                                      the tier before it plus 1.
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                        description: >-
                                          The unique identifier of the tier in our
                                          system.
                                      position:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The position of the tier in the charge,
                                          from 0, from the lowest band to the
                                          highest.
                                      from:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The first quantity of the band, which
                                          the band includes: a number of units of
                                          the resource or of the license, or of
                                          cents for a resource in money.
                                      to:
                                        type: integer
                                        minimum: 0
                                        nullable: true
                                        description: >-
                                          The last quantity of the band, which the
                                          band includes, in the unit of from, or
                                          null when the band has no end. The last
                                          tier has an end only on a charge with
                                          the pricing model tiered_fixed and an
                                          overage.
                                      pricing:
                                        type: object
                                        description: >-
                                          The price of the quantity that falls in
                                          the tier, by type: per_unit, percentage,
                                          per_package or flat.
                                        discriminator:
                                          propertyName: type
                                        oneOf:
                                          - type: object
                                            description: >-
                                              Per unit: each unit in the tier costs
                                              unitPrice. A charge on a resource in
                                              money cannot have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_unit.'
                                                enum:
                                                  - per_unit
                                              unitPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one unit in the tier, as a
                                                  decimal string.
                                                examples:
                                                  - '0.20'
                                              fixedPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                nullable: true
                                                description: >-
                                                  An amount that the tier bills on top of
                                                  its units when the tier applies, as a
                                                  decimal string, or null when it has
                                                  none. Only a tier of a charge with the
                                                  pricing model tiered_per_unit has an
                                                  amount other than zero.
                                                examples:
                                                  - '10.00'
                                            required:
                                              - type
                                              - unitPrice
                                              - fixedPrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Percentage: the tier bills a percentage
                                              of the usage that falls in it. Only a
                                              charge on a resource in money has it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: percentage.'
                                                enum:
                                                  - percentage
                                              percentage:
                                                type: string
                                                pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                description: >-
                                                  The percentage of the usage in the tier
                                                  that the tier bills, as a decimal string
                                                  from 0 to 100.
                                                examples:
                                                  - '1.5'
                                            required:
                                              - type
                                              - percentage
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Per package: the units in the tier bill
                                              packagePrice for each package of
                                              packageSize units that they start. A
                                              charge on a resource in money cannot
                                              have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_package.'
                                                enum:
                                                  - per_package
                                              packageSize:
                                                type: integer
                                                minimum: 1
                                                description: The number of units in one package.
                                              packagePrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one package, as a decimal
                                                  string.
                                                examples:
                                                  - '45.00'
                                            required:
                                              - type
                                              - packageSize
                                              - packagePrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Flat: the tier bills one amount,
                                              whatever the quantity that falls in it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: flat.'
                                                enum:
                                                  - flat
                                              amount:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The amount that the tier bills, as a
                                                  decimal string.
                                                examples:
                                                  - '199.90'
                                            required:
                                              - type
                                              - amount
                                            additionalProperties: false
                                    required:
                                      - id
                                      - position
                                      - from
                                      - to
                                      - pricing
                                    additionalProperties: false
                                  description: >-
                                    The price tiers of the charge, from the
                                    lowest band to the highest, for the pricing
                                    models tiered_per_unit and tiered_fixed, or
                                    an empty list for the other pricing models.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - licenseId
                                - billingModel
                                - tiers
                              additionalProperties: false
                            - type: object
                              description: >-
                                A custom plan charge: a charge whose price comes
                                from code that Aira writes for you, from the
                                custom charge definition that the charge follows
                                and from the parameter values of the charge. It
                                bills in arrears, in money.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: custom.'
                                  enum:
                                    - custom
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    custom.
                                  enum:
                                    - custom
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a custom plan charge: the
                                    parameter values that the code that Aira
                                    writes for you turns into an amount.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: custom.'
                                      enum:
                                        - custom
                                    parameters:
                                      type: object
                                      additionalProperties: true
                                      description: >-
                                        The parameter values of the charge, by
                                        the keys of the parameter schema of its
                                        custom charge definition.
                                  required:
                                    - model
                                    - parameters
                                  additionalProperties: false
                                customChargeDefinitionId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the custom charge
                                    definition that the charge follows.
                                chosenResourceIds:
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                  description: >-
                                    The unique identifiers of the resources that
                                    the charge chose as its inputs, from the
                                    input resources of its custom charge
                                    definition.
                                chosenLicenseIds:
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                  description: >-
                                    The unique identifiers of the licenses that
                                    the charge chose as its inputs, from the
                                    input licenses of its custom charge
                                    definition.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - customChargeDefinitionId
                                - chosenResourceIds
                                - chosenLicenseIds
                              additionalProperties: false
                    required:
                      - id
                      - planInstanceId
                      - planVersionId
                      - versionNumber
                      - isActive
                      - planInstanceVersionReason
                      - metadata
                      - createdAt
                      - planCharges
                    additionalProperties: false
                required:
                  - id
                  - contractId
                  - planId
                  - activePlanInstanceVersionId
                  - activePlanVersionId
                  - activePlanInstanceVersionReason
                  - status
                  - plan
                  - activePlanInstanceVersion
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plan_instances:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `plan_instance_not_found`: no plan instance has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_instance_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_instance_not_found:
                  value:
                    message: plan instance not found
                    code: plan_instance_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/plan-instances/{id}/cancel:
    post:
      summary: Cancel plan instance
      tags:
        - Plan Instances
      description: >-
        Cancels an active plan instance of an active contract. The plan instance
        moves to canceled at once: every calculation of the contract's billing
        cycles from then on leaves it out, including the cycle that is open at
        the cancel, and an issued invoice does not change. The cancel is final.


        Requires the role `plan_instances:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the plan instance in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: contract_must_be_active
          when: the contract of the plan instance is not active
        - status: 400
          code: plan_instance_not_active
          when: the plan instance is not active
        - status: 404
          code: plan_instance_not_found
          when: no plan instance has the `id`
      x-required-roles: *ref_14
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `contract_must_be_active`: the contract of the plan instance is
            not active.

            - `plan_instance_not_active`: the plan instance is not active.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - contract_must_be_active
                      - plan_instance_not_active
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                contract_must_be_active:
                  value:
                    message: contract must be active
                    code: contract_must_be_active
                plan_instance_not_active:
                  value:
                    message: plan instance must be active
                    code: plan_instance_not_active
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plan_instances:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `plan_instance_not_found`: no plan instance has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_instance_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_instance_not_found:
                  value:
                    message: plan instance not found
                    code: plan_instance_not_found
  /v1/plan-instances/rate-adjust:
    post:
      summary: Apply rate adjustment to plan instances
      tags:
        - Plan Instances
      description: >-
        Applies a rate adjustment to each plan instance of the body: the prices
        of its plan charges rise by the percentage, and a new plan instance
        version, with the reason readjustment, becomes its active plan instance
        version. The request applies all the rate adjustments or none, and a
        plan instance without plan charges stays as it is. With the header
        `x-override-rate-adjustment-check` set to true, the request also adjusts
        a plan instance that had a rate adjustment in the last 30 days.


        Requires the role `plan_instances:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: array
              items:
                type: object
                description: The rate adjustment of one plan instance.
                properties:
                  planInstanceId:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the plan instance whose prices
                      the rate adjustment raises.
                  percentage:
                    type: string
                    pattern: ^\d+(\.\d{1,6})?$
                    description: >-
                      The percentage that the rate adjustment adds to the prices
                      of the plan instance, as a decimal of zero or more with at
                      most six decimal places, such as "5" for a raise of 5%. A
                      percentage of zero leaves the plan instance as it is.
                    example: '5'
                required:
                  - planInstanceId
                  - percentage
                additionalProperties: false
              maxItems: 10000
        description: >-
          The rate adjustments to apply, one for each plan instance, at most
          10,000.
      parameters:
        - schema:
            type: boolean
          in: header
          name: x-override-rate-adjustment-check
          required: false
          description: >-
            When true, the request also adjusts a plan instance that had a rate
            adjustment in the last 30 days, which it refuses otherwise.
      x-public-api: true
      x-errors:
        - status: 400
          code: plan_instance_rate_adjustment_recently_applied
          when: >-
            a plan instance of the body had a rate adjustment in the last 30
            days and the header `x-override-rate-adjustment-check` is not true,
            and `details.readjustments` lists those rate adjustments
        - status: 400
          code: invalid_plan_charges
          when: >-
            a plan charge of a plan instance of the body breaks a rule of plan
            charges that is newer than the plan charge, such as a billing
            frequency other than 1 or 2 weeks or 1, 3, 6 or 12 months
        - status: 404
          code: plan_instance_not_found
          when: no plan instance has a `planInstanceId` of the body
        - status: 404
          code: plan_instance_version_not_found
          when: >-
            the active plan instance version of a plan instance of the body has
            the plan charges of a plan version whose plan was deleted
      x-required-roles: *ref_14
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `plan_instance_rate_adjustment_recently_applied`: a plan instance
            of the body had a rate adjustment in the last 30 days and the header
            `x-override-rate-adjustment-check` is not true, and
            `details.readjustments` lists those rate adjustments.

            - `invalid_plan_charges`: a plan charge of a plan instance of the
            body breaks a rule of plan charges that is newer than the plan
            charge, such as a billing frequency other than 1 or 2 weeks or 1, 3,
            6 or 12 months.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - plan_instance_rate_adjustment_recently_applied
                      - invalid_plan_charges
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: body must be object
                    code: json_schema_validation_error
                plan_instance_rate_adjustment_recently_applied:
                  value:
                    message: Plan instance already rate adjusted in the last 30 days
                    code: plan_instance_rate_adjustment_recently_applied
                invalid_plan_charges:
                  value:
                    message: 'plan charge "{itemName}": {reason}'
                    code: invalid_plan_charges
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plan_instances:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `plan_instance_not_found`: no plan instance has a `planInstanceId`
            of the body.

            - `plan_instance_version_not_found`: the active plan instance
            version of a plan instance of the body has the plan charges of a
            plan version whose plan was deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_instance_not_found
                      - plan_instance_version_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_instance_not_found:
                  value:
                    message: plan instance not found
                    code: plan_instance_not_found
                plan_instance_version_not_found:
                  value:
                    message: plan instance version not found
                    code: plan_instance_version_not_found
  /v1/plan-instances/update-to-latest-plan-version:
    post:
      summary: Update plan instances to latest plan version
      tags:
        - Plan Instances
      description: >-
        Moves each plan instance of the body to the active plan version of its
        plan: a new plan instance version, with the plan charges of that plan
        version and the reason created_from_plan_version, becomes its active
        plan instance version. A plan instance whose active plan instance
        version already comes from that plan version, with that reason, stays as
        it is. The request updates all the plan instances or none, and answers
        each plan instance that it selected.


        Requires the role `plan_instances:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                includePlanInstanceIds:
                  description: >-
                    The unique identifiers of the plan instances to update, at
                    most 10,000. Each plan instance must be active.
                  type: array
                  items:
                    type: string
                    format: uuid
                  minItems: 1
                  maxItems: 10000
                  uniqueItems: true
                excludePlanInstanceIds:
                  description: >-
                    The unique identifiers of the plan instances to leave as
                    they are, at most 10,000.
                  type: array
                  items:
                    type: string
                    format: uuid
                  maxItems: 10000
                  uniqueItems: true
                selectAll:
                  description: >-
                    When true, the request updates the active plan instances of
                    the plan of `selectFilters`, at most 10,000, in place of the
                    ones of `includePlanInstanceIds`.
                  type: boolean
                selectFilters:
                  description: >-
                    The plan whose active plan instances the request updates
                    when `selectAll` is true.
                  type: object
                  properties:
                    planId:
                      description: The unique identifier of the plan.
                      type: string
                      format: uuid
                  required:
                    - planId
                  additionalProperties: false
              anyOf:
                - required:
                    - includePlanInstanceIds
                - required:
                    - selectAll
                    - selectFilters
              additionalProperties: false
        description: >-
          The plan instances to update: the ones of `includePlanInstanceIds`, or
          the active plan instances of the plan of `selectFilters` when
          `selectAll` is true.
      x-public-api: true
      x-errors:
        - status: 400
          code: missing_plan_instance_ids
          when: '`selectAll` is false and the body has no `includePlanInstanceIds`'
        - status: 400
          code: plan_instance_not_active
          when: a plan instance of `includePlanInstanceIds` is completed or canceled
        - status: 400
          code: invalid_proration_usage_scope
          when: >-
            the active plan version of the plan of a plan instance has a
            usage-based charge on a resource with the billing model `proration`,
            and the usage scope of the contract of the plan instance has more
            than one customer
        - status: 400
          code: invalid_license_proration_allocation
          when: >-
            the active plan version of the plan of a plan instance has a
            license-based charge with the billing model `proration`, and the
            contract of the plan instance splits its invoices by the share of
            the usage of each customer
        - status: 400
          code: mixed_billing_frequency_family
          when: >-
            the billing frequencies of the plan charges of the active plan
            version of the plan of a plan instance are in weeks and the billing
            schedule of the contract of the plan instance repeats every month,
            or the reverse
        - status: 404
          code: plan_instance_not_found
          when: >-
            no plan instance has an id of `includePlanInstanceIds`, or
            `excludePlanInstanceIds` also lists it
      x-required-roles: *ref_14
      responses:
        '200':
          description: >-
            The plan instances that the request selected, as they are after the
            update.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a plan instance, a plan put on one
                        contract, without the charges of its active plan
                        instance version. Fetch the plan instance by id to read
                        its charges.
                      properties:
                        id:
                          description: >-
                            The unique identifier of the plan instance in our
                            system.
                          type: string
                          format: uuid
                        contractId:
                          description: >-
                            The unique identifier of the contract that the plan
                            instance belongs to.
                          type: string
                          format: uuid
                        planId:
                          description: >-
                            The unique identifier of the plan that the plan
                            instance comes from.
                          type: string
                          format: uuid
                        status:
                          description: >-
                            The status of the plan instance: active (billed in
                            the cycles of the contract), completed (reached its
                            end) or canceled (stopped before its end).
                          type: string
                          enum:
                            - active
                            - canceled
                            - completed
                        activePlanInstanceVersionId:
                          description: >-
                            The unique identifier of the plan instance version
                            that billing uses.
                          type: string
                          format: uuid
                        activePlanVersionId:
                          description: >-
                            The unique identifier of the plan version that the
                            active plan instance version comes from.
                          type: string
                          format: uuid
                        activePlanInstanceVersionReason:
                          description: >-
                            Why the active plan instance version exists:
                            created_from_plan_version (it comes from a plan
                            version of the plan), duplicated_from_contract (a
                            copy of a plan instance of another contract),
                            manual_override (an update of the charges of the
                            plan instance), readjustment (a rate adjustment) or
                            rollback (a restore of an earlier version).
                          type: string
                          enum:
                            - created_from_plan_version
                            - duplicated_from_contract
                            - manual_override
                            - readjustment
                            - rollback
                        plan:
                          description: The plan that the plan instance comes from.
                          type: object
                          properties:
                            id:
                              description: The unique identifier of the plan.
                              type: string
                              format: uuid
                            name:
                              description: The name of the plan.
                              type: string
                              example: Plano Essencial
                            description:
                              description: >-
                                The description of the plan, or null when it has
                                none.
                              type:
                                - 'null'
                                - string
                              example: Assinatura mensal com entrega diária de pães.
                            productId:
                              description: >-
                                The unique identifier of the product that the
                                plan belongs to.
                              type: string
                              format: uuid
                          required:
                            - id
                            - name
                            - description
                            - productId
                          additionalProperties: false
                      required:
                        - id
                        - contractId
                        - planId
                        - status
                        - activePlanInstanceVersionId
                        - activePlanVersionId
                        - activePlanInstanceVersionReason
                        - plan
                      additionalProperties: false
                    description: A list of items.
                required:
                  - items
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `missing_plan_instance_ids`: `selectAll` is false and the body has
            no `includePlanInstanceIds`.

            - `plan_instance_not_active`: a plan instance of
            `includePlanInstanceIds` is completed or canceled.

            - `invalid_proration_usage_scope`: the active plan version of the
            plan of a plan instance has a usage-based charge on a resource with
            the billing model `proration`, and the usage scope of the contract
            of the plan instance has more than one customer.

            - `invalid_license_proration_allocation`: the active plan version of
            the plan of a plan instance has a license-based charge with the
            billing model `proration`, and the contract of the plan instance
            splits its invoices by the share of the usage of each customer.

            - `mixed_billing_frequency_family`: the billing frequencies of the
            plan charges of the active plan version of the plan of a plan
            instance are in weeks and the billing schedule of the contract of
            the plan instance repeats every month, or the reverse.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - missing_plan_instance_ids
                      - plan_instance_not_active
                      - invalid_proration_usage_scope
                      - invalid_license_proration_allocation
                      - mixed_billing_frequency_family
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: body must be object
                    code: json_schema_validation_error
                missing_plan_instance_ids:
                  value:
                    message: Either selectAll or planInstanceIds must be provided
                    code: missing_plan_instance_ids
                plan_instance_not_active:
                  value:
                    message: plan instance must be active
                    code: plan_instance_not_active
                invalid_proration_usage_scope:
                  value:
                    message: >-
                      proration metrics are not supported when billing cycle
                      usage scope has more than one customer
                    code: invalid_proration_usage_scope
                invalid_license_proration_allocation:
                  value:
                    message: >-
                      prorated license charges are not supported on contracts
                      that split invoices by subsidiary usage
                    code: invalid_license_proration_allocation
                mixed_billing_frequency_family:
                  value:
                    message: >-
                      the billing frequencies of the plan charges of the active
                      plan version of the plan of a plan instance are in weeks
                      and the billing schedule of the contract of the plan
                      instance repeats every month, or the reverse
                    code: mixed_billing_frequency_family
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plan_instances:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `plan_instance_not_found`: no plan instance has an id of
            `includePlanInstanceIds`, or `excludePlanInstanceIds` also lists it.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_instance_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_instance_not_found:
                  value:
                    message: plan instance not found
                    code: plan_instance_not_found
  /v1/plan-instance-versions/:
    get:
      summary: List plan instance versions
      tags:
        - Plan Instances
      description: >-
        Lists the versions of a plan instance, newest first, without their
        charges. A plan instance that does not exist answers an empty list.


        Requires the role `plan_instance_versions:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: query
          name: planInstanceId
          required: true
          description: >-
            The unique identifier of the plan instance whose versions the
            request lists.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: &ref_16
        - plan_instance_versions:read
      responses:
        '200':
          description: The versions of the plan instance, newest first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a plan instance version in a list,
                        without its charges and its custom field values. Fetch
                        the plan instance version by id to read them.
                      properties:
                        id:
                          description: >-
                            The unique identifier of the plan instance version
                            in our system.
                          type: string
                          format: uuid
                        versionNumber:
                          description: >-
                            The number of the version in its plan instance, from
                            1, one more for each new version.
                          type: integer
                          minimum: 1
                        isActive:
                          description: >-
                            Whether billing uses this version. A plan instance
                            has one active version.
                          type: boolean
                        planInstanceVersionReason:
                          description: >-
                            Why the version exists: created_from_plan_version
                            (it comes from a plan version of the plan),
                            duplicated_from_contract (a copy of a plan instance
                            of another contract), manual_override (an update of
                            the charges of the plan instance), readjustment (a
                            rate adjustment) or rollback (a restore of an
                            earlier version).
                          type: string
                          enum:
                            - created_from_plan_version
                            - duplicated_from_contract
                            - manual_override
                            - readjustment
                            - rollback
                        metadata:
                          anyOf:
                            - type: object
                              description: >-
                                The details of a version that comes from a plan
                                version of the plan.
                              properties:
                                reason:
                                  type: string
                                  enum:
                                    - created_from_plan_version
                                  description: >-
                                    The reason of the version:
                                    created_from_plan_version.
                                sourcePlanVersionId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan version
                                    that the version comes from.
                              required:
                                - reason
                                - sourcePlanVersionId
                              additionalProperties: false
                            - type: object
                              description: >-
                                The details of a version that copies a plan
                                instance of another contract, from a duplication
                                of that contract.
                              properties:
                                reason:
                                  type: string
                                  enum:
                                    - duplicated_from_contract
                                  description: >-
                                    The reason of the version:
                                    duplicated_from_contract.
                                sourceContractId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the contract that
                                    the duplication copied.
                                sourcePlanInstanceId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan instance
                                    that the version copies.
                              required:
                                - reason
                                - sourceContractId
                                - sourcePlanInstanceId
                              additionalProperties: false
                            - type: object
                              description: >-
                                The details of a version from an update of the
                                charges of the plan instance, in the billing app
                                or through the API.
                              properties:
                                reason:
                                  type: string
                                  enum:
                                    - manual_override
                                  description: 'The reason of the version: manual_override.'
                                previousPlanInstanceVersionId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan instance
                                    version that was active before the update.
                              required:
                                - reason
                                - previousPlanInstanceVersionId
                              additionalProperties: false
                            - type: object
                              description: >-
                                The details of a version from a rate adjustment,
                                which applies a percentage to the prices of the
                                plan instance.
                              properties:
                                reason:
                                  type: string
                                  enum:
                                    - readjustment
                                  description: 'The reason of the version: readjustment.'
                                previousPlanInstanceVersionId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan instance
                                    version that was active before the rate
                                    adjustment.
                                percentage:
                                  type: string
                                  description: >-
                                    The percentage that the rate adjustment
                                    applied to the prices, as a decimal string,
                                    such as "5" for a rise of 5%.
                                  examples:
                                    - '5'
                              required:
                                - reason
                                - previousPlanInstanceVersionId
                                - percentage
                              additionalProperties: false
                            - type: object
                              description: >-
                                The details of a version from a restore of an
                                earlier version.
                              properties:
                                reason:
                                  type: string
                                  enum:
                                    - rollback
                                  description: 'The reason of the version: rollback.'
                                rolledBackFromPlanInstanceVersionId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan instance
                                    version whose charges the restore brought
                                    back.
                              required:
                                - reason
                                - rolledBackFromPlanInstanceVersionId
                              additionalProperties: false
                            - type: 'null'
                              description: Aira recorded no details for the version.
                          description: >-
                            The details of how the version came to exist, by
                            reason, such as the plan version that it comes from,
                            the version before it or the percentage of a rate
                            adjustment, or null when Aira recorded none.
                        createdAt:
                          description: The moment when Aira created the version.
                          type: string
                          format: date-time
                      required:
                        - id
                        - versionNumber
                        - isActive
                        - planInstanceVersionReason
                        - metadata
                        - createdAt
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''planInstanceId'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plan_instance_versions:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/plan-instance-versions/{id}:
    get:
      summary: Fetch plan instance version
      tags:
        - Plan Instances
      description: >-
        Fetches a plan instance version by id, with its plan charges and the
        custom field values that it was created with.


        Requires the role `plan_instance_versions:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the plan instance version in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: plan_instance_version_not_found
          when: no plan instance version has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_16
      responses:
        '200':
          description: >-
            Schema representing a plan instance version, one state of the
            charges of a plan instance. Each change of the charges creates a
            version: the active version is the one that billing uses, and a
            restore can bring back any of the others.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: >-
                      The unique identifier of the plan instance version in our
                      system.
                    type: string
                    format: uuid
                  planInstanceId:
                    description: >-
                      The unique identifier of the plan instance that the
                      version belongs to.
                    type: string
                    format: uuid
                  planVersionId:
                    description: >-
                      The unique identifier of the plan version that the version
                      comes from.
                    type: string
                    format: uuid
                  versionNumber:
                    description: >-
                      The number of the version in its plan instance, from 1,
                      one more for each new version.
                    type: integer
                    minimum: 1
                  isActive:
                    description: >-
                      Whether billing uses this version. A plan instance has one
                      active version.
                    type: boolean
                  planInstanceVersionReason:
                    description: >-
                      Why the version exists: created_from_plan_version (it
                      comes from a plan version of the plan),
                      duplicated_from_contract (a copy of a plan instance of
                      another contract), manual_override (an update of the
                      charges of the plan instance), readjustment (a rate
                      adjustment) or rollback (a restore of an earlier version).
                    type: string
                    enum:
                      - created_from_plan_version
                      - duplicated_from_contract
                      - manual_override
                      - readjustment
                      - rollback
                  metadata:
                    anyOf:
                      - type: object
                        description: >-
                          The details of a version that comes from a plan
                          version of the plan.
                        properties:
                          reason:
                            type: string
                            enum:
                              - created_from_plan_version
                            description: >-
                              The reason of the version:
                              created_from_plan_version.
                          sourcePlanVersionId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the plan version that the
                              version comes from.
                        required:
                          - reason
                          - sourcePlanVersionId
                        additionalProperties: false
                      - type: object
                        description: >-
                          The details of a version that copies a plan instance
                          of another contract, from a duplication of that
                          contract.
                        properties:
                          reason:
                            type: string
                            enum:
                              - duplicated_from_contract
                            description: >-
                              The reason of the version:
                              duplicated_from_contract.
                          sourceContractId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the contract that the
                              duplication copied.
                          sourcePlanInstanceId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the plan instance that
                              the version copies.
                        required:
                          - reason
                          - sourceContractId
                          - sourcePlanInstanceId
                        additionalProperties: false
                      - type: object
                        description: >-
                          The details of a version from an update of the charges
                          of the plan instance, in the billing app or through
                          the API.
                        properties:
                          reason:
                            type: string
                            enum:
                              - manual_override
                            description: 'The reason of the version: manual_override.'
                          previousPlanInstanceVersionId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the plan instance version
                              that was active before the update.
                        required:
                          - reason
                          - previousPlanInstanceVersionId
                        additionalProperties: false
                      - type: object
                        description: >-
                          The details of a version from a rate adjustment, which
                          applies a percentage to the prices of the plan
                          instance.
                        properties:
                          reason:
                            type: string
                            enum:
                              - readjustment
                            description: 'The reason of the version: readjustment.'
                          previousPlanInstanceVersionId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the plan instance version
                              that was active before the rate adjustment.
                          percentage:
                            type: string
                            description: >-
                              The percentage that the rate adjustment applied to
                              the prices, as a decimal string, such as "5" for a
                              rise of 5%.
                            examples:
                              - '5'
                        required:
                          - reason
                          - previousPlanInstanceVersionId
                          - percentage
                        additionalProperties: false
                      - type: object
                        description: >-
                          The details of a version from a restore of an earlier
                          version.
                        properties:
                          reason:
                            type: string
                            enum:
                              - rollback
                            description: 'The reason of the version: rollback.'
                          rolledBackFromPlanInstanceVersionId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the plan instance version
                              whose charges the restore brought back.
                        required:
                          - reason
                          - rolledBackFromPlanInstanceVersionId
                        additionalProperties: false
                      - type: 'null'
                        description: Aira recorded no details for the version.
                    description: >-
                      The details of how the version came to exist, by reason,
                      such as the plan version that it comes from, the version
                      before it or the percentage of a rate adjustment, or null
                      when Aira recorded none.
                  customFields:
                    type: object
                    description: >-
                      The custom field values that the version was created with.
                      An update of the plan instance sets them, and every other
                      way of creating a version leaves them empty.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  createdAt:
                    description: The moment when Aira created the version.
                    type: string
                    format: date-time
                  planCharges:
                    description: The plan charges of the version.
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a plan charge, one priced line of a
                        plan: its item names what it bills, its category says
                        what it bills from, its pricing model turns a quantity
                        into money, and its billing frequency says how often it
                        bills. The fields of a charge depend on its category. An
                        amount is an integer number of cents, and a price is a
                        decimal string with up to 6 decimal places, in BRL or in
                        the credit unit of the charge.
                      discriminator:
                        propertyName: category
                      oneOf:
                        - type: object
                          description: >-
                            A fixed charge: the same amount in every charge
                            period, billed on the invoice that its billing
                            timing names.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: fixed.'
                              enum:
                                - fixed
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              description: The pricing model of the charge, always fixed.
                              enum:
                                - fixed
                            pricing:
                              type: object
                              description: >-
                                The price of a fixed charge or of a minimum
                                commitment.
                              properties:
                                model:
                                  description: 'The pricing model of the price: fixed.'
                                  enum:
                                    - fixed
                                amount:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The amount that the charge bills in each
                                    charge period, in cents, or the amount of
                                    one unit when the charge has a quantity. For
                                    a minimum commitment, the least that the
                                    charges of the plan with its billing
                                    frequency bill.
                                quantity:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units that a fixed charge
                                    bills in each charge period, when it has
                                    one, so that each charge period bills
                                    quantity times amount. A minimum commitment
                                    has none.
                              required:
                                - model
                                - amount
                              additionalProperties: false
                            billingTiming:
                              type: string
                              enum:
                                - in_advance
                                - in_arrears
                              description: >-
                                When the charge bills a charge period:
                                in_arrears bills it on the closing invoice of
                                its last cycle, and in_advance bills it before
                                it starts, on the activation invoice or on the
                                closing invoice of the cycle before. The billing
                                timing moves the invoice, never the amount.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - billingTiming
                          additionalProperties: false
                        - type: object
                          description: >-
                            A minimum commitment: the least that the plan bills
                            in a charge period. When the charges of the plan
                            with the same billing frequency total less, the
                            charge bills the difference. A plan has at most one
                            for each billing frequency.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: minimum_commitment.'
                              enum:
                                - minimum_commitment
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              description: The pricing model of the charge, always fixed.
                              enum:
                                - fixed
                            pricing:
                              type: object
                              description: >-
                                The price of a fixed charge or of a minimum
                                commitment.
                              properties:
                                model:
                                  description: 'The pricing model of the price: fixed.'
                                  enum:
                                    - fixed
                                amount:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The amount that the charge bills in each
                                    charge period, in cents, or the amount of
                                    one unit when the charge has a quantity. For
                                    a minimum commitment, the least that the
                                    charges of the plan with its billing
                                    frequency bill.
                                quantity:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units that a fixed charge
                                    bills in each charge period, when it has
                                    one, so that each charge period bills
                                    quantity times amount. A minimum commitment
                                    has none.
                              required:
                                - model
                                - amount
                              additionalProperties: false
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                          additionalProperties: false
                        - type: object
                          description: >-
                            A usage-based charge: a charge on the usage of a
                            resource in its charge period, priced by its pricing
                            model.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: usage_based.'
                              enum:
                                - usage_based
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              enum:
                                - per_unit
                                - per_package
                                - percentage
                                - tiered_per_unit
                                - tiered_percentage
                                - tiered_fixed
                                - advanced
                              description: >-
                                The pricing model of the charge, the same as
                                pricing.model. per_unit, per_package and
                                tiered_per_unit price a resource in units,
                                percentage and tiered_percentage price a
                                resource in money, and tiered_fixed and advanced
                                price either.
                            pricing:
                              type: object
                              description: >-
                                The price of a usage-based or license-based
                                charge, by pricing model. Its model is the
                                pricingModel of the charge.
                              discriminator:
                                propertyName: model
                              oneOf:
                                - type: object
                                  description: >-
                                    Per unit: each unit of the charge period
                                    past the included quantity costs unitPrice.
                                    A charge on a resource in money cannot have
                                    it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_unit.
                                      enum:
                                        - per_unit
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    unitPrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one unit, as a decimal
                                        string.
                                      examples:
                                        - '0.25'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - unitPrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Per package: the units of the charge period
                                    past the included quantity bill packagePrice
                                    for each package of packageSize units that
                                    they start. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_package.
                                      enum:
                                        - per_package
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    packageSize:
                                      type: integer
                                      minimum: 1
                                      description: The number of units in one package.
                                    packagePrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one package, as a decimal
                                        string.
                                      examples:
                                        - '50.00'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - packageSize
                                    - packagePrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Percentage: the charge bills a percentage of
                                    the usage of its resource in the charge
                                    period. Only a charge on a resource in money
                                    has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        percentage.
                                      enum:
                                        - percentage
                                    percentage:
                                      type: string
                                      pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                      description: >-
                                        The percentage of the usage that the
                                        charge bills, as a decimal string from 0
                                        to 100.
                                      examples:
                                        - '2.5'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - percentage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered per unit: the tiers of the charge
                                    price its units, and each tier prices them
                                    per unit. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_per_unit.
                                      enum:
                                        - tiered_per_unit
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered percentage: the tiers of the charge
                                    price its usage, and each tier bills a
                                    percentage of it. Only a charge on a
                                    resource in money has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_percentage.
                                      enum:
                                        - tiered_percentage
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered fixed: the tier that the whole
                                    quantity reaches bills its flat amount. When
                                    the last tier has an end, unitOverage or
                                    percentageOverage prices the quantity past
                                    it, and a charge never has both.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_fixed.
                                      enum:
                                        - tiered_fixed
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        Always volume, because the tier that the
                                        whole quantity reaches bills its flat
                                        amount.
                                    unitOverage:
                                      type: object
                                      description: >-
                                        The price of the units past the last
                                        tier, for a charge on a resource in
                                        units or on a license, when the charge
                                        has one.
                                      properties:
                                        excessUnitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit past the last
                                            tier, as a decimal string.
                                          examples:
                                            - '0.30'
                                      required:
                                        - excessUnitPrice
                                      additionalProperties: false
                                    percentageOverage:
                                      type: object
                                      description: >-
                                        The percentage of the usage past the
                                        last tier that the charge bills, for a
                                        charge on a resource in money, when the
                                        charge has one.
                                      properties:
                                        excessPercentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, as a
                                            decimal string from 0 to 100.
                                          examples:
                                            - '1.5'
                                      required:
                                        - excessPercentage
                                      additionalProperties: false
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  not:
                                    required:
                                      - unitOverage
                                      - percentageOverage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Advanced: tiers of mixed types price the
                                    quantity. The tiers of a charge on a
                                    resource in units are per_unit, per_package
                                    or flat, and those of a charge on a resource
                                    in money are percentage or flat. A charge
                                    priced before the other pricing models
                                    existed has it too.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        advanced.
                                      enum:
                                        - advanced
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                            resourceId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the resource whose
                                usage the charge prices.
                            currencyUnit:
                              type: object
                              description: >-
                                The currency unit that the charge is priced in,
                                or null when the charge has none. A charge with
                                no currency unit or in BRL, the default currency
                                unit, bills money. A charge in any other
                                currency unit, a credit unit, decreases the
                                balance of a credit pool in that unit and bills
                                no money.
                              properties:
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the currency unit
                                    in our system.
                                name:
                                  type: string
                                  description: The name of the currency unit.
                                  examples:
                                    - Real
                                code:
                                  type: string
                                  description: The short code of the currency unit.
                                  examples:
                                    - BRL
                              required:
                                - id
                                - name
                                - code
                              additionalProperties: false
                              nullable: true
                            tiers:
                              type: array
                              items:
                                type: object
                                description: >-
                                  A price tier of the charge: a band of
                                  quantity, from one number to another, with its
                                  own price. The first tier starts at 0 or 1,
                                  and each tier starts at the to of the tier
                                  before it plus 1.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the tier in our
                                      system.
                                  position:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The position of the tier in the charge,
                                      from 0, from the lowest band to the
                                      highest.
                                  from:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The first quantity of the band, which the
                                      band includes: a number of units of the
                                      resource or of the license, or of cents
                                      for a resource in money.
                                  to:
                                    type: integer
                                    minimum: 0
                                    nullable: true
                                    description: >-
                                      The last quantity of the band, which the
                                      band includes, in the unit of from, or
                                      null when the band has no end. The last
                                      tier has an end only on a charge with the
                                      pricing model tiered_fixed and an overage.
                                  pricing:
                                    type: object
                                    description: >-
                                      The price of the quantity that falls in
                                      the tier, by type: per_unit, percentage,
                                      per_package or flat.
                                    discriminator:
                                      propertyName: type
                                    oneOf:
                                      - type: object
                                        description: >-
                                          Per unit: each unit in the tier costs
                                          unitPrice. A charge on a resource in
                                          money cannot have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_unit.'
                                            enum:
                                              - per_unit
                                          unitPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one unit in the tier, as a
                                              decimal string.
                                            examples:
                                              - '0.20'
                                          fixedPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            nullable: true
                                            description: >-
                                              An amount that the tier bills on top of
                                              its units when the tier applies, as a
                                              decimal string, or null when it has
                                              none. Only a tier of a charge with the
                                              pricing model tiered_per_unit has an
                                              amount other than zero.
                                            examples:
                                              - '10.00'
                                        required:
                                          - type
                                          - unitPrice
                                          - fixedPrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Percentage: the tier bills a percentage
                                          of the usage that falls in it. Only a
                                          charge on a resource in money has it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: percentage.'
                                            enum:
                                              - percentage
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              The percentage of the usage in the tier
                                              that the tier bills, as a decimal string
                                              from 0 to 100.
                                            examples:
                                              - '1.5'
                                        required:
                                          - type
                                          - percentage
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Per package: the units in the tier bill
                                          packagePrice for each package of
                                          packageSize units that they start. A
                                          charge on a resource in money cannot
                                          have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_package.'
                                            enum:
                                              - per_package
                                          packageSize:
                                            type: integer
                                            minimum: 1
                                            description: The number of units in one package.
                                          packagePrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one package, as a decimal
                                              string.
                                            examples:
                                              - '45.00'
                                        required:
                                          - type
                                          - packageSize
                                          - packagePrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Flat: the tier bills one amount,
                                          whatever the quantity that falls in it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: flat.'
                                            enum:
                                              - flat
                                          amount:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The amount that the tier bills, as a
                                              decimal string.
                                            examples:
                                              - '199.90'
                                        required:
                                          - type
                                          - amount
                                        additionalProperties: false
                                required:
                                  - id
                                  - position
                                  - from
                                  - to
                                  - pricing
                                additionalProperties: false
                              description: >-
                                The price tiers of the charge, from the lowest
                                band to the highest, for the pricing models
                                tiered_per_unit, tiered_percentage, tiered_fixed
                                and advanced, or an empty list for the other
                                pricing models.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - resourceId
                            - currencyUnit
                            - tiers
                          additionalProperties: false
                        - type: object
                          description: >-
                            A license-based charge: a charge on the balance of a
                            license in its charge period, read by its billing
                            model and priced by its pricing model.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: license_based.'
                              enum:
                                - license_based
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              enum:
                                - per_unit
                                - per_package
                                - tiered_per_unit
                                - tiered_fixed
                              description: >-
                                The pricing model of the charge, the same as
                                pricing.model: per_unit, per_package,
                                tiered_per_unit or tiered_fixed. No percentage
                                applies, because the balance of a license is a
                                count, not an amount of money.
                            pricing:
                              type: object
                              description: >-
                                The price of a usage-based or license-based
                                charge, by pricing model. Its model is the
                                pricingModel of the charge.
                              discriminator:
                                propertyName: model
                              oneOf:
                                - type: object
                                  description: >-
                                    Per unit: each unit of the charge period
                                    past the included quantity costs unitPrice.
                                    A charge on a resource in money cannot have
                                    it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_unit.
                                      enum:
                                        - per_unit
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    unitPrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one unit, as a decimal
                                        string.
                                      examples:
                                        - '0.25'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - unitPrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Per package: the units of the charge period
                                    past the included quantity bill packagePrice
                                    for each package of packageSize units that
                                    they start. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_package.
                                      enum:
                                        - per_package
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    packageSize:
                                      type: integer
                                      minimum: 1
                                      description: The number of units in one package.
                                    packagePrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one package, as a decimal
                                        string.
                                      examples:
                                        - '50.00'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - packageSize
                                    - packagePrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Percentage: the charge bills a percentage of
                                    the usage of its resource in the charge
                                    period. Only a charge on a resource in money
                                    has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        percentage.
                                      enum:
                                        - percentage
                                    percentage:
                                      type: string
                                      pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                      description: >-
                                        The percentage of the usage that the
                                        charge bills, as a decimal string from 0
                                        to 100.
                                      examples:
                                        - '2.5'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - percentage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered per unit: the tiers of the charge
                                    price its units, and each tier prices them
                                    per unit. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_per_unit.
                                      enum:
                                        - tiered_per_unit
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered percentage: the tiers of the charge
                                    price its usage, and each tier bills a
                                    percentage of it. Only a charge on a
                                    resource in money has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_percentage.
                                      enum:
                                        - tiered_percentage
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered fixed: the tier that the whole
                                    quantity reaches bills its flat amount. When
                                    the last tier has an end, unitOverage or
                                    percentageOverage prices the quantity past
                                    it, and a charge never has both.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_fixed.
                                      enum:
                                        - tiered_fixed
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        Always volume, because the tier that the
                                        whole quantity reaches bills its flat
                                        amount.
                                    unitOverage:
                                      type: object
                                      description: >-
                                        The price of the units past the last
                                        tier, for a charge on a resource in
                                        units or on a license, when the charge
                                        has one.
                                      properties:
                                        excessUnitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit past the last
                                            tier, as a decimal string.
                                          examples:
                                            - '0.30'
                                      required:
                                        - excessUnitPrice
                                      additionalProperties: false
                                    percentageOverage:
                                      type: object
                                      description: >-
                                        The percentage of the usage past the
                                        last tier that the charge bills, for a
                                        charge on a resource in money, when the
                                        charge has one.
                                      properties:
                                        excessPercentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, as a
                                            decimal string from 0 to 100.
                                          examples:
                                            - '1.5'
                                      required:
                                        - excessPercentage
                                      additionalProperties: false
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  not:
                                    required:
                                      - unitOverage
                                      - percentageOverage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Advanced: tiers of mixed types price the
                                    quantity. The tiers of a charge on a
                                    resource in units are per_unit, per_package
                                    or flat, and those of a charge on a resource
                                    in money are percentage or flat. A charge
                                    priced before the other pricing models
                                    existed has it too.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        advanced.
                                      enum:
                                        - advanced
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                            licenseId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the license whose
                                balance the charge bills.
                            billingModel:
                              type: string
                              enum:
                                - in_full
                                - proration
                              description: >-
                                How the charge reads the balance of its license
                                in a charge period: in_full bills the last
                                balance, and proration weighs each balance by
                                the days that it was in effect.
                            tiers:
                              type: array
                              items:
                                type: object
                                description: >-
                                  A price tier of the charge: a band of
                                  quantity, from one number to another, with its
                                  own price. The first tier starts at 0 or 1,
                                  and each tier starts at the to of the tier
                                  before it plus 1.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the tier in our
                                      system.
                                  position:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The position of the tier in the charge,
                                      from 0, from the lowest band to the
                                      highest.
                                  from:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The first quantity of the band, which the
                                      band includes: a number of units of the
                                      resource or of the license, or of cents
                                      for a resource in money.
                                  to:
                                    type: integer
                                    minimum: 0
                                    nullable: true
                                    description: >-
                                      The last quantity of the band, which the
                                      band includes, in the unit of from, or
                                      null when the band has no end. The last
                                      tier has an end only on a charge with the
                                      pricing model tiered_fixed and an overage.
                                  pricing:
                                    type: object
                                    description: >-
                                      The price of the quantity that falls in
                                      the tier, by type: per_unit, percentage,
                                      per_package or flat.
                                    discriminator:
                                      propertyName: type
                                    oneOf:
                                      - type: object
                                        description: >-
                                          Per unit: each unit in the tier costs
                                          unitPrice. A charge on a resource in
                                          money cannot have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_unit.'
                                            enum:
                                              - per_unit
                                          unitPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one unit in the tier, as a
                                              decimal string.
                                            examples:
                                              - '0.20'
                                          fixedPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            nullable: true
                                            description: >-
                                              An amount that the tier bills on top of
                                              its units when the tier applies, as a
                                              decimal string, or null when it has
                                              none. Only a tier of a charge with the
                                              pricing model tiered_per_unit has an
                                              amount other than zero.
                                            examples:
                                              - '10.00'
                                        required:
                                          - type
                                          - unitPrice
                                          - fixedPrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Percentage: the tier bills a percentage
                                          of the usage that falls in it. Only a
                                          charge on a resource in money has it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: percentage.'
                                            enum:
                                              - percentage
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              The percentage of the usage in the tier
                                              that the tier bills, as a decimal string
                                              from 0 to 100.
                                            examples:
                                              - '1.5'
                                        required:
                                          - type
                                          - percentage
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Per package: the units in the tier bill
                                          packagePrice for each package of
                                          packageSize units that they start. A
                                          charge on a resource in money cannot
                                          have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_package.'
                                            enum:
                                              - per_package
                                          packageSize:
                                            type: integer
                                            minimum: 1
                                            description: The number of units in one package.
                                          packagePrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one package, as a decimal
                                              string.
                                            examples:
                                              - '45.00'
                                        required:
                                          - type
                                          - packageSize
                                          - packagePrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Flat: the tier bills one amount,
                                          whatever the quantity that falls in it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: flat.'
                                            enum:
                                              - flat
                                          amount:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The amount that the tier bills, as a
                                              decimal string.
                                            examples:
                                              - '199.90'
                                        required:
                                          - type
                                          - amount
                                        additionalProperties: false
                                required:
                                  - id
                                  - position
                                  - from
                                  - to
                                  - pricing
                                additionalProperties: false
                              description: >-
                                The price tiers of the charge, from the lowest
                                band to the highest, for the pricing models
                                tiered_per_unit and tiered_fixed, or an empty
                                list for the other pricing models.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - licenseId
                            - billingModel
                            - tiers
                          additionalProperties: false
                        - type: object
                          description: >-
                            A custom plan charge: a charge whose price comes
                            from code that Aira writes for you, from the custom
                            charge definition that the charge follows and from
                            the parameter values of the charge. It bills in
                            arrears, in money.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: custom.'
                              enum:
                                - custom
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              description: The pricing model of the charge, always custom.
                              enum:
                                - custom
                            pricing:
                              type: object
                              description: >-
                                The price of a custom plan charge: the parameter
                                values that the code that Aira writes for you
                                turns into an amount.
                              properties:
                                model:
                                  description: 'The pricing model of the price: custom.'
                                  enum:
                                    - custom
                                parameters:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The parameter values of the charge, by the
                                    keys of the parameter schema of its custom
                                    charge definition.
                              required:
                                - model
                                - parameters
                              additionalProperties: false
                            customChargeDefinitionId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the custom charge
                                definition that the charge follows.
                            chosenResourceIds:
                              type: array
                              items:
                                type: string
                                format: uuid
                              description: >-
                                The unique identifiers of the resources that the
                                charge chose as its inputs, from the input
                                resources of its custom charge definition.
                            chosenLicenseIds:
                              type: array
                              items:
                                type: string
                                format: uuid
                              description: >-
                                The unique identifiers of the licenses that the
                                charge chose as its inputs, from the input
                                licenses of its custom charge definition.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - customChargeDefinitionId
                            - chosenResourceIds
                            - chosenLicenseIds
                          additionalProperties: false
                required:
                  - id
                  - planInstanceId
                  - planVersionId
                  - versionNumber
                  - isActive
                  - planInstanceVersionReason
                  - metadata
                  - customFields
                  - createdAt
                  - planCharges
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plan_instance_versions:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `plan_instance_version_not_found`: no plan instance version has
            the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_instance_version_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_instance_version_not_found:
                  value:
                    message: plan instance version not found
                    code: plan_instance_version_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/plan-instance-versions/{id}/rollback:
    post:
      summary: Restore plan instance version
      tags:
        - Plan Instances
      description: >-
        Restores a plan instance version: a new version of its plan instance,
        with the charges and the plan version of the restored version and the
        reason rollback, becomes the active version. The new version has no
        custom field values. The request answers the new version.


        Requires the role `plan_instance_versions:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the plan instance version in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: mixed_billing_frequency_family
          when: >-
            the billing frequencies of the plan charges of the restored version
            are in weeks and the billing schedule of the contract of the plan
            instance repeats every month, or the reverse
        - status: 404
          code: plan_instance_version_not_found
          when: no plan instance version has the `id`
        - status: 404
          code: plan_instance_not_found
          when: the plan instance of the plan instance version was deleted
      x-required-roles:
        - plan_instance_versions:write
      responses:
        '200':
          description: >-
            Schema representing a plan instance version, one state of the
            charges of a plan instance. Each change of the charges creates a
            version: the active version is the one that billing uses, and a
            restore can bring back any of the others.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: >-
                      The unique identifier of the plan instance version in our
                      system.
                    type: string
                    format: uuid
                  planInstanceId:
                    description: >-
                      The unique identifier of the plan instance that the
                      version belongs to.
                    type: string
                    format: uuid
                  planVersionId:
                    description: >-
                      The unique identifier of the plan version that the version
                      comes from.
                    type: string
                    format: uuid
                  versionNumber:
                    description: >-
                      The number of the version in its plan instance, from 1,
                      one more for each new version.
                    type: integer
                    minimum: 1
                  isActive:
                    description: >-
                      Whether billing uses this version. A plan instance has one
                      active version.
                    type: boolean
                  planInstanceVersionReason:
                    description: >-
                      Why the version exists: created_from_plan_version (it
                      comes from a plan version of the plan),
                      duplicated_from_contract (a copy of a plan instance of
                      another contract), manual_override (an update of the
                      charges of the plan instance), readjustment (a rate
                      adjustment) or rollback (a restore of an earlier version).
                    type: string
                    enum:
                      - created_from_plan_version
                      - duplicated_from_contract
                      - manual_override
                      - readjustment
                      - rollback
                  metadata:
                    anyOf:
                      - type: object
                        description: >-
                          The details of a version that comes from a plan
                          version of the plan.
                        properties:
                          reason:
                            type: string
                            enum:
                              - created_from_plan_version
                            description: >-
                              The reason of the version:
                              created_from_plan_version.
                          sourcePlanVersionId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the plan version that the
                              version comes from.
                        required:
                          - reason
                          - sourcePlanVersionId
                        additionalProperties: false
                      - type: object
                        description: >-
                          The details of a version that copies a plan instance
                          of another contract, from a duplication of that
                          contract.
                        properties:
                          reason:
                            type: string
                            enum:
                              - duplicated_from_contract
                            description: >-
                              The reason of the version:
                              duplicated_from_contract.
                          sourceContractId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the contract that the
                              duplication copied.
                          sourcePlanInstanceId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the plan instance that
                              the version copies.
                        required:
                          - reason
                          - sourceContractId
                          - sourcePlanInstanceId
                        additionalProperties: false
                      - type: object
                        description: >-
                          The details of a version from an update of the charges
                          of the plan instance, in the billing app or through
                          the API.
                        properties:
                          reason:
                            type: string
                            enum:
                              - manual_override
                            description: 'The reason of the version: manual_override.'
                          previousPlanInstanceVersionId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the plan instance version
                              that was active before the update.
                        required:
                          - reason
                          - previousPlanInstanceVersionId
                        additionalProperties: false
                      - type: object
                        description: >-
                          The details of a version from a rate adjustment, which
                          applies a percentage to the prices of the plan
                          instance.
                        properties:
                          reason:
                            type: string
                            enum:
                              - readjustment
                            description: 'The reason of the version: readjustment.'
                          previousPlanInstanceVersionId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the plan instance version
                              that was active before the rate adjustment.
                          percentage:
                            type: string
                            description: >-
                              The percentage that the rate adjustment applied to
                              the prices, as a decimal string, such as "5" for a
                              rise of 5%.
                            examples:
                              - '5'
                        required:
                          - reason
                          - previousPlanInstanceVersionId
                          - percentage
                        additionalProperties: false
                      - type: object
                        description: >-
                          The details of a version from a restore of an earlier
                          version.
                        properties:
                          reason:
                            type: string
                            enum:
                              - rollback
                            description: 'The reason of the version: rollback.'
                          rolledBackFromPlanInstanceVersionId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the plan instance version
                              whose charges the restore brought back.
                        required:
                          - reason
                          - rolledBackFromPlanInstanceVersionId
                        additionalProperties: false
                      - type: 'null'
                        description: Aira recorded no details for the version.
                    description: >-
                      The details of how the version came to exist, by reason,
                      such as the plan version that it comes from, the version
                      before it or the percentage of a rate adjustment, or null
                      when Aira recorded none.
                  customFields:
                    type: object
                    description: >-
                      The custom field values that the version was created with.
                      An update of the plan instance sets them, and every other
                      way of creating a version leaves them empty.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  createdAt:
                    description: The moment when Aira created the version.
                    type: string
                    format: date-time
                  planCharges:
                    description: The plan charges of the version.
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a plan charge, one priced line of a
                        plan: its item names what it bills, its category says
                        what it bills from, its pricing model turns a quantity
                        into money, and its billing frequency says how often it
                        bills. The fields of a charge depend on its category. An
                        amount is an integer number of cents, and a price is a
                        decimal string with up to 6 decimal places, in BRL or in
                        the credit unit of the charge.
                      discriminator:
                        propertyName: category
                      oneOf:
                        - type: object
                          description: >-
                            A fixed charge: the same amount in every charge
                            period, billed on the invoice that its billing
                            timing names.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: fixed.'
                              enum:
                                - fixed
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              description: The pricing model of the charge, always fixed.
                              enum:
                                - fixed
                            pricing:
                              type: object
                              description: >-
                                The price of a fixed charge or of a minimum
                                commitment.
                              properties:
                                model:
                                  description: 'The pricing model of the price: fixed.'
                                  enum:
                                    - fixed
                                amount:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The amount that the charge bills in each
                                    charge period, in cents, or the amount of
                                    one unit when the charge has a quantity. For
                                    a minimum commitment, the least that the
                                    charges of the plan with its billing
                                    frequency bill.
                                quantity:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units that a fixed charge
                                    bills in each charge period, when it has
                                    one, so that each charge period bills
                                    quantity times amount. A minimum commitment
                                    has none.
                              required:
                                - model
                                - amount
                              additionalProperties: false
                            billingTiming:
                              type: string
                              enum:
                                - in_advance
                                - in_arrears
                              description: >-
                                When the charge bills a charge period:
                                in_arrears bills it on the closing invoice of
                                its last cycle, and in_advance bills it before
                                it starts, on the activation invoice or on the
                                closing invoice of the cycle before. The billing
                                timing moves the invoice, never the amount.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - billingTiming
                          additionalProperties: false
                        - type: object
                          description: >-
                            A minimum commitment: the least that the plan bills
                            in a charge period. When the charges of the plan
                            with the same billing frequency total less, the
                            charge bills the difference. A plan has at most one
                            for each billing frequency.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: minimum_commitment.'
                              enum:
                                - minimum_commitment
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              description: The pricing model of the charge, always fixed.
                              enum:
                                - fixed
                            pricing:
                              type: object
                              description: >-
                                The price of a fixed charge or of a minimum
                                commitment.
                              properties:
                                model:
                                  description: 'The pricing model of the price: fixed.'
                                  enum:
                                    - fixed
                                amount:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The amount that the charge bills in each
                                    charge period, in cents, or the amount of
                                    one unit when the charge has a quantity. For
                                    a minimum commitment, the least that the
                                    charges of the plan with its billing
                                    frequency bill.
                                quantity:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units that a fixed charge
                                    bills in each charge period, when it has
                                    one, so that each charge period bills
                                    quantity times amount. A minimum commitment
                                    has none.
                              required:
                                - model
                                - amount
                              additionalProperties: false
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                          additionalProperties: false
                        - type: object
                          description: >-
                            A usage-based charge: a charge on the usage of a
                            resource in its charge period, priced by its pricing
                            model.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: usage_based.'
                              enum:
                                - usage_based
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              enum:
                                - per_unit
                                - per_package
                                - percentage
                                - tiered_per_unit
                                - tiered_percentage
                                - tiered_fixed
                                - advanced
                              description: >-
                                The pricing model of the charge, the same as
                                pricing.model. per_unit, per_package and
                                tiered_per_unit price a resource in units,
                                percentage and tiered_percentage price a
                                resource in money, and tiered_fixed and advanced
                                price either.
                            pricing:
                              type: object
                              description: >-
                                The price of a usage-based or license-based
                                charge, by pricing model. Its model is the
                                pricingModel of the charge.
                              discriminator:
                                propertyName: model
                              oneOf:
                                - type: object
                                  description: >-
                                    Per unit: each unit of the charge period
                                    past the included quantity costs unitPrice.
                                    A charge on a resource in money cannot have
                                    it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_unit.
                                      enum:
                                        - per_unit
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    unitPrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one unit, as a decimal
                                        string.
                                      examples:
                                        - '0.25'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - unitPrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Per package: the units of the charge period
                                    past the included quantity bill packagePrice
                                    for each package of packageSize units that
                                    they start. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_package.
                                      enum:
                                        - per_package
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    packageSize:
                                      type: integer
                                      minimum: 1
                                      description: The number of units in one package.
                                    packagePrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one package, as a decimal
                                        string.
                                      examples:
                                        - '50.00'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - packageSize
                                    - packagePrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Percentage: the charge bills a percentage of
                                    the usage of its resource in the charge
                                    period. Only a charge on a resource in money
                                    has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        percentage.
                                      enum:
                                        - percentage
                                    percentage:
                                      type: string
                                      pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                      description: >-
                                        The percentage of the usage that the
                                        charge bills, as a decimal string from 0
                                        to 100.
                                      examples:
                                        - '2.5'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - percentage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered per unit: the tiers of the charge
                                    price its units, and each tier prices them
                                    per unit. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_per_unit.
                                      enum:
                                        - tiered_per_unit
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered percentage: the tiers of the charge
                                    price its usage, and each tier bills a
                                    percentage of it. Only a charge on a
                                    resource in money has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_percentage.
                                      enum:
                                        - tiered_percentage
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered fixed: the tier that the whole
                                    quantity reaches bills its flat amount. When
                                    the last tier has an end, unitOverage or
                                    percentageOverage prices the quantity past
                                    it, and a charge never has both.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_fixed.
                                      enum:
                                        - tiered_fixed
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        Always volume, because the tier that the
                                        whole quantity reaches bills its flat
                                        amount.
                                    unitOverage:
                                      type: object
                                      description: >-
                                        The price of the units past the last
                                        tier, for a charge on a resource in
                                        units or on a license, when the charge
                                        has one.
                                      properties:
                                        excessUnitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit past the last
                                            tier, as a decimal string.
                                          examples:
                                            - '0.30'
                                      required:
                                        - excessUnitPrice
                                      additionalProperties: false
                                    percentageOverage:
                                      type: object
                                      description: >-
                                        The percentage of the usage past the
                                        last tier that the charge bills, for a
                                        charge on a resource in money, when the
                                        charge has one.
                                      properties:
                                        excessPercentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, as a
                                            decimal string from 0 to 100.
                                          examples:
                                            - '1.5'
                                      required:
                                        - excessPercentage
                                      additionalProperties: false
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  not:
                                    required:
                                      - unitOverage
                                      - percentageOverage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Advanced: tiers of mixed types price the
                                    quantity. The tiers of a charge on a
                                    resource in units are per_unit, per_package
                                    or flat, and those of a charge on a resource
                                    in money are percentage or flat. A charge
                                    priced before the other pricing models
                                    existed has it too.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        advanced.
                                      enum:
                                        - advanced
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                            resourceId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the resource whose
                                usage the charge prices.
                            currencyUnit:
                              type: object
                              description: >-
                                The currency unit that the charge is priced in,
                                or null when the charge has none. A charge with
                                no currency unit or in BRL, the default currency
                                unit, bills money. A charge in any other
                                currency unit, a credit unit, decreases the
                                balance of a credit pool in that unit and bills
                                no money.
                              properties:
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the currency unit
                                    in our system.
                                name:
                                  type: string
                                  description: The name of the currency unit.
                                  examples:
                                    - Real
                                code:
                                  type: string
                                  description: The short code of the currency unit.
                                  examples:
                                    - BRL
                              required:
                                - id
                                - name
                                - code
                              additionalProperties: false
                              nullable: true
                            tiers:
                              type: array
                              items:
                                type: object
                                description: >-
                                  A price tier of the charge: a band of
                                  quantity, from one number to another, with its
                                  own price. The first tier starts at 0 or 1,
                                  and each tier starts at the to of the tier
                                  before it plus 1.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the tier in our
                                      system.
                                  position:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The position of the tier in the charge,
                                      from 0, from the lowest band to the
                                      highest.
                                  from:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The first quantity of the band, which the
                                      band includes: a number of units of the
                                      resource or of the license, or of cents
                                      for a resource in money.
                                  to:
                                    type: integer
                                    minimum: 0
                                    nullable: true
                                    description: >-
                                      The last quantity of the band, which the
                                      band includes, in the unit of from, or
                                      null when the band has no end. The last
                                      tier has an end only on a charge with the
                                      pricing model tiered_fixed and an overage.
                                  pricing:
                                    type: object
                                    description: >-
                                      The price of the quantity that falls in
                                      the tier, by type: per_unit, percentage,
                                      per_package or flat.
                                    discriminator:
                                      propertyName: type
                                    oneOf:
                                      - type: object
                                        description: >-
                                          Per unit: each unit in the tier costs
                                          unitPrice. A charge on a resource in
                                          money cannot have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_unit.'
                                            enum:
                                              - per_unit
                                          unitPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one unit in the tier, as a
                                              decimal string.
                                            examples:
                                              - '0.20'
                                          fixedPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            nullable: true
                                            description: >-
                                              An amount that the tier bills on top of
                                              its units when the tier applies, as a
                                              decimal string, or null when it has
                                              none. Only a tier of a charge with the
                                              pricing model tiered_per_unit has an
                                              amount other than zero.
                                            examples:
                                              - '10.00'
                                        required:
                                          - type
                                          - unitPrice
                                          - fixedPrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Percentage: the tier bills a percentage
                                          of the usage that falls in it. Only a
                                          charge on a resource in money has it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: percentage.'
                                            enum:
                                              - percentage
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              The percentage of the usage in the tier
                                              that the tier bills, as a decimal string
                                              from 0 to 100.
                                            examples:
                                              - '1.5'
                                        required:
                                          - type
                                          - percentage
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Per package: the units in the tier bill
                                          packagePrice for each package of
                                          packageSize units that they start. A
                                          charge on a resource in money cannot
                                          have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_package.'
                                            enum:
                                              - per_package
                                          packageSize:
                                            type: integer
                                            minimum: 1
                                            description: The number of units in one package.
                                          packagePrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one package, as a decimal
                                              string.
                                            examples:
                                              - '45.00'
                                        required:
                                          - type
                                          - packageSize
                                          - packagePrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Flat: the tier bills one amount,
                                          whatever the quantity that falls in it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: flat.'
                                            enum:
                                              - flat
                                          amount:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The amount that the tier bills, as a
                                              decimal string.
                                            examples:
                                              - '199.90'
                                        required:
                                          - type
                                          - amount
                                        additionalProperties: false
                                required:
                                  - id
                                  - position
                                  - from
                                  - to
                                  - pricing
                                additionalProperties: false
                              description: >-
                                The price tiers of the charge, from the lowest
                                band to the highest, for the pricing models
                                tiered_per_unit, tiered_percentage, tiered_fixed
                                and advanced, or an empty list for the other
                                pricing models.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - resourceId
                            - currencyUnit
                            - tiers
                          additionalProperties: false
                        - type: object
                          description: >-
                            A license-based charge: a charge on the balance of a
                            license in its charge period, read by its billing
                            model and priced by its pricing model.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: license_based.'
                              enum:
                                - license_based
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              enum:
                                - per_unit
                                - per_package
                                - tiered_per_unit
                                - tiered_fixed
                              description: >-
                                The pricing model of the charge, the same as
                                pricing.model: per_unit, per_package,
                                tiered_per_unit or tiered_fixed. No percentage
                                applies, because the balance of a license is a
                                count, not an amount of money.
                            pricing:
                              type: object
                              description: >-
                                The price of a usage-based or license-based
                                charge, by pricing model. Its model is the
                                pricingModel of the charge.
                              discriminator:
                                propertyName: model
                              oneOf:
                                - type: object
                                  description: >-
                                    Per unit: each unit of the charge period
                                    past the included quantity costs unitPrice.
                                    A charge on a resource in money cannot have
                                    it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_unit.
                                      enum:
                                        - per_unit
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    unitPrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one unit, as a decimal
                                        string.
                                      examples:
                                        - '0.25'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - unitPrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Per package: the units of the charge period
                                    past the included quantity bill packagePrice
                                    for each package of packageSize units that
                                    they start. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_package.
                                      enum:
                                        - per_package
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    packageSize:
                                      type: integer
                                      minimum: 1
                                      description: The number of units in one package.
                                    packagePrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one package, as a decimal
                                        string.
                                      examples:
                                        - '50.00'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - packageSize
                                    - packagePrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Percentage: the charge bills a percentage of
                                    the usage of its resource in the charge
                                    period. Only a charge on a resource in money
                                    has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        percentage.
                                      enum:
                                        - percentage
                                    percentage:
                                      type: string
                                      pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                      description: >-
                                        The percentage of the usage that the
                                        charge bills, as a decimal string from 0
                                        to 100.
                                      examples:
                                        - '2.5'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - percentage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered per unit: the tiers of the charge
                                    price its units, and each tier prices them
                                    per unit. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_per_unit.
                                      enum:
                                        - tiered_per_unit
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered percentage: the tiers of the charge
                                    price its usage, and each tier bills a
                                    percentage of it. Only a charge on a
                                    resource in money has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_percentage.
                                      enum:
                                        - tiered_percentage
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered fixed: the tier that the whole
                                    quantity reaches bills its flat amount. When
                                    the last tier has an end, unitOverage or
                                    percentageOverage prices the quantity past
                                    it, and a charge never has both.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_fixed.
                                      enum:
                                        - tiered_fixed
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        Always volume, because the tier that the
                                        whole quantity reaches bills its flat
                                        amount.
                                    unitOverage:
                                      type: object
                                      description: >-
                                        The price of the units past the last
                                        tier, for a charge on a resource in
                                        units or on a license, when the charge
                                        has one.
                                      properties:
                                        excessUnitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit past the last
                                            tier, as a decimal string.
                                          examples:
                                            - '0.30'
                                      required:
                                        - excessUnitPrice
                                      additionalProperties: false
                                    percentageOverage:
                                      type: object
                                      description: >-
                                        The percentage of the usage past the
                                        last tier that the charge bills, for a
                                        charge on a resource in money, when the
                                        charge has one.
                                      properties:
                                        excessPercentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, as a
                                            decimal string from 0 to 100.
                                          examples:
                                            - '1.5'
                                      required:
                                        - excessPercentage
                                      additionalProperties: false
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  not:
                                    required:
                                      - unitOverage
                                      - percentageOverage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Advanced: tiers of mixed types price the
                                    quantity. The tiers of a charge on a
                                    resource in units are per_unit, per_package
                                    or flat, and those of a charge on a resource
                                    in money are percentage or flat. A charge
                                    priced before the other pricing models
                                    existed has it too.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        advanced.
                                      enum:
                                        - advanced
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                            licenseId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the license whose
                                balance the charge bills.
                            billingModel:
                              type: string
                              enum:
                                - in_full
                                - proration
                              description: >-
                                How the charge reads the balance of its license
                                in a charge period: in_full bills the last
                                balance, and proration weighs each balance by
                                the days that it was in effect.
                            tiers:
                              type: array
                              items:
                                type: object
                                description: >-
                                  A price tier of the charge: a band of
                                  quantity, from one number to another, with its
                                  own price. The first tier starts at 0 or 1,
                                  and each tier starts at the to of the tier
                                  before it plus 1.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the tier in our
                                      system.
                                  position:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The position of the tier in the charge,
                                      from 0, from the lowest band to the
                                      highest.
                                  from:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The first quantity of the band, which the
                                      band includes: a number of units of the
                                      resource or of the license, or of cents
                                      for a resource in money.
                                  to:
                                    type: integer
                                    minimum: 0
                                    nullable: true
                                    description: >-
                                      The last quantity of the band, which the
                                      band includes, in the unit of from, or
                                      null when the band has no end. The last
                                      tier has an end only on a charge with the
                                      pricing model tiered_fixed and an overage.
                                  pricing:
                                    type: object
                                    description: >-
                                      The price of the quantity that falls in
                                      the tier, by type: per_unit, percentage,
                                      per_package or flat.
                                    discriminator:
                                      propertyName: type
                                    oneOf:
                                      - type: object
                                        description: >-
                                          Per unit: each unit in the tier costs
                                          unitPrice. A charge on a resource in
                                          money cannot have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_unit.'
                                            enum:
                                              - per_unit
                                          unitPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one unit in the tier, as a
                                              decimal string.
                                            examples:
                                              - '0.20'
                                          fixedPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            nullable: true
                                            description: >-
                                              An amount that the tier bills on top of
                                              its units when the tier applies, as a
                                              decimal string, or null when it has
                                              none. Only a tier of a charge with the
                                              pricing model tiered_per_unit has an
                                              amount other than zero.
                                            examples:
                                              - '10.00'
                                        required:
                                          - type
                                          - unitPrice
                                          - fixedPrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Percentage: the tier bills a percentage
                                          of the usage that falls in it. Only a
                                          charge on a resource in money has it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: percentage.'
                                            enum:
                                              - percentage
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              The percentage of the usage in the tier
                                              that the tier bills, as a decimal string
                                              from 0 to 100.
                                            examples:
                                              - '1.5'
                                        required:
                                          - type
                                          - percentage
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Per package: the units in the tier bill
                                          packagePrice for each package of
                                          packageSize units that they start. A
                                          charge on a resource in money cannot
                                          have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_package.'
                                            enum:
                                              - per_package
                                          packageSize:
                                            type: integer
                                            minimum: 1
                                            description: The number of units in one package.
                                          packagePrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one package, as a decimal
                                              string.
                                            examples:
                                              - '45.00'
                                        required:
                                          - type
                                          - packageSize
                                          - packagePrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Flat: the tier bills one amount,
                                          whatever the quantity that falls in it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: flat.'
                                            enum:
                                              - flat
                                          amount:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The amount that the tier bills, as a
                                              decimal string.
                                            examples:
                                              - '199.90'
                                        required:
                                          - type
                                          - amount
                                        additionalProperties: false
                                required:
                                  - id
                                  - position
                                  - from
                                  - to
                                  - pricing
                                additionalProperties: false
                              description: >-
                                The price tiers of the charge, from the lowest
                                band to the highest, for the pricing models
                                tiered_per_unit and tiered_fixed, or an empty
                                list for the other pricing models.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - licenseId
                            - billingModel
                            - tiers
                          additionalProperties: false
                        - type: object
                          description: >-
                            A custom plan charge: a charge whose price comes
                            from code that Aira writes for you, from the custom
                            charge definition that the charge follows and from
                            the parameter values of the charge. It bills in
                            arrears, in money.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: custom.'
                              enum:
                                - custom
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              description: The pricing model of the charge, always custom.
                              enum:
                                - custom
                            pricing:
                              type: object
                              description: >-
                                The price of a custom plan charge: the parameter
                                values that the code that Aira writes for you
                                turns into an amount.
                              properties:
                                model:
                                  description: 'The pricing model of the price: custom.'
                                  enum:
                                    - custom
                                parameters:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The parameter values of the charge, by the
                                    keys of the parameter schema of its custom
                                    charge definition.
                              required:
                                - model
                                - parameters
                              additionalProperties: false
                            customChargeDefinitionId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the custom charge
                                definition that the charge follows.
                            chosenResourceIds:
                              type: array
                              items:
                                type: string
                                format: uuid
                              description: >-
                                The unique identifiers of the resources that the
                                charge chose as its inputs, from the input
                                resources of its custom charge definition.
                            chosenLicenseIds:
                              type: array
                              items:
                                type: string
                                format: uuid
                              description: >-
                                The unique identifiers of the licenses that the
                                charge chose as its inputs, from the input
                                licenses of its custom charge definition.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - customChargeDefinitionId
                            - chosenResourceIds
                            - chosenLicenseIds
                          additionalProperties: false
                required:
                  - id
                  - planInstanceId
                  - planVersionId
                  - versionNumber
                  - isActive
                  - planInstanceVersionReason
                  - metadata
                  - customFields
                  - createdAt
                  - planCharges
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `mixed_billing_frequency_family`: the billing frequencies of the
            plan charges of the restored version are in weeks and the billing
            schedule of the contract of the plan instance repeats every month,
            or the reverse.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - mixed_billing_frequency_family
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                mixed_billing_frequency_family:
                  value:
                    message: >-
                      the billing frequencies of the plan charges of the
                      restored version are in weeks and the billing schedule of
                      the contract of the plan instance repeats every month, or
                      the reverse
                    code: mixed_billing_frequency_family
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plan_instance_versions:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `plan_instance_version_not_found`: no plan instance version has
            the `id`.

            - `plan_instance_not_found`: the plan instance of the plan instance
            version was deleted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_instance_version_not_found
                      - plan_instance_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_instance_version_not_found:
                  value:
                    message: plan instance version not found
                    code: plan_instance_version_not_found
                plan_instance_not_found:
                  value:
                    message: plan instance not found
                    code: plan_instance_not_found
  /v1/plans/:
    post:
      summary: Create plan
      tags:
        - Plans
      description: >-
        Creates a plan of a product with its first plan version, which holds the
        plan charges of the body and becomes the active plan version of the
        plan, so a new plan instance of the plan bills those plan charges.


        Requires the role `plans:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  description: The name of the plan.
                  example: Plano Essencial
                description:
                  description: >-
                    The description of the plan, or null for none. Leave it out
                    for none.
                  type:
                    - 'null'
                    - string
                  example: Assinatura mensal com entrega diária de pães.
                productId:
                  type: string
                  format: uuid
                  description: >-
                    The unique identifier of the product that the plan belongs
                    to.
                planCharges:
                  type: array
                  minItems: 1
                  maxItems: 100
                  items:
                    type: object
                    discriminator:
                      propertyName: category
                    oneOf:
                      - type: object
                        description: >-
                          A fixed charge: bills a flat amount once per period of
                          its billingFrequency, at the boundary its
                          billingTiming picks.
                        properties:
                          category:
                            description: 'Discriminator: fixed charge.'
                            enum:
                              - fixed
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          itemId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the catalog item this
                              charge bills.
                          pricingModel:
                            type: string
                            description: >-
                              Fixed and minimum_commitment charges always use
                              fixed pricing.
                            enum:
                              - fixed
                          pricing:
                            type: object
                            description: >-
                              Fixed pricing: a flat amount billed once per
                              period of the charge's billingFrequency. The only
                              pricing available for fixed and minimum_commitment
                              charges.
                            properties:
                              model:
                                description: 'Discriminator: fixed pricing.'
                                enum:
                                  - fixed
                              amount:
                                type: integer
                                minimum: 0
                                description: >-
                                  The flat amount billed per period, in cents.
                                  For minimum_commitment charges, the minimum
                                  the charges sharing its frequency are topped
                                  up to.
                              quantity:
                                type: integer
                                minimum: 1
                                description: >-
                                  Optional, fixed charges only: the quantity
                                  billed. When set, amount is the amount of one
                                  unit and each period of the charge's
                                  billingFrequency bills quantity x amount.
                            required:
                              - model
                              - amount
                            additionalProperties: false
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                          billingTiming:
                            type: string
                            enum:
                              - in_advance
                              - in_arrears
                            description: >-
                              Optional. When the charge's flat fee is billed
                              relative to the period it covers (see
                              billingFrequency): in_arrears (the default) bills
                              the period at the close of the cycle that ends it;
                              in_advance bills it at the boundary that opens it
                              (the contract's activation invoice for the periods
                              its first cycle opens, otherwise the close of the
                              cycle just before the period). Only the timing
                              shifts, never the amount. Valid only on fixed
                              charges. Defaults to in_arrears when omitted.
                        required:
                          - category
                          - itemId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                      - type: object
                        description: >-
                          A minimum commitment charge: at the close of each
                          period of its billingFrequency, tops the plan's
                          charges sharing that frequency up to the configured
                          amount when their total on that calculation stays
                          below it. A plan can have at most one minimum per
                          billing frequency.
                        properties:
                          category:
                            description: 'Discriminator: minimum commitment charge.'
                            enum:
                              - minimum_commitment
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          itemId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the catalog item this
                              charge bills.
                          pricingModel:
                            type: string
                            description: >-
                              Fixed and minimum_commitment charges always use
                              fixed pricing.
                            enum:
                              - fixed
                          pricing:
                            type: object
                            description: >-
                              Fixed pricing: a flat amount billed once per
                              period of the charge's billingFrequency. The only
                              pricing available for fixed and minimum_commitment
                              charges.
                            properties:
                              model:
                                description: 'Discriminator: fixed pricing.'
                                enum:
                                  - fixed
                              amount:
                                type: integer
                                minimum: 0
                                description: >-
                                  The flat amount billed per period, in cents.
                                  For minimum_commitment charges, the minimum
                                  the charges sharing its frequency are topped
                                  up to.
                              quantity:
                                type: integer
                                minimum: 1
                                description: >-
                                  Optional, fixed charges only: the quantity
                                  billed. When set, amount is the amount of one
                                  unit and each period of the charge's
                                  billingFrequency bills quantity x amount.
                            required:
                              - model
                              - amount
                            additionalProperties: false
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                        required:
                          - category
                          - itemId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                      - type: object
                        description: >-
                          A usage-based charge: prices the consumption of a
                          metered resource according to pricingModel.
                        properties:
                          category:
                            description: 'Discriminator: usage-based charge.'
                            enum:
                              - usage_based
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          resourceId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the metered resource
                              whose usage the charge prices.
                          pricingModel:
                            type: string
                            enum:
                              - per_unit
                              - per_package
                              - percentage
                              - tiered_per_unit
                              - tiered_percentage
                              - tiered_fixed
                              - advanced
                            description: >-
                              How the charge is priced: per_unit (price per unit
                              with optional included quantity), per_package
                              (price per started package of units), percentage
                              (a percentage of a monetary base amount),
                              tiered_per_unit / tiered_percentage / tiered_fixed
                              (tier ladder where every tier uses that pricing
                              type), or advanced (tier ladder mixing tier
                              pricing types). per_unit, per_package and
                              tiered_per_unit require a Unit-type resource;
                              percentage and tiered_percentage require a
                              Currency-type resource; tiered_fixed and advanced
                              accept either. Always matches pricing.model.
                          pricing:
                            type: object
                            description: >-
                              Pricing configuration of a usage-based charge,
                              keyed by model. Must match the charge's
                              pricingModel.
                            discriminator:
                              propertyName: model
                            oneOf:
                              - type: object
                                description: >-
                                  Per-unit pricing: every billable unit costs
                                  unitPrice, after deducting the included
                                  quantity. Not valid for charges on
                                  Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: per-unit pricing.'
                                    enum:
                                      - per_unit
                                  includedQuantity:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional number of units included at no
                                      charge before billing starts.
                                  unitPrice:
                                    type: string
                                    pattern: ^\d+(\.\d{1,6})?$
                                    description: >-
                                      Price per unit, as a decimal currency-unit
                                      string (up to 6 decimal places).
                                    examples:
                                      - '0.25'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - unitPrice
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Per-package pricing: billable units are
                                  charged per started package of packageSize
                                  units, after deducting the included quantity.
                                  Not valid for charges on Currency-type
                                  resources.
                                properties:
                                  model:
                                    description: 'Discriminator: per-package pricing.'
                                    enum:
                                      - per_package
                                  includedQuantity:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional number of units included at no
                                      charge before billing starts.
                                  packageSize:
                                    type: integer
                                    minimum: 1
                                    description: Number of resource units per package.
                                  packagePrice:
                                    type: string
                                    pattern: ^\d+(\.\d{1,6})?$
                                    description: >-
                                      Price per package, as a decimal
                                      currency-unit string (up to 6 decimal
                                      places).
                                    examples:
                                      - '50.00'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - packageSize
                                  - packagePrice
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Percentage pricing: a percentage taken over
                                  the monetary base amount consumed. Only valid
                                  for charges on Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: percentage pricing.'
                                    enum:
                                      - percentage
                                  percentage:
                                    type: string
                                    pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                    description: >-
                                      Percentage applied to the base amount, as
                                      a decimal string from 0 to 100 (up to 6
                                      decimal places).
                                    examples:
                                      - '2.5'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - percentage
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered per-unit pricing: units are priced by
                                  the tier ladder defined in the charge's tiers,
                                  every tier priced per unit. Not valid for
                                  charges on Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered per-unit pricing.'
                                    enum:
                                      - tiered_per_unit
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered percentage pricing: the monetary base
                                  amount is priced by the tier ladder defined in
                                  the charge's tiers, every tier priced as a
                                  percentage. Only valid for charges on
                                  Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered percentage pricing.'
                                    enum:
                                      - tiered_percentage
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered fixed pricing: the tier containing the
                                  total usage bills its flat amount. Always
                                  volume mode. Usage beyond the last tier can be
                                  billed through unitOverage or
                                  percentageOverage (mutually exclusive);
                                  configuring one requires a bounded final tier.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered fixed pricing.'
                                    enum:
                                      - tiered_fixed
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      Must be volume for tiered fixed pricing:
                                      the single tier containing the total usage
                                      bills its flat amount.
                                  unitOverage:
                                    type: object
                                    description: >-
                                      Optional overage price for units beyond
                                      the last tier, for charges on Unit-type
                                      resources. Mutually exclusive with
                                      percentageOverage.
                                    properties:
                                      excessUnitPrice:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit beyond the last tier, as
                                          a decimal currency-unit string (up to 6
                                          decimal places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - excessUnitPrice
                                    additionalProperties: false
                                  percentageOverage:
                                    type: object
                                    description: >-
                                      Optional overage percentage for the base
                                      amount beyond the last tier, for charges
                                      on Currency-type resources. Mutually
                                      exclusive with unitOverage.
                                    properties:
                                      excessPercentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          beyond the last tier, as a decimal
                                          string from 0 to 100 (up to 6 decimal
                                          places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - excessPercentage
                                    additionalProperties: false
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                not:
                                  required:
                                    - unitOverage
                                    - percentageOverage
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Advanced pricing: a tier ladder mixing tier
                                  pricing types (per unit, percentage, per
                                  package, flat). On a Unit-type resource the
                                  tiers can be per_unit, per_package or flat; on
                                  a Currency-type resource, percentage or flat.
                                  Also used for charges priced before single
                                  pricing models existed.
                                properties:
                                  model:
                                    description: >-
                                      Discriminator: advanced (mixed-tier)
                                      pricing.
                                    enum:
                                      - advanced
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                          tiers:
                            type: array
                            items:
                              type: object
                              description: >-
                                A price tier: a band of quantity, from one
                                number to another, with its own price. The tiers
                                of a plan charge form a contiguous ladder over
                                its quantity.
                              properties:
                                from:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    Lower bound of the tier band (inclusive), in
                                    resource units — or cents of the monetary
                                    base amount for percentage-priced tiers. The
                                    first tier starts at 0 or 1; each subsequent
                                    tier starts at the previous tier's to + 1.
                                to:
                                  type: integer
                                  minimum: 0
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band (inclusive), in
                                    the same unit as from. Null makes the final
                                    tier unbounded; a finite final bound is only
                                    allowed on tiered_fixed charges with an
                                    overage price configured.
                                pricing:
                                  type: object
                                  description: >-
                                    How usage falling in this tier is priced,
                                    keyed by type: per_unit (price per unit),
                                    percentage (percentage of the base amount),
                                    per_package (price per started package), or
                                    flat (fixed amount for the band).
                                  discriminator:
                                    propertyName: type
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per-unit tier pricing: every unit in the
                                        tier band costs unitPrice. Not valid for
                                        charges on Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: per-unit tier pricing.'
                                          enum:
                                            - per_unit
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            Price per unit within the tier, as a
                                            decimal currency-unit string (up to 6
                                            decimal places).
                                          examples:
                                            - '0.20'
                                        fixedPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          nullable: true
                                          description: >-
                                            Optional flat fee billed on top when the
                                            tier applies, as a decimal currency-unit
                                            string. Only valid on pricingModel
                                            tiered_per_unit. Null when the tier has
                                            no flat fee.
                                          examples:
                                            - '10.00'
                                      required:
                                        - type
                                        - unitPrice
                                        - fixedPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage tier pricing: the base amount
                                        in the tier band is billed at a
                                        percentage. Only valid for charges on
                                        Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: percentage tier pricing.'
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            Percentage applied to the base amount
                                            within the tier, as a decimal string
                                            from 0 to 100 (up to 6 decimal places).
                                          examples:
                                            - '1.5'
                                      required:
                                        - type
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per-package tier pricing: units in the
                                        tier band are charged per started
                                        package of packageSize units. Not valid
                                        for charges on Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: per-package tier pricing.'
                                          enum:
                                            - per_package
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: Number of resource units per package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            Price per package, as a decimal
                                            currency-unit string (up to 6 decimal
                                            places).
                                          examples:
                                            - '45.00'
                                      required:
                                        - type
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Flat tier pricing: usage falling in the
                                        tier band is billed a flat amount,
                                        regardless of the exact quantity.
                                      properties:
                                        type:
                                          description: 'Discriminator: flat tier pricing.'
                                          enum:
                                            - flat
                                        amount:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The flat amount billed for the tier, as
                                            a decimal currency-unit string (up to 6
                                            decimal places).
                                          examples:
                                            - '199.90'
                                      required:
                                        - type
                                        - amount
                                      additionalProperties: false
                              required:
                                - from
                                - to
                                - pricing
                              additionalProperties: false
                            description: >-
                              The tier ladder of the charge, ordered from the
                              lowest band to the highest. Required non-empty for
                              tier-based pricing models (tiered_per_unit,
                              tiered_percentage, tiered_fixed, advanced); must
                              be empty otherwise.
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                          currencyUnitCode:
                            type: string
                            description: >-
                              Code of the currency unit the charge's usage is
                              denominated in, when the credits module is on.
                              Defaults to BRL when omitted.
                            examples:
                              - BRL
                        required:
                          - category
                          - resourceId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                          - tiers
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                      - type: object
                        description: >-
                          A license-based charge: bills the license balance once
                          per period of its billingFrequency, at the close of
                          the period. By default it bills in full the last
                          balance reported before the close; when billingModel
                          is proration, it prorates each change of the balance
                          over the days held.
                        properties:
                          category:
                            description: 'Discriminator: license-based charge.'
                            enum:
                              - license_based
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          licenseId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the license whose
                              reported count the charge bills. The charge bills
                              as the license's own catalog item.
                          pricingModel:
                            type: string
                            enum:
                              - per_unit
                              - per_package
                              - tiered_per_unit
                              - tiered_fixed
                            description: >-
                              How the license count is priced: per_unit (price
                              per license with optional included quantity),
                              per_package (price per started package of
                              licenses), or tiered_per_unit / tiered_fixed (tier
                              ladder over the count). Percentage models do not
                              apply: a license count carries no monetary base.
                              Always matches pricing.model.
                          pricing:
                            type: object
                            description: >-
                              Pricing configuration of a usage-based charge,
                              keyed by model. Must match the charge's
                              pricingModel.
                            discriminator:
                              propertyName: model
                            oneOf:
                              - type: object
                                description: >-
                                  Per-unit pricing: every billable unit costs
                                  unitPrice, after deducting the included
                                  quantity. Not valid for charges on
                                  Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: per-unit pricing.'
                                    enum:
                                      - per_unit
                                  includedQuantity:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional number of units included at no
                                      charge before billing starts.
                                  unitPrice:
                                    type: string
                                    pattern: ^\d+(\.\d{1,6})?$
                                    description: >-
                                      Price per unit, as a decimal currency-unit
                                      string (up to 6 decimal places).
                                    examples:
                                      - '0.25'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - unitPrice
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Per-package pricing: billable units are
                                  charged per started package of packageSize
                                  units, after deducting the included quantity.
                                  Not valid for charges on Currency-type
                                  resources.
                                properties:
                                  model:
                                    description: 'Discriminator: per-package pricing.'
                                    enum:
                                      - per_package
                                  includedQuantity:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional number of units included at no
                                      charge before billing starts.
                                  packageSize:
                                    type: integer
                                    minimum: 1
                                    description: Number of resource units per package.
                                  packagePrice:
                                    type: string
                                    pattern: ^\d+(\.\d{1,6})?$
                                    description: >-
                                      Price per package, as a decimal
                                      currency-unit string (up to 6 decimal
                                      places).
                                    examples:
                                      - '50.00'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - packageSize
                                  - packagePrice
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Percentage pricing: a percentage taken over
                                  the monetary base amount consumed. Only valid
                                  for charges on Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: percentage pricing.'
                                    enum:
                                      - percentage
                                  percentage:
                                    type: string
                                    pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                    description: >-
                                      Percentage applied to the base amount, as
                                      a decimal string from 0 to 100 (up to 6
                                      decimal places).
                                    examples:
                                      - '2.5'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - percentage
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered per-unit pricing: units are priced by
                                  the tier ladder defined in the charge's tiers,
                                  every tier priced per unit. Not valid for
                                  charges on Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered per-unit pricing.'
                                    enum:
                                      - tiered_per_unit
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered percentage pricing: the monetary base
                                  amount is priced by the tier ladder defined in
                                  the charge's tiers, every tier priced as a
                                  percentage. Only valid for charges on
                                  Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered percentage pricing.'
                                    enum:
                                      - tiered_percentage
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered fixed pricing: the tier containing the
                                  total usage bills its flat amount. Always
                                  volume mode. Usage beyond the last tier can be
                                  billed through unitOverage or
                                  percentageOverage (mutually exclusive);
                                  configuring one requires a bounded final tier.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered fixed pricing.'
                                    enum:
                                      - tiered_fixed
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      Must be volume for tiered fixed pricing:
                                      the single tier containing the total usage
                                      bills its flat amount.
                                  unitOverage:
                                    type: object
                                    description: >-
                                      Optional overage price for units beyond
                                      the last tier, for charges on Unit-type
                                      resources. Mutually exclusive with
                                      percentageOverage.
                                    properties:
                                      excessUnitPrice:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit beyond the last tier, as
                                          a decimal currency-unit string (up to 6
                                          decimal places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - excessUnitPrice
                                    additionalProperties: false
                                  percentageOverage:
                                    type: object
                                    description: >-
                                      Optional overage percentage for the base
                                      amount beyond the last tier, for charges
                                      on Currency-type resources. Mutually
                                      exclusive with unitOverage.
                                    properties:
                                      excessPercentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          beyond the last tier, as a decimal
                                          string from 0 to 100 (up to 6 decimal
                                          places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - excessPercentage
                                    additionalProperties: false
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                not:
                                  required:
                                    - unitOverage
                                    - percentageOverage
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Advanced pricing: a tier ladder mixing tier
                                  pricing types (per unit, percentage, per
                                  package, flat). On a Unit-type resource the
                                  tiers can be per_unit, per_package or flat; on
                                  a Currency-type resource, percentage or flat.
                                  Also used for charges priced before single
                                  pricing models existed.
                                properties:
                                  model:
                                    description: >-
                                      Discriminator: advanced (mixed-tier)
                                      pricing.
                                    enum:
                                      - advanced
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                          billingModel:
                            type: string
                            enum:
                              - in_full
                              - proration
                            description: >-
                              Optional. How the license balance bills over the
                              charge's period: in_full (the default) bills the
                              last balance reported before the period closes,
                              for the whole period; proration bills the opening
                              balance at full price plus one prorated delta per
                              change during the cycle. Proration requires
                              per_unit pricing, or tiered_per_unit in
                              progressive mode: only tier unit prices prorate,
                              and tier flat prices bill in full for the bands
                              that the closing balance reaches.
                          tiers:
                            type: array
                            items:
                              type: object
                              description: >-
                                A price tier: a band of quantity, from one
                                number to another, with its own price. The tiers
                                of a plan charge form a contiguous ladder over
                                its quantity.
                              properties:
                                from:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    Lower bound of the tier band (inclusive), in
                                    resource units — or cents of the monetary
                                    base amount for percentage-priced tiers. The
                                    first tier starts at 0 or 1; each subsequent
                                    tier starts at the previous tier's to + 1.
                                to:
                                  type: integer
                                  minimum: 0
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band (inclusive), in
                                    the same unit as from. Null makes the final
                                    tier unbounded; a finite final bound is only
                                    allowed on tiered_fixed charges with an
                                    overage price configured.
                                pricing:
                                  type: object
                                  description: >-
                                    How usage falling in this tier is priced,
                                    keyed by type: per_unit (price per unit),
                                    percentage (percentage of the base amount),
                                    per_package (price per started package), or
                                    flat (fixed amount for the band).
                                  discriminator:
                                    propertyName: type
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per-unit tier pricing: every unit in the
                                        tier band costs unitPrice. Not valid for
                                        charges on Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: per-unit tier pricing.'
                                          enum:
                                            - per_unit
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            Price per unit within the tier, as a
                                            decimal currency-unit string (up to 6
                                            decimal places).
                                          examples:
                                            - '0.20'
                                        fixedPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          nullable: true
                                          description: >-
                                            Optional flat fee billed on top when the
                                            tier applies, as a decimal currency-unit
                                            string. Only valid on pricingModel
                                            tiered_per_unit. Null when the tier has
                                            no flat fee.
                                          examples:
                                            - '10.00'
                                      required:
                                        - type
                                        - unitPrice
                                        - fixedPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage tier pricing: the base amount
                                        in the tier band is billed at a
                                        percentage. Only valid for charges on
                                        Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: percentage tier pricing.'
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            Percentage applied to the base amount
                                            within the tier, as a decimal string
                                            from 0 to 100 (up to 6 decimal places).
                                          examples:
                                            - '1.5'
                                      required:
                                        - type
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per-package tier pricing: units in the
                                        tier band are charged per started
                                        package of packageSize units. Not valid
                                        for charges on Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: per-package tier pricing.'
                                          enum:
                                            - per_package
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: Number of resource units per package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            Price per package, as a decimal
                                            currency-unit string (up to 6 decimal
                                            places).
                                          examples:
                                            - '45.00'
                                      required:
                                        - type
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Flat tier pricing: usage falling in the
                                        tier band is billed a flat amount,
                                        regardless of the exact quantity.
                                      properties:
                                        type:
                                          description: 'Discriminator: flat tier pricing.'
                                          enum:
                                            - flat
                                        amount:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The flat amount billed for the tier, as
                                            a decimal currency-unit string (up to 6
                                            decimal places).
                                          examples:
                                            - '199.90'
                                      required:
                                        - type
                                        - amount
                                      additionalProperties: false
                              required:
                                - from
                                - to
                                - pricing
                              additionalProperties: false
                            description: >-
                              The tier ladder of the charge, ordered from the
                              lowest band to the highest. Required non-empty for
                              tier-based pricing models (tiered_per_unit,
                              tiered_fixed); must be empty otherwise.
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                        required:
                          - category
                          - licenseId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                          - tiers
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                      - type: object
                        description: >-
                          A custom charge: bills the amount that the calculator
                          that Aira writes for you computes from the inputs the
                          charge chooses among its custom charge definition's
                          inputs and from the charge's parameter values. Bills
                          in arrears in the default currency.
                        properties:
                          category:
                            description: 'Discriminator: custom charge.'
                            enum:
                              - custom
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          itemId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the catalog item this
                              charge bills.
                          customChargeDefinitionId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the custom charge
                              definition the charge follows.
                          chosenResourceIds:
                            type: array
                            items:
                              type: string
                              format: uuid
                            uniqueItems: true
                            description: >-
                              The unique identifiers of the metered resources
                              that the charge chooses as its inputs, from the
                              definition's inputResourceIds. Together with
                              chosenLicenseIds, the charge chooses exactly the
                              definition's chosenInputCount inputs. Omitting it
                              chooses no resource.
                          chosenLicenseIds:
                            type: array
                            items:
                              type: string
                              format: uuid
                            uniqueItems: true
                            description: >-
                              The unique identifiers of the licenses that the
                              charge chooses as its inputs, from the
                              definition's inputLicenseIds. Together with
                              chosenResourceIds, the charge chooses exactly the
                              definition's chosenInputCount inputs. Omitting it
                              chooses no license.
                          pricingModel:
                            type: string
                            description: >-
                              Custom charges always use custom pricing: the
                              calculator that Aira writes for you computes the
                              amount from the charge's parameter values.
                            enum:
                              - custom
                          pricing:
                            type: object
                            description: >-
                              Custom pricing: schema-defined commercial
                              parameters priced by the calculator that Aira
                              writes for you. The only pricing available for
                              custom charges.
                            properties:
                              model:
                                description: 'Discriminator: custom pricing.'
                                enum:
                                  - custom
                              parameters:
                                type: object
                                additionalProperties: true
                                description: >-
                                  The charge's commercial parameter values,
                                  keyed by the field keys of the referenced
                                  custom charge definition's parameter schema.
                                  Validated against that parameter schema when
                                  the charge is saved.
                            required:
                              - model
                              - parameters
                            additionalProperties: false
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                        required:
                          - category
                          - itemId
                          - customChargeDefinitionId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                  description: >-
                    The plan charges of the first plan version of the plan, each
                    at the position of its index in the list.
              required:
                - name
                - productId
                - planCharges
              additionalProperties: false
        required: true
        description: The plan to create, with the plan charges of its first plan version.
      x-public-api: true
      x-errors:
        - status: 400
          code: product_not_found
          when: no product has the `productId`
        - &ref_17
          status: 400
          code: invalid_plan_charges
          when: >-
            a plan charge breaks a rule of plan charges, such as tiers that
            leave a gap, an item, a resource or a license that does not exist,
            two minimum commitments with the same billing frequency, or billing
            frequencies in both months and weeks
        - &ref_18
          status: 400
          code: billing_frequency_not_yet_supported
          when: >-
            a license-based charge with the billing model `proration`, or a
            usage-based charge on a resource with the billing model `proration`,
            has a billing frequency of more than one month or one week
        - &ref_19
          status: 400
          code: currency_unit_not_found
          when: no currency unit has the `currencyUnitCode` of a usage-based charge
      x-required-roles: &ref_20
        - plans:write
      responses:
        '201':
          description: >-
            A plan, a reusable set of charges of the catalog, with its product
            and its active plan version. A contract bills a plan through a plan
            instance.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the plan in our system.
                  name:
                    type: string
                    minLength: 1
                    description: The name of the plan.
                    example: Plano Essencial
                  description:
                    description: The description of the plan, or null when it has none.
                    type:
                      - 'null'
                      - string
                    example: Assinatura mensal com entrega diária de pães.
                  product:
                    type: object
                    description: The product that the plan belongs to.
                    properties:
                      id:
                        description: The unique identifier of the product in our system.
                        type: string
                        format: uuid
                      name:
                        description: The name of the product.
                        type: string
                        minLength: 1
                        example: Platform subscription
                    required:
                      - id
                      - name
                    additionalProperties: false
                  activePlanVersion:
                    type: object
                    description: >-
                      The active plan version of the plan, whose plan charges a
                      new plan instance of the plan bills.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the plan version in our
                          system.
                      versionNumber:
                        type: number
                        minimum: 1
                        description: >-
                          The number of the plan version in its plan, from 1,
                          one more for each new plan version.
                      isActive:
                        type: boolean
                        description: >-
                          Whether the plan version is the active plan version of
                          its plan, whose plan charges a new plan instance of
                          the plan bills. A plan has one active plan version.
                      planCharges:
                        type: array
                        items:
                          type: object
                          description: >-
                            Schema representing a plan charge, one priced line
                            of a plan: its item names what it bills, its
                            category says what it bills from, its pricing model
                            turns a quantity into money, and its billing
                            frequency says how often it bills. The fields of a
                            charge depend on its category. An amount is an
                            integer number of cents, and a price is a decimal
                            string with up to 6 decimal places, in BRL or in the
                            credit unit of the charge.
                          discriminator:
                            propertyName: category
                          oneOf:
                            - type: object
                              description: >-
                                A fixed charge: the same amount in every charge
                                period, billed on the invoice that its billing
                                timing names.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: fixed.'
                                  enum:
                                    - fixed
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    fixed.
                                  enum:
                                    - fixed
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a fixed charge or of a minimum
                                    commitment.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: fixed.'
                                      enum:
                                        - fixed
                                    amount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The amount that the charge bills in each
                                        charge period, in cents, or the amount
                                        of one unit when the charge has a
                                        quantity. For a minimum commitment, the
                                        least that the charges of the plan with
                                        its billing frequency bill.
                                    quantity:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units that a fixed charge
                                        bills in each charge period, when it has
                                        one, so that each charge period bills
                                        quantity times amount. A minimum
                                        commitment has none.
                                  required:
                                    - model
                                    - amount
                                  additionalProperties: false
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    When the charge bills a charge period:
                                    in_arrears bills it on the closing invoice
                                    of its last cycle, and in_advance bills it
                                    before it starts, on the activation invoice
                                    or on the closing invoice of the cycle
                                    before. The billing timing moves the
                                    invoice, never the amount.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - billingTiming
                              additionalProperties: false
                            - type: object
                              description: >-
                                A minimum commitment: the least that the plan
                                bills in a charge period. When the charges of
                                the plan with the same billing frequency total
                                less, the charge bills the difference. A plan
                                has at most one for each billing frequency.
                              properties:
                                category:
                                  type: string
                                  description: >-
                                    The category of the charge:
                                    minimum_commitment.
                                  enum:
                                    - minimum_commitment
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    fixed.
                                  enum:
                                    - fixed
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a fixed charge or of a minimum
                                    commitment.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: fixed.'
                                      enum:
                                        - fixed
                                    amount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The amount that the charge bills in each
                                        charge period, in cents, or the amount
                                        of one unit when the charge has a
                                        quantity. For a minimum commitment, the
                                        least that the charges of the plan with
                                        its billing frequency bill.
                                    quantity:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units that a fixed charge
                                        bills in each charge period, when it has
                                        one, so that each charge period bills
                                        quantity times amount. A minimum
                                        commitment has none.
                                  required:
                                    - model
                                    - amount
                                  additionalProperties: false
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                              additionalProperties: false
                            - type: object
                              description: >-
                                A usage-based charge: a charge on the usage of a
                                resource in its charge period, priced by its
                                pricing model.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: usage_based.'
                                  enum:
                                    - usage_based
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  enum:
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                  description: >-
                                    The pricing model of the charge, the same as
                                    pricing.model. per_unit, per_package and
                                    tiered_per_unit price a resource in units,
                                    percentage and tiered_percentage price a
                                    resource in money, and tiered_fixed and
                                    advanced price either.
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a usage-based or license-based
                                    charge, by pricing model. Its model is the
                                    pricingModel of the charge.
                                  discriminator:
                                    propertyName: model
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per unit: each unit of the charge period
                                        past the included quantity costs
                                        unitPrice. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_unit.
                                          enum:
                                            - per_unit
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit, as a decimal
                                            string.
                                          examples:
                                            - '0.25'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - unitPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per package: the units of the charge
                                        period past the included quantity bill
                                        packagePrice for each package of
                                        packageSize units that they start. A
                                        charge on a resource in money cannot
                                        have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_package.
                                          enum:
                                            - per_package
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: The number of units in one package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one package, as a decimal
                                            string.
                                          examples:
                                            - '50.00'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage: the charge bills a
                                        percentage of the usage of its resource
                                        in the charge period. Only a charge on a
                                        resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            percentage.
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage that the
                                            charge bills, as a decimal string from 0
                                            to 100.
                                          examples:
                                            - '2.5'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered per unit: the tiers of the charge
                                        price its units, and each tier prices
                                        them per unit. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_per_unit.
                                          enum:
                                            - tiered_per_unit
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered percentage: the tiers of the
                                        charge price its usage, and each tier
                                        bills a percentage of it. Only a charge
                                        on a resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_percentage.
                                          enum:
                                            - tiered_percentage
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered fixed: the tier that the whole
                                        quantity reaches bills its flat amount.
                                        When the last tier has an end,
                                        unitOverage or percentageOverage prices
                                        the quantity past it, and a charge never
                                        has both.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_fixed.
                                          enum:
                                            - tiered_fixed
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            Always volume, because the tier that the
                                            whole quantity reaches bills its flat
                                            amount.
                                        unitOverage:
                                          type: object
                                          description: >-
                                            The price of the units past the last
                                            tier, for a charge on a resource in
                                            units or on a license, when the charge
                                            has one.
                                          properties:
                                            excessUnitPrice:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                The price of one unit past the last
                                                tier, as a decimal string.
                                              examples:
                                                - '0.30'
                                          required:
                                            - excessUnitPrice
                                          additionalProperties: false
                                        percentageOverage:
                                          type: object
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, for a
                                            charge on a resource in money, when the
                                            charge has one.
                                          properties:
                                            excessPercentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                The percentage of the usage past the
                                                last tier that the charge bills, as a
                                                decimal string from 0 to 100.
                                              examples:
                                                - '1.5'
                                          required:
                                            - excessPercentage
                                          additionalProperties: false
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      not:
                                        required:
                                          - unitOverage
                                          - percentageOverage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Advanced: tiers of mixed types price the
                                        quantity. The tiers of a charge on a
                                        resource in units are per_unit,
                                        per_package or flat, and those of a
                                        charge on a resource in money are
                                        percentage or flat. A charge priced
                                        before the other pricing models existed
                                        has it too.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            advanced.
                                          enum:
                                            - advanced
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                resourceId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the resource whose
                                    usage the charge prices.
                                currencyUnit:
                                  type: object
                                  description: >-
                                    The currency unit that the charge is priced
                                    in, or null when the charge has none. A
                                    charge with no currency unit or in BRL, the
                                    default currency unit, bills money. A charge
                                    in any other currency unit, a credit unit,
                                    decreases the balance of a credit pool in
                                    that unit and bills no money.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the currency
                                        unit in our system.
                                    name:
                                      type: string
                                      description: The name of the currency unit.
                                      examples:
                                        - Real
                                    code:
                                      type: string
                                      description: The short code of the currency unit.
                                      examples:
                                        - BRL
                                  required:
                                    - id
                                    - name
                                    - code
                                  additionalProperties: false
                                  nullable: true
                                tiers:
                                  type: array
                                  items:
                                    type: object
                                    description: >-
                                      A price tier of the charge: a band of
                                      quantity, from one number to another, with
                                      its own price. The first tier starts at 0
                                      or 1, and each tier starts at the to of
                                      the tier before it plus 1.
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                        description: >-
                                          The unique identifier of the tier in our
                                          system.
                                      position:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The position of the tier in the charge,
                                          from 0, from the lowest band to the
                                          highest.
                                      from:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The first quantity of the band, which
                                          the band includes: a number of units of
                                          the resource or of the license, or of
                                          cents for a resource in money.
                                      to:
                                        type: integer
                                        minimum: 0
                                        nullable: true
                                        description: >-
                                          The last quantity of the band, which the
                                          band includes, in the unit of from, or
                                          null when the band has no end. The last
                                          tier has an end only on a charge with
                                          the pricing model tiered_fixed and an
                                          overage.
                                      pricing:
                                        type: object
                                        description: >-
                                          The price of the quantity that falls in
                                          the tier, by type: per_unit, percentage,
                                          per_package or flat.
                                        discriminator:
                                          propertyName: type
                                        oneOf:
                                          - type: object
                                            description: >-
                                              Per unit: each unit in the tier costs
                                              unitPrice. A charge on a resource in
                                              money cannot have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_unit.'
                                                enum:
                                                  - per_unit
                                              unitPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one unit in the tier, as a
                                                  decimal string.
                                                examples:
                                                  - '0.20'
                                              fixedPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                nullable: true
                                                description: >-
                                                  An amount that the tier bills on top of
                                                  its units when the tier applies, as a
                                                  decimal string, or null when it has
                                                  none. Only a tier of a charge with the
                                                  pricing model tiered_per_unit has an
                                                  amount other than zero.
                                                examples:
                                                  - '10.00'
                                            required:
                                              - type
                                              - unitPrice
                                              - fixedPrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Percentage: the tier bills a percentage
                                              of the usage that falls in it. Only a
                                              charge on a resource in money has it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: percentage.'
                                                enum:
                                                  - percentage
                                              percentage:
                                                type: string
                                                pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                description: >-
                                                  The percentage of the usage in the tier
                                                  that the tier bills, as a decimal string
                                                  from 0 to 100.
                                                examples:
                                                  - '1.5'
                                            required:
                                              - type
                                              - percentage
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Per package: the units in the tier bill
                                              packagePrice for each package of
                                              packageSize units that they start. A
                                              charge on a resource in money cannot
                                              have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_package.'
                                                enum:
                                                  - per_package
                                              packageSize:
                                                type: integer
                                                minimum: 1
                                                description: The number of units in one package.
                                              packagePrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one package, as a decimal
                                                  string.
                                                examples:
                                                  - '45.00'
                                            required:
                                              - type
                                              - packageSize
                                              - packagePrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Flat: the tier bills one amount,
                                              whatever the quantity that falls in it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: flat.'
                                                enum:
                                                  - flat
                                              amount:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The amount that the tier bills, as a
                                                  decimal string.
                                                examples:
                                                  - '199.90'
                                            required:
                                              - type
                                              - amount
                                            additionalProperties: false
                                    required:
                                      - id
                                      - position
                                      - from
                                      - to
                                      - pricing
                                    additionalProperties: false
                                  description: >-
                                    The price tiers of the charge, from the
                                    lowest band to the highest, for the pricing
                                    models tiered_per_unit, tiered_percentage,
                                    tiered_fixed and advanced, or an empty list
                                    for the other pricing models.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - resourceId
                                - currencyUnit
                                - tiers
                              additionalProperties: false
                            - type: object
                              description: >-
                                A license-based charge: a charge on the balance
                                of a license in its charge period, read by its
                                billing model and priced by its pricing model.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: license_based.'
                                  enum:
                                    - license_based
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  enum:
                                    - per_unit
                                    - per_package
                                    - tiered_per_unit
                                    - tiered_fixed
                                  description: >-
                                    The pricing model of the charge, the same as
                                    pricing.model: per_unit, per_package,
                                    tiered_per_unit or tiered_fixed. No
                                    percentage applies, because the balance of a
                                    license is a count, not an amount of money.
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a usage-based or license-based
                                    charge, by pricing model. Its model is the
                                    pricingModel of the charge.
                                  discriminator:
                                    propertyName: model
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per unit: each unit of the charge period
                                        past the included quantity costs
                                        unitPrice. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_unit.
                                          enum:
                                            - per_unit
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit, as a decimal
                                            string.
                                          examples:
                                            - '0.25'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - unitPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per package: the units of the charge
                                        period past the included quantity bill
                                        packagePrice for each package of
                                        packageSize units that they start. A
                                        charge on a resource in money cannot
                                        have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_package.
                                          enum:
                                            - per_package
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: The number of units in one package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one package, as a decimal
                                            string.
                                          examples:
                                            - '50.00'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage: the charge bills a
                                        percentage of the usage of its resource
                                        in the charge period. Only a charge on a
                                        resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            percentage.
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage that the
                                            charge bills, as a decimal string from 0
                                            to 100.
                                          examples:
                                            - '2.5'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered per unit: the tiers of the charge
                                        price its units, and each tier prices
                                        them per unit. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_per_unit.
                                          enum:
                                            - tiered_per_unit
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered percentage: the tiers of the
                                        charge price its usage, and each tier
                                        bills a percentage of it. Only a charge
                                        on a resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_percentage.
                                          enum:
                                            - tiered_percentage
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered fixed: the tier that the whole
                                        quantity reaches bills its flat amount.
                                        When the last tier has an end,
                                        unitOverage or percentageOverage prices
                                        the quantity past it, and a charge never
                                        has both.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_fixed.
                                          enum:
                                            - tiered_fixed
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            Always volume, because the tier that the
                                            whole quantity reaches bills its flat
                                            amount.
                                        unitOverage:
                                          type: object
                                          description: >-
                                            The price of the units past the last
                                            tier, for a charge on a resource in
                                            units or on a license, when the charge
                                            has one.
                                          properties:
                                            excessUnitPrice:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                The price of one unit past the last
                                                tier, as a decimal string.
                                              examples:
                                                - '0.30'
                                          required:
                                            - excessUnitPrice
                                          additionalProperties: false
                                        percentageOverage:
                                          type: object
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, for a
                                            charge on a resource in money, when the
                                            charge has one.
                                          properties:
                                            excessPercentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                The percentage of the usage past the
                                                last tier that the charge bills, as a
                                                decimal string from 0 to 100.
                                              examples:
                                                - '1.5'
                                          required:
                                            - excessPercentage
                                          additionalProperties: false
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      not:
                                        required:
                                          - unitOverage
                                          - percentageOverage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Advanced: tiers of mixed types price the
                                        quantity. The tiers of a charge on a
                                        resource in units are per_unit,
                                        per_package or flat, and those of a
                                        charge on a resource in money are
                                        percentage or flat. A charge priced
                                        before the other pricing models existed
                                        has it too.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            advanced.
                                          enum:
                                            - advanced
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                licenseId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the license whose
                                    balance the charge bills.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the charge reads the balance of its
                                    license in a charge period: in_full bills
                                    the last balance, and proration weighs each
                                    balance by the days that it was in effect.
                                tiers:
                                  type: array
                                  items:
                                    type: object
                                    description: >-
                                      A price tier of the charge: a band of
                                      quantity, from one number to another, with
                                      its own price. The first tier starts at 0
                                      or 1, and each tier starts at the to of
                                      the tier before it plus 1.
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                        description: >-
                                          The unique identifier of the tier in our
                                          system.
                                      position:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The position of the tier in the charge,
                                          from 0, from the lowest band to the
                                          highest.
                                      from:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The first quantity of the band, which
                                          the band includes: a number of units of
                                          the resource or of the license, or of
                                          cents for a resource in money.
                                      to:
                                        type: integer
                                        minimum: 0
                                        nullable: true
                                        description: >-
                                          The last quantity of the band, which the
                                          band includes, in the unit of from, or
                                          null when the band has no end. The last
                                          tier has an end only on a charge with
                                          the pricing model tiered_fixed and an
                                          overage.
                                      pricing:
                                        type: object
                                        description: >-
                                          The price of the quantity that falls in
                                          the tier, by type: per_unit, percentage,
                                          per_package or flat.
                                        discriminator:
                                          propertyName: type
                                        oneOf:
                                          - type: object
                                            description: >-
                                              Per unit: each unit in the tier costs
                                              unitPrice. A charge on a resource in
                                              money cannot have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_unit.'
                                                enum:
                                                  - per_unit
                                              unitPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one unit in the tier, as a
                                                  decimal string.
                                                examples:
                                                  - '0.20'
                                              fixedPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                nullable: true
                                                description: >-
                                                  An amount that the tier bills on top of
                                                  its units when the tier applies, as a
                                                  decimal string, or null when it has
                                                  none. Only a tier of a charge with the
                                                  pricing model tiered_per_unit has an
                                                  amount other than zero.
                                                examples:
                                                  - '10.00'
                                            required:
                                              - type
                                              - unitPrice
                                              - fixedPrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Percentage: the tier bills a percentage
                                              of the usage that falls in it. Only a
                                              charge on a resource in money has it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: percentage.'
                                                enum:
                                                  - percentage
                                              percentage:
                                                type: string
                                                pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                description: >-
                                                  The percentage of the usage in the tier
                                                  that the tier bills, as a decimal string
                                                  from 0 to 100.
                                                examples:
                                                  - '1.5'
                                            required:
                                              - type
                                              - percentage
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Per package: the units in the tier bill
                                              packagePrice for each package of
                                              packageSize units that they start. A
                                              charge on a resource in money cannot
                                              have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_package.'
                                                enum:
                                                  - per_package
                                              packageSize:
                                                type: integer
                                                minimum: 1
                                                description: The number of units in one package.
                                              packagePrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one package, as a decimal
                                                  string.
                                                examples:
                                                  - '45.00'
                                            required:
                                              - type
                                              - packageSize
                                              - packagePrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Flat: the tier bills one amount,
                                              whatever the quantity that falls in it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: flat.'
                                                enum:
                                                  - flat
                                              amount:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The amount that the tier bills, as a
                                                  decimal string.
                                                examples:
                                                  - '199.90'
                                            required:
                                              - type
                                              - amount
                                            additionalProperties: false
                                    required:
                                      - id
                                      - position
                                      - from
                                      - to
                                      - pricing
                                    additionalProperties: false
                                  description: >-
                                    The price tiers of the charge, from the
                                    lowest band to the highest, for the pricing
                                    models tiered_per_unit and tiered_fixed, or
                                    an empty list for the other pricing models.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - licenseId
                                - billingModel
                                - tiers
                              additionalProperties: false
                            - type: object
                              description: >-
                                A custom plan charge: a charge whose price comes
                                from code that Aira writes for you, from the
                                custom charge definition that the charge follows
                                and from the parameter values of the charge. It
                                bills in arrears, in money.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: custom.'
                                  enum:
                                    - custom
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    custom.
                                  enum:
                                    - custom
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a custom plan charge: the
                                    parameter values that the code that Aira
                                    writes for you turns into an amount.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: custom.'
                                      enum:
                                        - custom
                                    parameters:
                                      type: object
                                      additionalProperties: true
                                      description: >-
                                        The parameter values of the charge, by
                                        the keys of the parameter schema of its
                                        custom charge definition.
                                  required:
                                    - model
                                    - parameters
                                  additionalProperties: false
                                customChargeDefinitionId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the custom charge
                                    definition that the charge follows.
                                chosenResourceIds:
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                  description: >-
                                    The unique identifiers of the resources that
                                    the charge chose as its inputs, from the
                                    input resources of its custom charge
                                    definition.
                                chosenLicenseIds:
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                  description: >-
                                    The unique identifiers of the licenses that
                                    the charge chose as its inputs, from the
                                    input licenses of its custom charge
                                    definition.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - customChargeDefinitionId
                                - chosenResourceIds
                                - chosenLicenseIds
                              additionalProperties: false
                        description: The plan charges of the plan version.
                    required:
                      - id
                      - versionNumber
                      - isActive
                      - planCharges
                    additionalProperties: false
                required:
                  - id
                  - name
                  - description
                  - product
                  - activePlanVersion
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `product_not_found`: no product has the `productId`.

            - `invalid_plan_charges`: a plan charge breaks a rule of plan
            charges, such as tiers that leave a gap, an item, a resource or a
            license that does not exist, two minimum commitments with the same
            billing frequency, or billing frequencies in both months and weeks.

            - `billing_frequency_not_yet_supported`: a license-based charge with
            the billing model `proration`, or a usage-based charge on a resource
            with the billing model `proration`, has a billing frequency of more
            than one month or one week.

            - `currency_unit_not_found`: no currency unit has the
            `currencyUnitCode` of a usage-based charge.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - product_not_found
                      - invalid_plan_charges
                      - billing_frequency_not_yet_supported
                      - currency_unit_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                product_not_found:
                  value:
                    message: default product not found
                    code: product_not_found
                invalid_plan_charges:
                  value:
                    message: 'plan charge "{itemName}": {reason}'
                    code: invalid_plan_charges
                billing_frequency_not_yet_supported:
                  value:
                    message: >-
                      a license-based charge with the billing model `proration`,
                      or a usage-based charge on a resource with the billing
                      model `proration`, has a billing frequency of more than
                      one month or one week
                    code: billing_frequency_not_yet_supported
                currency_unit_not_found:
                  value:
                    message: currency unit not found
                    code: currency_unit_not_found
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plans:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
    get:
      summary: List plans
      tags:
        - Plans
      description: |-
        Lists the plans, newest first, each with the product that it belongs to.

        Requires the role `plans:read`.
      parameters:
        - schema:
            type: string
          example: essencial
          in: query
          name: search
          required: false
          description: Free-text search over the plan name, ignoring case and accents.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: &ref_21
        - plans:read
      responses:
        '200':
          description: The plans that match the filters, newest first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a plan, a reusable set of charges of
                        the catalog. A contract bills a plan through a plan
                        instance.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: The unique identifier of the plan in our system.
                        name:
                          type: string
                          minLength: 1
                          description: The name of the plan.
                          example: Plano Essencial
                        description:
                          description: >-
                            The description of the plan, or null when it has
                            none.
                          type:
                            - 'null'
                            - string
                          example: Assinatura mensal com entrega diária de pães.
                        product:
                          type: object
                          description: The product that the plan belongs to.
                          properties:
                            id:
                              description: >-
                                The unique identifier of the product in our
                                system.
                              type: string
                              format: uuid
                            name:
                              description: The name of the product.
                              type: string
                              minLength: 1
                              example: Platform subscription
                          required:
                            - id
                            - name
                          additionalProperties: false
                      required:
                        - id
                        - name
                        - description
                        - product
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''search'' must be string'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plans:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/plans/{id}:
    put:
      summary: Update plan
      tags:
        - Plans
      description: >-
        Updates the name, the description and the product of a plan. When the
        plan charges of the body differ from those of the active plan version,
        it also creates a plan version with them, which becomes the active plan
        version of the plan. The plan instances of the plan keep their plan
        instance versions until `POST
        /v1/plan-instances/update-to-latest-plan-version` moves them.


        Requires the role `plans:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  description: The name of the plan.
                  example: Plano Essencial
                description:
                  description: >-
                    The description of the plan, or null for none. Leave it out
                    for none.
                  type:
                    - 'null'
                    - string
                  example: Assinatura mensal com entrega diária de pães.
                productId:
                  type: string
                  format: uuid
                  description: >-
                    The unique identifier of the product that the plan belongs
                    to.
                planCharges:
                  type: array
                  minItems: 1
                  maxItems: 100
                  items:
                    type: object
                    discriminator:
                      propertyName: category
                    oneOf:
                      - type: object
                        description: >-
                          A fixed charge: bills a flat amount once per period of
                          its billingFrequency, at the boundary its
                          billingTiming picks.
                        properties:
                          category:
                            description: 'Discriminator: fixed charge.'
                            enum:
                              - fixed
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          itemId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the catalog item this
                              charge bills.
                          pricingModel:
                            type: string
                            description: >-
                              Fixed and minimum_commitment charges always use
                              fixed pricing.
                            enum:
                              - fixed
                          pricing:
                            type: object
                            description: >-
                              Fixed pricing: a flat amount billed once per
                              period of the charge's billingFrequency. The only
                              pricing available for fixed and minimum_commitment
                              charges.
                            properties:
                              model:
                                description: 'Discriminator: fixed pricing.'
                                enum:
                                  - fixed
                              amount:
                                type: integer
                                minimum: 0
                                description: >-
                                  The flat amount billed per period, in cents.
                                  For minimum_commitment charges, the minimum
                                  the charges sharing its frequency are topped
                                  up to.
                              quantity:
                                type: integer
                                minimum: 1
                                description: >-
                                  Optional, fixed charges only: the quantity
                                  billed. When set, amount is the amount of one
                                  unit and each period of the charge's
                                  billingFrequency bills quantity x amount.
                            required:
                              - model
                              - amount
                            additionalProperties: false
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                          billingTiming:
                            type: string
                            enum:
                              - in_advance
                              - in_arrears
                            description: >-
                              Optional. When the charge's flat fee is billed
                              relative to the period it covers (see
                              billingFrequency): in_arrears (the default) bills
                              the period at the close of the cycle that ends it;
                              in_advance bills it at the boundary that opens it
                              (the contract's activation invoice for the periods
                              its first cycle opens, otherwise the close of the
                              cycle just before the period). Only the timing
                              shifts, never the amount. Valid only on fixed
                              charges. Defaults to in_arrears when omitted.
                        required:
                          - category
                          - itemId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                      - type: object
                        description: >-
                          A minimum commitment charge: at the close of each
                          period of its billingFrequency, tops the plan's
                          charges sharing that frequency up to the configured
                          amount when their total on that calculation stays
                          below it. A plan can have at most one minimum per
                          billing frequency.
                        properties:
                          category:
                            description: 'Discriminator: minimum commitment charge.'
                            enum:
                              - minimum_commitment
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          itemId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the catalog item this
                              charge bills.
                          pricingModel:
                            type: string
                            description: >-
                              Fixed and minimum_commitment charges always use
                              fixed pricing.
                            enum:
                              - fixed
                          pricing:
                            type: object
                            description: >-
                              Fixed pricing: a flat amount billed once per
                              period of the charge's billingFrequency. The only
                              pricing available for fixed and minimum_commitment
                              charges.
                            properties:
                              model:
                                description: 'Discriminator: fixed pricing.'
                                enum:
                                  - fixed
                              amount:
                                type: integer
                                minimum: 0
                                description: >-
                                  The flat amount billed per period, in cents.
                                  For minimum_commitment charges, the minimum
                                  the charges sharing its frequency are topped
                                  up to.
                              quantity:
                                type: integer
                                minimum: 1
                                description: >-
                                  Optional, fixed charges only: the quantity
                                  billed. When set, amount is the amount of one
                                  unit and each period of the charge's
                                  billingFrequency bills quantity x amount.
                            required:
                              - model
                              - amount
                            additionalProperties: false
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                        required:
                          - category
                          - itemId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                      - type: object
                        description: >-
                          A usage-based charge: prices the consumption of a
                          metered resource according to pricingModel.
                        properties:
                          category:
                            description: 'Discriminator: usage-based charge.'
                            enum:
                              - usage_based
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          resourceId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the metered resource
                              whose usage the charge prices.
                          pricingModel:
                            type: string
                            enum:
                              - per_unit
                              - per_package
                              - percentage
                              - tiered_per_unit
                              - tiered_percentage
                              - tiered_fixed
                              - advanced
                            description: >-
                              How the charge is priced: per_unit (price per unit
                              with optional included quantity), per_package
                              (price per started package of units), percentage
                              (a percentage of a monetary base amount),
                              tiered_per_unit / tiered_percentage / tiered_fixed
                              (tier ladder where every tier uses that pricing
                              type), or advanced (tier ladder mixing tier
                              pricing types). per_unit, per_package and
                              tiered_per_unit require a Unit-type resource;
                              percentage and tiered_percentage require a
                              Currency-type resource; tiered_fixed and advanced
                              accept either. Always matches pricing.model.
                          pricing:
                            type: object
                            description: >-
                              Pricing configuration of a usage-based charge,
                              keyed by model. Must match the charge's
                              pricingModel.
                            discriminator:
                              propertyName: model
                            oneOf:
                              - type: object
                                description: >-
                                  Per-unit pricing: every billable unit costs
                                  unitPrice, after deducting the included
                                  quantity. Not valid for charges on
                                  Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: per-unit pricing.'
                                    enum:
                                      - per_unit
                                  includedQuantity:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional number of units included at no
                                      charge before billing starts.
                                  unitPrice:
                                    type: string
                                    pattern: ^\d+(\.\d{1,6})?$
                                    description: >-
                                      Price per unit, as a decimal currency-unit
                                      string (up to 6 decimal places).
                                    examples:
                                      - '0.25'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - unitPrice
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Per-package pricing: billable units are
                                  charged per started package of packageSize
                                  units, after deducting the included quantity.
                                  Not valid for charges on Currency-type
                                  resources.
                                properties:
                                  model:
                                    description: 'Discriminator: per-package pricing.'
                                    enum:
                                      - per_package
                                  includedQuantity:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional number of units included at no
                                      charge before billing starts.
                                  packageSize:
                                    type: integer
                                    minimum: 1
                                    description: Number of resource units per package.
                                  packagePrice:
                                    type: string
                                    pattern: ^\d+(\.\d{1,6})?$
                                    description: >-
                                      Price per package, as a decimal
                                      currency-unit string (up to 6 decimal
                                      places).
                                    examples:
                                      - '50.00'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - packageSize
                                  - packagePrice
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Percentage pricing: a percentage taken over
                                  the monetary base amount consumed. Only valid
                                  for charges on Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: percentage pricing.'
                                    enum:
                                      - percentage
                                  percentage:
                                    type: string
                                    pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                    description: >-
                                      Percentage applied to the base amount, as
                                      a decimal string from 0 to 100 (up to 6
                                      decimal places).
                                    examples:
                                      - '2.5'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - percentage
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered per-unit pricing: units are priced by
                                  the tier ladder defined in the charge's tiers,
                                  every tier priced per unit. Not valid for
                                  charges on Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered per-unit pricing.'
                                    enum:
                                      - tiered_per_unit
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered percentage pricing: the monetary base
                                  amount is priced by the tier ladder defined in
                                  the charge's tiers, every tier priced as a
                                  percentage. Only valid for charges on
                                  Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered percentage pricing.'
                                    enum:
                                      - tiered_percentage
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered fixed pricing: the tier containing the
                                  total usage bills its flat amount. Always
                                  volume mode. Usage beyond the last tier can be
                                  billed through unitOverage or
                                  percentageOverage (mutually exclusive);
                                  configuring one requires a bounded final tier.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered fixed pricing.'
                                    enum:
                                      - tiered_fixed
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      Must be volume for tiered fixed pricing:
                                      the single tier containing the total usage
                                      bills its flat amount.
                                  unitOverage:
                                    type: object
                                    description: >-
                                      Optional overage price for units beyond
                                      the last tier, for charges on Unit-type
                                      resources. Mutually exclusive with
                                      percentageOverage.
                                    properties:
                                      excessUnitPrice:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit beyond the last tier, as
                                          a decimal currency-unit string (up to 6
                                          decimal places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - excessUnitPrice
                                    additionalProperties: false
                                  percentageOverage:
                                    type: object
                                    description: >-
                                      Optional overage percentage for the base
                                      amount beyond the last tier, for charges
                                      on Currency-type resources. Mutually
                                      exclusive with unitOverage.
                                    properties:
                                      excessPercentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          beyond the last tier, as a decimal
                                          string from 0 to 100 (up to 6 decimal
                                          places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - excessPercentage
                                    additionalProperties: false
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                not:
                                  required:
                                    - unitOverage
                                    - percentageOverage
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Advanced pricing: a tier ladder mixing tier
                                  pricing types (per unit, percentage, per
                                  package, flat). On a Unit-type resource the
                                  tiers can be per_unit, per_package or flat; on
                                  a Currency-type resource, percentage or flat.
                                  Also used for charges priced before single
                                  pricing models existed.
                                properties:
                                  model:
                                    description: >-
                                      Discriminator: advanced (mixed-tier)
                                      pricing.
                                    enum:
                                      - advanced
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                          tiers:
                            type: array
                            items:
                              type: object
                              description: >-
                                A price tier: a band of quantity, from one
                                number to another, with its own price. The tiers
                                of a plan charge form a contiguous ladder over
                                its quantity.
                              properties:
                                from:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    Lower bound of the tier band (inclusive), in
                                    resource units — or cents of the monetary
                                    base amount for percentage-priced tiers. The
                                    first tier starts at 0 or 1; each subsequent
                                    tier starts at the previous tier's to + 1.
                                to:
                                  type: integer
                                  minimum: 0
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band (inclusive), in
                                    the same unit as from. Null makes the final
                                    tier unbounded; a finite final bound is only
                                    allowed on tiered_fixed charges with an
                                    overage price configured.
                                pricing:
                                  type: object
                                  description: >-
                                    How usage falling in this tier is priced,
                                    keyed by type: per_unit (price per unit),
                                    percentage (percentage of the base amount),
                                    per_package (price per started package), or
                                    flat (fixed amount for the band).
                                  discriminator:
                                    propertyName: type
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per-unit tier pricing: every unit in the
                                        tier band costs unitPrice. Not valid for
                                        charges on Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: per-unit tier pricing.'
                                          enum:
                                            - per_unit
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            Price per unit within the tier, as a
                                            decimal currency-unit string (up to 6
                                            decimal places).
                                          examples:
                                            - '0.20'
                                        fixedPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          nullable: true
                                          description: >-
                                            Optional flat fee billed on top when the
                                            tier applies, as a decimal currency-unit
                                            string. Only valid on pricingModel
                                            tiered_per_unit. Null when the tier has
                                            no flat fee.
                                          examples:
                                            - '10.00'
                                      required:
                                        - type
                                        - unitPrice
                                        - fixedPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage tier pricing: the base amount
                                        in the tier band is billed at a
                                        percentage. Only valid for charges on
                                        Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: percentage tier pricing.'
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            Percentage applied to the base amount
                                            within the tier, as a decimal string
                                            from 0 to 100 (up to 6 decimal places).
                                          examples:
                                            - '1.5'
                                      required:
                                        - type
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per-package tier pricing: units in the
                                        tier band are charged per started
                                        package of packageSize units. Not valid
                                        for charges on Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: per-package tier pricing.'
                                          enum:
                                            - per_package
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: Number of resource units per package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            Price per package, as a decimal
                                            currency-unit string (up to 6 decimal
                                            places).
                                          examples:
                                            - '45.00'
                                      required:
                                        - type
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Flat tier pricing: usage falling in the
                                        tier band is billed a flat amount,
                                        regardless of the exact quantity.
                                      properties:
                                        type:
                                          description: 'Discriminator: flat tier pricing.'
                                          enum:
                                            - flat
                                        amount:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The flat amount billed for the tier, as
                                            a decimal currency-unit string (up to 6
                                            decimal places).
                                          examples:
                                            - '199.90'
                                      required:
                                        - type
                                        - amount
                                      additionalProperties: false
                              required:
                                - from
                                - to
                                - pricing
                              additionalProperties: false
                            description: >-
                              The tier ladder of the charge, ordered from the
                              lowest band to the highest. Required non-empty for
                              tier-based pricing models (tiered_per_unit,
                              tiered_percentage, tiered_fixed, advanced); must
                              be empty otherwise.
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                          currencyUnitCode:
                            type: string
                            description: >-
                              Code of the currency unit the charge's usage is
                              denominated in, when the credits module is on.
                              Defaults to BRL when omitted.
                            examples:
                              - BRL
                        required:
                          - category
                          - resourceId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                          - tiers
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                      - type: object
                        description: >-
                          A license-based charge: bills the license balance once
                          per period of its billingFrequency, at the close of
                          the period. By default it bills in full the last
                          balance reported before the close; when billingModel
                          is proration, it prorates each change of the balance
                          over the days held.
                        properties:
                          category:
                            description: 'Discriminator: license-based charge.'
                            enum:
                              - license_based
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          licenseId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the license whose
                              reported count the charge bills. The charge bills
                              as the license's own catalog item.
                          pricingModel:
                            type: string
                            enum:
                              - per_unit
                              - per_package
                              - tiered_per_unit
                              - tiered_fixed
                            description: >-
                              How the license count is priced: per_unit (price
                              per license with optional included quantity),
                              per_package (price per started package of
                              licenses), or tiered_per_unit / tiered_fixed (tier
                              ladder over the count). Percentage models do not
                              apply: a license count carries no monetary base.
                              Always matches pricing.model.
                          pricing:
                            type: object
                            description: >-
                              Pricing configuration of a usage-based charge,
                              keyed by model. Must match the charge's
                              pricingModel.
                            discriminator:
                              propertyName: model
                            oneOf:
                              - type: object
                                description: >-
                                  Per-unit pricing: every billable unit costs
                                  unitPrice, after deducting the included
                                  quantity. Not valid for charges on
                                  Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: per-unit pricing.'
                                    enum:
                                      - per_unit
                                  includedQuantity:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional number of units included at no
                                      charge before billing starts.
                                  unitPrice:
                                    type: string
                                    pattern: ^\d+(\.\d{1,6})?$
                                    description: >-
                                      Price per unit, as a decimal currency-unit
                                      string (up to 6 decimal places).
                                    examples:
                                      - '0.25'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - unitPrice
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Per-package pricing: billable units are
                                  charged per started package of packageSize
                                  units, after deducting the included quantity.
                                  Not valid for charges on Currency-type
                                  resources.
                                properties:
                                  model:
                                    description: 'Discriminator: per-package pricing.'
                                    enum:
                                      - per_package
                                  includedQuantity:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional number of units included at no
                                      charge before billing starts.
                                  packageSize:
                                    type: integer
                                    minimum: 1
                                    description: Number of resource units per package.
                                  packagePrice:
                                    type: string
                                    pattern: ^\d+(\.\d{1,6})?$
                                    description: >-
                                      Price per package, as a decimal
                                      currency-unit string (up to 6 decimal
                                      places).
                                    examples:
                                      - '50.00'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - packageSize
                                  - packagePrice
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Percentage pricing: a percentage taken over
                                  the monetary base amount consumed. Only valid
                                  for charges on Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: percentage pricing.'
                                    enum:
                                      - percentage
                                  percentage:
                                    type: string
                                    pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                    description: >-
                                      Percentage applied to the base amount, as
                                      a decimal string from 0 to 100 (up to 6
                                      decimal places).
                                    examples:
                                      - '2.5'
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - percentage
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered per-unit pricing: units are priced by
                                  the tier ladder defined in the charge's tiers,
                                  every tier priced per unit. Not valid for
                                  charges on Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered per-unit pricing.'
                                    enum:
                                      - tiered_per_unit
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered percentage pricing: the monetary base
                                  amount is priced by the tier ladder defined in
                                  the charge's tiers, every tier priced as a
                                  percentage. Only valid for charges on
                                  Currency-type resources.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered percentage pricing.'
                                    enum:
                                      - tiered_percentage
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Tiered fixed pricing: the tier containing the
                                  total usage bills its flat amount. Always
                                  volume mode. Usage beyond the last tier can be
                                  billed through unitOverage or
                                  percentageOverage (mutually exclusive);
                                  configuring one requires a bounded final tier.
                                properties:
                                  model:
                                    description: 'Discriminator: tiered fixed pricing.'
                                    enum:
                                      - tiered_fixed
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      Must be volume for tiered fixed pricing:
                                      the single tier containing the total usage
                                      bills its flat amount.
                                  unitOverage:
                                    type: object
                                    description: >-
                                      Optional overage price for units beyond
                                      the last tier, for charges on Unit-type
                                      resources. Mutually exclusive with
                                      percentageOverage.
                                    properties:
                                      excessUnitPrice:
                                        type: string
                                        pattern: ^\d+(\.\d{1,6})?$
                                        description: >-
                                          Price per unit beyond the last tier, as
                                          a decimal currency-unit string (up to 6
                                          decimal places).
                                        examples:
                                          - '0.30'
                                    required:
                                      - excessUnitPrice
                                    additionalProperties: false
                                  percentageOverage:
                                    type: object
                                    description: >-
                                      Optional overage percentage for the base
                                      amount beyond the last tier, for charges
                                      on Currency-type resources. Mutually
                                      exclusive with unitOverage.
                                    properties:
                                      excessPercentage:
                                        type: string
                                        pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                        description: >-
                                          Percentage applied to the base amount
                                          beyond the last tier, as a decimal
                                          string from 0 to 100 (up to 6 decimal
                                          places).
                                        examples:
                                          - '1.5'
                                    required:
                                      - excessPercentage
                                    additionalProperties: false
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                not:
                                  required:
                                    - unitOverage
                                    - percentageOverage
                                additionalProperties: false
                              - type: object
                                description: >-
                                  Advanced pricing: a tier ladder mixing tier
                                  pricing types (per unit, percentage, per
                                  package, flat). On a Unit-type resource the
                                  tiers can be per_unit, per_package or flat; on
                                  a Currency-type resource, percentage or flat.
                                  Also used for charges priced before single
                                  pricing models existed.
                                properties:
                                  model:
                                    description: >-
                                      Discriminator: advanced (mixed-tier)
                                      pricing.
                                    enum:
                                      - advanced
                                  tierMode:
                                    enum:
                                      - progressive
                                      - volume
                                    description: >-
                                      How the ladder applies: progressive prices
                                      each tier's band separately (graduated);
                                      volume prices all usage at the single tier
                                      containing the total.
                                  fixedAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional flat amount billed once per
                                      period of the charge's billingFrequency,
                                      on top of the priced quantity, in cents.
                                      Rendered as a fixed-price sub-line item
                                      when greater than zero.
                                  minimumAmount:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      Optional floor for the charge, in cents.
                                      When the priced quantity plus fixedAmount
                                      stays below it, a minimum-amount sub-line
                                      item tops the charge up to this value.
                                required:
                                  - model
                                  - tierMode
                                additionalProperties: false
                          billingModel:
                            type: string
                            enum:
                              - in_full
                              - proration
                            description: >-
                              Optional. How the license balance bills over the
                              charge's period: in_full (the default) bills the
                              last balance reported before the period closes,
                              for the whole period; proration bills the opening
                              balance at full price plus one prorated delta per
                              change during the cycle. Proration requires
                              per_unit pricing, or tiered_per_unit in
                              progressive mode: only tier unit prices prorate,
                              and tier flat prices bill in full for the bands
                              that the closing balance reaches.
                          tiers:
                            type: array
                            items:
                              type: object
                              description: >-
                                A price tier: a band of quantity, from one
                                number to another, with its own price. The tiers
                                of a plan charge form a contiguous ladder over
                                its quantity.
                              properties:
                                from:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    Lower bound of the tier band (inclusive), in
                                    resource units — or cents of the monetary
                                    base amount for percentage-priced tiers. The
                                    first tier starts at 0 or 1; each subsequent
                                    tier starts at the previous tier's to + 1.
                                to:
                                  type: integer
                                  minimum: 0
                                  nullable: true
                                  description: >-
                                    Upper bound of the tier band (inclusive), in
                                    the same unit as from. Null makes the final
                                    tier unbounded; a finite final bound is only
                                    allowed on tiered_fixed charges with an
                                    overage price configured.
                                pricing:
                                  type: object
                                  description: >-
                                    How usage falling in this tier is priced,
                                    keyed by type: per_unit (price per unit),
                                    percentage (percentage of the base amount),
                                    per_package (price per started package), or
                                    flat (fixed amount for the band).
                                  discriminator:
                                    propertyName: type
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per-unit tier pricing: every unit in the
                                        tier band costs unitPrice. Not valid for
                                        charges on Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: per-unit tier pricing.'
                                          enum:
                                            - per_unit
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            Price per unit within the tier, as a
                                            decimal currency-unit string (up to 6
                                            decimal places).
                                          examples:
                                            - '0.20'
                                        fixedPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          nullable: true
                                          description: >-
                                            Optional flat fee billed on top when the
                                            tier applies, as a decimal currency-unit
                                            string. Only valid on pricingModel
                                            tiered_per_unit. Null when the tier has
                                            no flat fee.
                                          examples:
                                            - '10.00'
                                      required:
                                        - type
                                        - unitPrice
                                        - fixedPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage tier pricing: the base amount
                                        in the tier band is billed at a
                                        percentage. Only valid for charges on
                                        Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: percentage tier pricing.'
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            Percentage applied to the base amount
                                            within the tier, as a decimal string
                                            from 0 to 100 (up to 6 decimal places).
                                          examples:
                                            - '1.5'
                                      required:
                                        - type
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per-package tier pricing: units in the
                                        tier band are charged per started
                                        package of packageSize units. Not valid
                                        for charges on Currency-type resources.
                                      properties:
                                        type:
                                          description: 'Discriminator: per-package tier pricing.'
                                          enum:
                                            - per_package
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: Number of resource units per package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            Price per package, as a decimal
                                            currency-unit string (up to 6 decimal
                                            places).
                                          examples:
                                            - '45.00'
                                      required:
                                        - type
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Flat tier pricing: usage falling in the
                                        tier band is billed a flat amount,
                                        regardless of the exact quantity.
                                      properties:
                                        type:
                                          description: 'Discriminator: flat tier pricing.'
                                          enum:
                                            - flat
                                        amount:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The flat amount billed for the tier, as
                                            a decimal currency-unit string (up to 6
                                            decimal places).
                                          examples:
                                            - '199.90'
                                      required:
                                        - type
                                        - amount
                                      additionalProperties: false
                              required:
                                - from
                                - to
                                - pricing
                              additionalProperties: false
                            description: >-
                              The tier ladder of the charge, ordered from the
                              lowest band to the highest. Required non-empty for
                              tier-based pricing models (tiered_per_unit,
                              tiered_fixed); must be empty otherwise.
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                        required:
                          - category
                          - licenseId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                          - tiers
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                      - type: object
                        description: >-
                          A custom charge: bills the amount that the calculator
                          that Aira writes for you computes from the inputs the
                          charge chooses among its custom charge definition's
                          inputs and from the charge's parameter values. Bills
                          in arrears in the default currency.
                        properties:
                          category:
                            description: 'Discriminator: custom charge.'
                            enum:
                              - custom
                          name:
                            type: string
                            minLength: 1
                            description: >-
                              Display name of the charge as it appears on
                              invoices. Required when isCustomNameEnabled is
                              true. When isCustomNameEnabled is false, the name
                              follows the name of the resource of the charge,
                              else of its license, else of its catalog item.
                            examples:
                              - Mensalidade
                          isCustomNameEnabled:
                            type: boolean
                            description: >-
                              Whether name is customized for this charge. When
                              false, the name follows the name of the resource
                              of the charge, else of its license, else of its
                              catalog item.
                          itemId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the catalog item this
                              charge bills.
                          customChargeDefinitionId:
                            type: string
                            format: uuid
                            description: >-
                              The unique identifier of the custom charge
                              definition the charge follows.
                          chosenResourceIds:
                            type: array
                            items:
                              type: string
                              format: uuid
                            uniqueItems: true
                            description: >-
                              The unique identifiers of the metered resources
                              that the charge chooses as its inputs, from the
                              definition's inputResourceIds. Together with
                              chosenLicenseIds, the charge chooses exactly the
                              definition's chosenInputCount inputs. Omitting it
                              chooses no resource.
                          chosenLicenseIds:
                            type: array
                            items:
                              type: string
                              format: uuid
                            uniqueItems: true
                            description: >-
                              The unique identifiers of the licenses that the
                              charge chooses as its inputs, from the
                              definition's inputLicenseIds. Together with
                              chosenResourceIds, the charge chooses exactly the
                              definition's chosenInputCount inputs. Omitting it
                              chooses no license.
                          pricingModel:
                            type: string
                            description: >-
                              Custom charges always use custom pricing: the
                              calculator that Aira writes for you computes the
                              amount from the charge's parameter values.
                            enum:
                              - custom
                          pricing:
                            type: object
                            description: >-
                              Custom pricing: schema-defined commercial
                              parameters priced by the calculator that Aira
                              writes for you. The only pricing available for
                              custom charges.
                            properties:
                              model:
                                description: 'Discriminator: custom pricing.'
                                enum:
                                  - custom
                              parameters:
                                type: object
                                additionalProperties: true
                                description: >-
                                  The charge's commercial parameter values,
                                  keyed by the field keys of the referenced
                                  custom charge definition's parameter schema.
                                  Validated against that parameter schema when
                                  the charge is saved.
                            required:
                              - model
                              - parameters
                            additionalProperties: false
                          billingFrequency:
                            type: object
                            description: >-
                              Optional. The period this charge covers: unit
                              month or week, repeated count times. A write
                              accepts six frequencies: week x 1, week x 2, month
                              x 1 (the default), month x 3, month x 6 and month
                              x 12; any other count is rejected. Fixed and
                              minimum-commitment charges bill at their period
                              boundary; usage-based charges measure their
                              resource over the whole period and license-based
                              charges bill the last count reported before it
                              closes, both priced at the close. Custom charges
                              read their input resources and licenses the same
                              way, and their calculator prices them at the
                              close. Prorated license charges and usage charges
                              on a prorated resource accept only a count of one,
                              month x 1 or week x 1. Defaults to month x 1 when
                              omitted.
                            properties:
                              unit:
                                type: string
                                enum:
                                  - month
                                  - week
                                description: >-
                                  Grid family of the period. All charges on a
                                  plan must share one family.
                              count:
                                type: integer
                                minimum: 1
                                description: How many units the period spans.
                            required:
                              - unit
                              - count
                            additionalProperties: false
                        required:
                          - category
                          - itemId
                          - customChargeDefinitionId
                          - isCustomNameEnabled
                          - pricingModel
                          - pricing
                        additionalProperties: false
                        allOf:
                          - if:
                              properties:
                                isCustomNameEnabled:
                                  enum:
                                    - true
                            then:
                              required:
                                - name
                  description: >-
                    The plan charges of the plan, each at the position of its
                    index in the list. When they differ from those of the active
                    plan version, they become a new plan version.
              required:
                - name
                - productId
                - planCharges
              additionalProperties: false
        required: true
        description: >-
          The new name, description and product of the plan, and its plan
          charges.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the plan in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: product_not_found
          when: no product has the `productId`
        - *ref_17
        - *ref_18
        - *ref_19
        - status: 404
          code: plan_not_found
          when: no plan has the `id`
      x-required-roles: *ref_20
      responses:
        '200':
          description: >-
            A plan, a reusable set of charges of the catalog, with its product
            and its active plan version. A contract bills a plan through a plan
            instance.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the plan in our system.
                  name:
                    type: string
                    minLength: 1
                    description: The name of the plan.
                    example: Plano Essencial
                  description:
                    description: The description of the plan, or null when it has none.
                    type:
                      - 'null'
                      - string
                    example: Assinatura mensal com entrega diária de pães.
                  product:
                    type: object
                    description: The product that the plan belongs to.
                    properties:
                      id:
                        description: The unique identifier of the product in our system.
                        type: string
                        format: uuid
                      name:
                        description: The name of the product.
                        type: string
                        minLength: 1
                        example: Platform subscription
                    required:
                      - id
                      - name
                    additionalProperties: false
                  activePlanVersion:
                    type: object
                    description: >-
                      The active plan version of the plan, whose plan charges a
                      new plan instance of the plan bills.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the plan version in our
                          system.
                      versionNumber:
                        type: number
                        minimum: 1
                        description: >-
                          The number of the plan version in its plan, from 1,
                          one more for each new plan version.
                      isActive:
                        type: boolean
                        description: >-
                          Whether the plan version is the active plan version of
                          its plan, whose plan charges a new plan instance of
                          the plan bills. A plan has one active plan version.
                      planCharges:
                        type: array
                        items:
                          type: object
                          description: >-
                            Schema representing a plan charge, one priced line
                            of a plan: its item names what it bills, its
                            category says what it bills from, its pricing model
                            turns a quantity into money, and its billing
                            frequency says how often it bills. The fields of a
                            charge depend on its category. An amount is an
                            integer number of cents, and a price is a decimal
                            string with up to 6 decimal places, in BRL or in the
                            credit unit of the charge.
                          discriminator:
                            propertyName: category
                          oneOf:
                            - type: object
                              description: >-
                                A fixed charge: the same amount in every charge
                                period, billed on the invoice that its billing
                                timing names.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: fixed.'
                                  enum:
                                    - fixed
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    fixed.
                                  enum:
                                    - fixed
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a fixed charge or of a minimum
                                    commitment.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: fixed.'
                                      enum:
                                        - fixed
                                    amount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The amount that the charge bills in each
                                        charge period, in cents, or the amount
                                        of one unit when the charge has a
                                        quantity. For a minimum commitment, the
                                        least that the charges of the plan with
                                        its billing frequency bill.
                                    quantity:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units that a fixed charge
                                        bills in each charge period, when it has
                                        one, so that each charge period bills
                                        quantity times amount. A minimum
                                        commitment has none.
                                  required:
                                    - model
                                    - amount
                                  additionalProperties: false
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    When the charge bills a charge period:
                                    in_arrears bills it on the closing invoice
                                    of its last cycle, and in_advance bills it
                                    before it starts, on the activation invoice
                                    or on the closing invoice of the cycle
                                    before. The billing timing moves the
                                    invoice, never the amount.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - billingTiming
                              additionalProperties: false
                            - type: object
                              description: >-
                                A minimum commitment: the least that the plan
                                bills in a charge period. When the charges of
                                the plan with the same billing frequency total
                                less, the charge bills the difference. A plan
                                has at most one for each billing frequency.
                              properties:
                                category:
                                  type: string
                                  description: >-
                                    The category of the charge:
                                    minimum_commitment.
                                  enum:
                                    - minimum_commitment
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    fixed.
                                  enum:
                                    - fixed
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a fixed charge or of a minimum
                                    commitment.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: fixed.'
                                      enum:
                                        - fixed
                                    amount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The amount that the charge bills in each
                                        charge period, in cents, or the amount
                                        of one unit when the charge has a
                                        quantity. For a minimum commitment, the
                                        least that the charges of the plan with
                                        its billing frequency bill.
                                    quantity:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units that a fixed charge
                                        bills in each charge period, when it has
                                        one, so that each charge period bills
                                        quantity times amount. A minimum
                                        commitment has none.
                                  required:
                                    - model
                                    - amount
                                  additionalProperties: false
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                              additionalProperties: false
                            - type: object
                              description: >-
                                A usage-based charge: a charge on the usage of a
                                resource in its charge period, priced by its
                                pricing model.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: usage_based.'
                                  enum:
                                    - usage_based
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  enum:
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                  description: >-
                                    The pricing model of the charge, the same as
                                    pricing.model. per_unit, per_package and
                                    tiered_per_unit price a resource in units,
                                    percentage and tiered_percentage price a
                                    resource in money, and tiered_fixed and
                                    advanced price either.
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a usage-based or license-based
                                    charge, by pricing model. Its model is the
                                    pricingModel of the charge.
                                  discriminator:
                                    propertyName: model
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per unit: each unit of the charge period
                                        past the included quantity costs
                                        unitPrice. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_unit.
                                          enum:
                                            - per_unit
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit, as a decimal
                                            string.
                                          examples:
                                            - '0.25'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - unitPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per package: the units of the charge
                                        period past the included quantity bill
                                        packagePrice for each package of
                                        packageSize units that they start. A
                                        charge on a resource in money cannot
                                        have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_package.
                                          enum:
                                            - per_package
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: The number of units in one package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one package, as a decimal
                                            string.
                                          examples:
                                            - '50.00'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage: the charge bills a
                                        percentage of the usage of its resource
                                        in the charge period. Only a charge on a
                                        resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            percentage.
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage that the
                                            charge bills, as a decimal string from 0
                                            to 100.
                                          examples:
                                            - '2.5'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered per unit: the tiers of the charge
                                        price its units, and each tier prices
                                        them per unit. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_per_unit.
                                          enum:
                                            - tiered_per_unit
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered percentage: the tiers of the
                                        charge price its usage, and each tier
                                        bills a percentage of it. Only a charge
                                        on a resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_percentage.
                                          enum:
                                            - tiered_percentage
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered fixed: the tier that the whole
                                        quantity reaches bills its flat amount.
                                        When the last tier has an end,
                                        unitOverage or percentageOverage prices
                                        the quantity past it, and a charge never
                                        has both.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_fixed.
                                          enum:
                                            - tiered_fixed
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            Always volume, because the tier that the
                                            whole quantity reaches bills its flat
                                            amount.
                                        unitOverage:
                                          type: object
                                          description: >-
                                            The price of the units past the last
                                            tier, for a charge on a resource in
                                            units or on a license, when the charge
                                            has one.
                                          properties:
                                            excessUnitPrice:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                The price of one unit past the last
                                                tier, as a decimal string.
                                              examples:
                                                - '0.30'
                                          required:
                                            - excessUnitPrice
                                          additionalProperties: false
                                        percentageOverage:
                                          type: object
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, for a
                                            charge on a resource in money, when the
                                            charge has one.
                                          properties:
                                            excessPercentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                The percentage of the usage past the
                                                last tier that the charge bills, as a
                                                decimal string from 0 to 100.
                                              examples:
                                                - '1.5'
                                          required:
                                            - excessPercentage
                                          additionalProperties: false
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      not:
                                        required:
                                          - unitOverage
                                          - percentageOverage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Advanced: tiers of mixed types price the
                                        quantity. The tiers of a charge on a
                                        resource in units are per_unit,
                                        per_package or flat, and those of a
                                        charge on a resource in money are
                                        percentage or flat. A charge priced
                                        before the other pricing models existed
                                        has it too.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            advanced.
                                          enum:
                                            - advanced
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                resourceId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the resource whose
                                    usage the charge prices.
                                currencyUnit:
                                  type: object
                                  description: >-
                                    The currency unit that the charge is priced
                                    in, or null when the charge has none. A
                                    charge with no currency unit or in BRL, the
                                    default currency unit, bills money. A charge
                                    in any other currency unit, a credit unit,
                                    decreases the balance of a credit pool in
                                    that unit and bills no money.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the currency
                                        unit in our system.
                                    name:
                                      type: string
                                      description: The name of the currency unit.
                                      examples:
                                        - Real
                                    code:
                                      type: string
                                      description: The short code of the currency unit.
                                      examples:
                                        - BRL
                                  required:
                                    - id
                                    - name
                                    - code
                                  additionalProperties: false
                                  nullable: true
                                tiers:
                                  type: array
                                  items:
                                    type: object
                                    description: >-
                                      A price tier of the charge: a band of
                                      quantity, from one number to another, with
                                      its own price. The first tier starts at 0
                                      or 1, and each tier starts at the to of
                                      the tier before it plus 1.
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                        description: >-
                                          The unique identifier of the tier in our
                                          system.
                                      position:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The position of the tier in the charge,
                                          from 0, from the lowest band to the
                                          highest.
                                      from:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The first quantity of the band, which
                                          the band includes: a number of units of
                                          the resource or of the license, or of
                                          cents for a resource in money.
                                      to:
                                        type: integer
                                        minimum: 0
                                        nullable: true
                                        description: >-
                                          The last quantity of the band, which the
                                          band includes, in the unit of from, or
                                          null when the band has no end. The last
                                          tier has an end only on a charge with
                                          the pricing model tiered_fixed and an
                                          overage.
                                      pricing:
                                        type: object
                                        description: >-
                                          The price of the quantity that falls in
                                          the tier, by type: per_unit, percentage,
                                          per_package or flat.
                                        discriminator:
                                          propertyName: type
                                        oneOf:
                                          - type: object
                                            description: >-
                                              Per unit: each unit in the tier costs
                                              unitPrice. A charge on a resource in
                                              money cannot have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_unit.'
                                                enum:
                                                  - per_unit
                                              unitPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one unit in the tier, as a
                                                  decimal string.
                                                examples:
                                                  - '0.20'
                                              fixedPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                nullable: true
                                                description: >-
                                                  An amount that the tier bills on top of
                                                  its units when the tier applies, as a
                                                  decimal string, or null when it has
                                                  none. Only a tier of a charge with the
                                                  pricing model tiered_per_unit has an
                                                  amount other than zero.
                                                examples:
                                                  - '10.00'
                                            required:
                                              - type
                                              - unitPrice
                                              - fixedPrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Percentage: the tier bills a percentage
                                              of the usage that falls in it. Only a
                                              charge on a resource in money has it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: percentage.'
                                                enum:
                                                  - percentage
                                              percentage:
                                                type: string
                                                pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                description: >-
                                                  The percentage of the usage in the tier
                                                  that the tier bills, as a decimal string
                                                  from 0 to 100.
                                                examples:
                                                  - '1.5'
                                            required:
                                              - type
                                              - percentage
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Per package: the units in the tier bill
                                              packagePrice for each package of
                                              packageSize units that they start. A
                                              charge on a resource in money cannot
                                              have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_package.'
                                                enum:
                                                  - per_package
                                              packageSize:
                                                type: integer
                                                minimum: 1
                                                description: The number of units in one package.
                                              packagePrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one package, as a decimal
                                                  string.
                                                examples:
                                                  - '45.00'
                                            required:
                                              - type
                                              - packageSize
                                              - packagePrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Flat: the tier bills one amount,
                                              whatever the quantity that falls in it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: flat.'
                                                enum:
                                                  - flat
                                              amount:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The amount that the tier bills, as a
                                                  decimal string.
                                                examples:
                                                  - '199.90'
                                            required:
                                              - type
                                              - amount
                                            additionalProperties: false
                                    required:
                                      - id
                                      - position
                                      - from
                                      - to
                                      - pricing
                                    additionalProperties: false
                                  description: >-
                                    The price tiers of the charge, from the
                                    lowest band to the highest, for the pricing
                                    models tiered_per_unit, tiered_percentage,
                                    tiered_fixed and advanced, or an empty list
                                    for the other pricing models.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - resourceId
                                - currencyUnit
                                - tiers
                              additionalProperties: false
                            - type: object
                              description: >-
                                A license-based charge: a charge on the balance
                                of a license in its charge period, read by its
                                billing model and priced by its pricing model.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: license_based.'
                                  enum:
                                    - license_based
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  enum:
                                    - per_unit
                                    - per_package
                                    - tiered_per_unit
                                    - tiered_fixed
                                  description: >-
                                    The pricing model of the charge, the same as
                                    pricing.model: per_unit, per_package,
                                    tiered_per_unit or tiered_fixed. No
                                    percentage applies, because the balance of a
                                    license is a count, not an amount of money.
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a usage-based or license-based
                                    charge, by pricing model. Its model is the
                                    pricingModel of the charge.
                                  discriminator:
                                    propertyName: model
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per unit: each unit of the charge period
                                        past the included quantity costs
                                        unitPrice. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_unit.
                                          enum:
                                            - per_unit
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit, as a decimal
                                            string.
                                          examples:
                                            - '0.25'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - unitPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per package: the units of the charge
                                        period past the included quantity bill
                                        packagePrice for each package of
                                        packageSize units that they start. A
                                        charge on a resource in money cannot
                                        have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_package.
                                          enum:
                                            - per_package
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: The number of units in one package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one package, as a decimal
                                            string.
                                          examples:
                                            - '50.00'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage: the charge bills a
                                        percentage of the usage of its resource
                                        in the charge period. Only a charge on a
                                        resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            percentage.
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage that the
                                            charge bills, as a decimal string from 0
                                            to 100.
                                          examples:
                                            - '2.5'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered per unit: the tiers of the charge
                                        price its units, and each tier prices
                                        them per unit. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_per_unit.
                                          enum:
                                            - tiered_per_unit
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered percentage: the tiers of the
                                        charge price its usage, and each tier
                                        bills a percentage of it. Only a charge
                                        on a resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_percentage.
                                          enum:
                                            - tiered_percentage
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered fixed: the tier that the whole
                                        quantity reaches bills its flat amount.
                                        When the last tier has an end,
                                        unitOverage or percentageOverage prices
                                        the quantity past it, and a charge never
                                        has both.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_fixed.
                                          enum:
                                            - tiered_fixed
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            Always volume, because the tier that the
                                            whole quantity reaches bills its flat
                                            amount.
                                        unitOverage:
                                          type: object
                                          description: >-
                                            The price of the units past the last
                                            tier, for a charge on a resource in
                                            units or on a license, when the charge
                                            has one.
                                          properties:
                                            excessUnitPrice:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                The price of one unit past the last
                                                tier, as a decimal string.
                                              examples:
                                                - '0.30'
                                          required:
                                            - excessUnitPrice
                                          additionalProperties: false
                                        percentageOverage:
                                          type: object
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, for a
                                            charge on a resource in money, when the
                                            charge has one.
                                          properties:
                                            excessPercentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                The percentage of the usage past the
                                                last tier that the charge bills, as a
                                                decimal string from 0 to 100.
                                              examples:
                                                - '1.5'
                                          required:
                                            - excessPercentage
                                          additionalProperties: false
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      not:
                                        required:
                                          - unitOverage
                                          - percentageOverage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Advanced: tiers of mixed types price the
                                        quantity. The tiers of a charge on a
                                        resource in units are per_unit,
                                        per_package or flat, and those of a
                                        charge on a resource in money are
                                        percentage or flat. A charge priced
                                        before the other pricing models existed
                                        has it too.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            advanced.
                                          enum:
                                            - advanced
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                licenseId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the license whose
                                    balance the charge bills.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the charge reads the balance of its
                                    license in a charge period: in_full bills
                                    the last balance, and proration weighs each
                                    balance by the days that it was in effect.
                                tiers:
                                  type: array
                                  items:
                                    type: object
                                    description: >-
                                      A price tier of the charge: a band of
                                      quantity, from one number to another, with
                                      its own price. The first tier starts at 0
                                      or 1, and each tier starts at the to of
                                      the tier before it plus 1.
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                        description: >-
                                          The unique identifier of the tier in our
                                          system.
                                      position:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The position of the tier in the charge,
                                          from 0, from the lowest band to the
                                          highest.
                                      from:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The first quantity of the band, which
                                          the band includes: a number of units of
                                          the resource or of the license, or of
                                          cents for a resource in money.
                                      to:
                                        type: integer
                                        minimum: 0
                                        nullable: true
                                        description: >-
                                          The last quantity of the band, which the
                                          band includes, in the unit of from, or
                                          null when the band has no end. The last
                                          tier has an end only on a charge with
                                          the pricing model tiered_fixed and an
                                          overage.
                                      pricing:
                                        type: object
                                        description: >-
                                          The price of the quantity that falls in
                                          the tier, by type: per_unit, percentage,
                                          per_package or flat.
                                        discriminator:
                                          propertyName: type
                                        oneOf:
                                          - type: object
                                            description: >-
                                              Per unit: each unit in the tier costs
                                              unitPrice. A charge on a resource in
                                              money cannot have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_unit.'
                                                enum:
                                                  - per_unit
                                              unitPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one unit in the tier, as a
                                                  decimal string.
                                                examples:
                                                  - '0.20'
                                              fixedPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                nullable: true
                                                description: >-
                                                  An amount that the tier bills on top of
                                                  its units when the tier applies, as a
                                                  decimal string, or null when it has
                                                  none. Only a tier of a charge with the
                                                  pricing model tiered_per_unit has an
                                                  amount other than zero.
                                                examples:
                                                  - '10.00'
                                            required:
                                              - type
                                              - unitPrice
                                              - fixedPrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Percentage: the tier bills a percentage
                                              of the usage that falls in it. Only a
                                              charge on a resource in money has it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: percentage.'
                                                enum:
                                                  - percentage
                                              percentage:
                                                type: string
                                                pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                description: >-
                                                  The percentage of the usage in the tier
                                                  that the tier bills, as a decimal string
                                                  from 0 to 100.
                                                examples:
                                                  - '1.5'
                                            required:
                                              - type
                                              - percentage
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Per package: the units in the tier bill
                                              packagePrice for each package of
                                              packageSize units that they start. A
                                              charge on a resource in money cannot
                                              have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_package.'
                                                enum:
                                                  - per_package
                                              packageSize:
                                                type: integer
                                                minimum: 1
                                                description: The number of units in one package.
                                              packagePrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one package, as a decimal
                                                  string.
                                                examples:
                                                  - '45.00'
                                            required:
                                              - type
                                              - packageSize
                                              - packagePrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Flat: the tier bills one amount,
                                              whatever the quantity that falls in it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: flat.'
                                                enum:
                                                  - flat
                                              amount:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The amount that the tier bills, as a
                                                  decimal string.
                                                examples:
                                                  - '199.90'
                                            required:
                                              - type
                                              - amount
                                            additionalProperties: false
                                    required:
                                      - id
                                      - position
                                      - from
                                      - to
                                      - pricing
                                    additionalProperties: false
                                  description: >-
                                    The price tiers of the charge, from the
                                    lowest band to the highest, for the pricing
                                    models tiered_per_unit and tiered_fixed, or
                                    an empty list for the other pricing models.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - licenseId
                                - billingModel
                                - tiers
                              additionalProperties: false
                            - type: object
                              description: >-
                                A custom plan charge: a charge whose price comes
                                from code that Aira writes for you, from the
                                custom charge definition that the charge follows
                                and from the parameter values of the charge. It
                                bills in arrears, in money.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: custom.'
                                  enum:
                                    - custom
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    custom.
                                  enum:
                                    - custom
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a custom plan charge: the
                                    parameter values that the code that Aira
                                    writes for you turns into an amount.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: custom.'
                                      enum:
                                        - custom
                                    parameters:
                                      type: object
                                      additionalProperties: true
                                      description: >-
                                        The parameter values of the charge, by
                                        the keys of the parameter schema of its
                                        custom charge definition.
                                  required:
                                    - model
                                    - parameters
                                  additionalProperties: false
                                customChargeDefinitionId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the custom charge
                                    definition that the charge follows.
                                chosenResourceIds:
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                  description: >-
                                    The unique identifiers of the resources that
                                    the charge chose as its inputs, from the
                                    input resources of its custom charge
                                    definition.
                                chosenLicenseIds:
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                  description: >-
                                    The unique identifiers of the licenses that
                                    the charge chose as its inputs, from the
                                    input licenses of its custom charge
                                    definition.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - customChargeDefinitionId
                                - chosenResourceIds
                                - chosenLicenseIds
                              additionalProperties: false
                        description: The plan charges of the plan version.
                    required:
                      - id
                      - versionNumber
                      - isActive
                      - planCharges
                    additionalProperties: false
                required:
                  - id
                  - name
                  - description
                  - product
                  - activePlanVersion
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `product_not_found`: no product has the `productId`.

            - `invalid_plan_charges`: a plan charge breaks a rule of plan
            charges, such as tiers that leave a gap, an item, a resource or a
            license that does not exist, two minimum commitments with the same
            billing frequency, or billing frequencies in both months and weeks.

            - `billing_frequency_not_yet_supported`: a license-based charge with
            the billing model `proration`, or a usage-based charge on a resource
            with the billing model `proration`, has a billing frequency of more
            than one month or one week.

            - `currency_unit_not_found`: no currency unit has the
            `currencyUnitCode` of a usage-based charge.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - product_not_found
                      - invalid_plan_charges
                      - billing_frequency_not_yet_supported
                      - currency_unit_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                product_not_found:
                  value:
                    message: default product not found
                    code: product_not_found
                invalid_plan_charges:
                  value:
                    message: 'plan charge "{itemName}": {reason}'
                    code: invalid_plan_charges
                billing_frequency_not_yet_supported:
                  value:
                    message: >-
                      a license-based charge with the billing model `proration`,
                      or a usage-based charge on a resource with the billing
                      model `proration`, has a billing frequency of more than
                      one month or one week
                    code: billing_frequency_not_yet_supported
                currency_unit_not_found:
                  value:
                    message: currency unit not found
                    code: currency_unit_not_found
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plans:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `plan_not_found`: no plan has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_not_found:
                  value:
                    message: plan "{planId}" not found
                    code: plan_not_found
    delete:
      summary: Delete plan
      tags:
        - Plans
      description: >-
        Deletes a plan with its plan versions and their plan charges, so `GET
        /v1/plans` leaves it out and no new plan instance can bill it.


        Requires the role `plans:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the plan in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: plan_not_found
          when: no plan has the `id`
        - status: 409
          code: plan_being_used_by_contract
          when: a contract has an active plan instance of the plan
      x-required-roles: *ref_20
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plans:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `plan_not_found`: no plan has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_not_found:
                  value:
                    message: plan "{planId}" not found
                    code: plan_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `plan_being_used_by_contract`: a contract has an active plan
            instance of the plan.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_being_used_by_contract
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_being_used_by_contract:
                  value:
                    message: >-
                      Cannot delete plan. Contracts are associated with this
                      plan.
                    code: plan_being_used_by_contract
    get:
      summary: Fetch plan
      tags:
        - Plans
      description: >-
        Fetches a plan by id, with its product and the plan charges of its
        active plan version.


        Requires the role `plans:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the plan in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: plan_not_found
          when: no plan has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_21
      responses:
        '200':
          description: >-
            A plan, a reusable set of charges of the catalog, with its product
            and its active plan version. A contract bills a plan through a plan
            instance.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the plan in our system.
                  name:
                    type: string
                    minLength: 1
                    description: The name of the plan.
                    example: Plano Essencial
                  description:
                    description: The description of the plan, or null when it has none.
                    type:
                      - 'null'
                      - string
                    example: Assinatura mensal com entrega diária de pães.
                  product:
                    type: object
                    description: The product that the plan belongs to.
                    properties:
                      id:
                        description: The unique identifier of the product in our system.
                        type: string
                        format: uuid
                      name:
                        description: The name of the product.
                        type: string
                        minLength: 1
                        example: Platform subscription
                    required:
                      - id
                      - name
                    additionalProperties: false
                  activePlanVersion:
                    type: object
                    description: >-
                      The active plan version of the plan, whose plan charges a
                      new plan instance of the plan bills.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the plan version in our
                          system.
                      versionNumber:
                        type: number
                        minimum: 1
                        description: >-
                          The number of the plan version in its plan, from 1,
                          one more for each new plan version.
                      isActive:
                        type: boolean
                        description: >-
                          Whether the plan version is the active plan version of
                          its plan, whose plan charges a new plan instance of
                          the plan bills. A plan has one active plan version.
                      planCharges:
                        type: array
                        items:
                          type: object
                          description: >-
                            Schema representing a plan charge, one priced line
                            of a plan: its item names what it bills, its
                            category says what it bills from, its pricing model
                            turns a quantity into money, and its billing
                            frequency says how often it bills. The fields of a
                            charge depend on its category. An amount is an
                            integer number of cents, and a price is a decimal
                            string with up to 6 decimal places, in BRL or in the
                            credit unit of the charge.
                          discriminator:
                            propertyName: category
                          oneOf:
                            - type: object
                              description: >-
                                A fixed charge: the same amount in every charge
                                period, billed on the invoice that its billing
                                timing names.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: fixed.'
                                  enum:
                                    - fixed
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    fixed.
                                  enum:
                                    - fixed
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a fixed charge or of a minimum
                                    commitment.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: fixed.'
                                      enum:
                                        - fixed
                                    amount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The amount that the charge bills in each
                                        charge period, in cents, or the amount
                                        of one unit when the charge has a
                                        quantity. For a minimum commitment, the
                                        least that the charges of the plan with
                                        its billing frequency bill.
                                    quantity:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units that a fixed charge
                                        bills in each charge period, when it has
                                        one, so that each charge period bills
                                        quantity times amount. A minimum
                                        commitment has none.
                                  required:
                                    - model
                                    - amount
                                  additionalProperties: false
                                billingTiming:
                                  type: string
                                  enum:
                                    - in_advance
                                    - in_arrears
                                  description: >-
                                    When the charge bills a charge period:
                                    in_arrears bills it on the closing invoice
                                    of its last cycle, and in_advance bills it
                                    before it starts, on the activation invoice
                                    or on the closing invoice of the cycle
                                    before. The billing timing moves the
                                    invoice, never the amount.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - billingTiming
                              additionalProperties: false
                            - type: object
                              description: >-
                                A minimum commitment: the least that the plan
                                bills in a charge period. When the charges of
                                the plan with the same billing frequency total
                                less, the charge bills the difference. A plan
                                has at most one for each billing frequency.
                              properties:
                                category:
                                  type: string
                                  description: >-
                                    The category of the charge:
                                    minimum_commitment.
                                  enum:
                                    - minimum_commitment
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    fixed.
                                  enum:
                                    - fixed
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a fixed charge or of a minimum
                                    commitment.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: fixed.'
                                      enum:
                                        - fixed
                                    amount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The amount that the charge bills in each
                                        charge period, in cents, or the amount
                                        of one unit when the charge has a
                                        quantity. For a minimum commitment, the
                                        least that the charges of the plan with
                                        its billing frequency bill.
                                    quantity:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units that a fixed charge
                                        bills in each charge period, when it has
                                        one, so that each charge period bills
                                        quantity times amount. A minimum
                                        commitment has none.
                                  required:
                                    - model
                                    - amount
                                  additionalProperties: false
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                              additionalProperties: false
                            - type: object
                              description: >-
                                A usage-based charge: a charge on the usage of a
                                resource in its charge period, priced by its
                                pricing model.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: usage_based.'
                                  enum:
                                    - usage_based
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  enum:
                                    - per_unit
                                    - per_package
                                    - percentage
                                    - tiered_per_unit
                                    - tiered_percentage
                                    - tiered_fixed
                                    - advanced
                                  description: >-
                                    The pricing model of the charge, the same as
                                    pricing.model. per_unit, per_package and
                                    tiered_per_unit price a resource in units,
                                    percentage and tiered_percentage price a
                                    resource in money, and tiered_fixed and
                                    advanced price either.
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a usage-based or license-based
                                    charge, by pricing model. Its model is the
                                    pricingModel of the charge.
                                  discriminator:
                                    propertyName: model
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per unit: each unit of the charge period
                                        past the included quantity costs
                                        unitPrice. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_unit.
                                          enum:
                                            - per_unit
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit, as a decimal
                                            string.
                                          examples:
                                            - '0.25'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - unitPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per package: the units of the charge
                                        period past the included quantity bill
                                        packagePrice for each package of
                                        packageSize units that they start. A
                                        charge on a resource in money cannot
                                        have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_package.
                                          enum:
                                            - per_package
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: The number of units in one package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one package, as a decimal
                                            string.
                                          examples:
                                            - '50.00'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage: the charge bills a
                                        percentage of the usage of its resource
                                        in the charge period. Only a charge on a
                                        resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            percentage.
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage that the
                                            charge bills, as a decimal string from 0
                                            to 100.
                                          examples:
                                            - '2.5'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered per unit: the tiers of the charge
                                        price its units, and each tier prices
                                        them per unit. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_per_unit.
                                          enum:
                                            - tiered_per_unit
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered percentage: the tiers of the
                                        charge price its usage, and each tier
                                        bills a percentage of it. Only a charge
                                        on a resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_percentage.
                                          enum:
                                            - tiered_percentage
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered fixed: the tier that the whole
                                        quantity reaches bills its flat amount.
                                        When the last tier has an end,
                                        unitOverage or percentageOverage prices
                                        the quantity past it, and a charge never
                                        has both.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_fixed.
                                          enum:
                                            - tiered_fixed
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            Always volume, because the tier that the
                                            whole quantity reaches bills its flat
                                            amount.
                                        unitOverage:
                                          type: object
                                          description: >-
                                            The price of the units past the last
                                            tier, for a charge on a resource in
                                            units or on a license, when the charge
                                            has one.
                                          properties:
                                            excessUnitPrice:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                The price of one unit past the last
                                                tier, as a decimal string.
                                              examples:
                                                - '0.30'
                                          required:
                                            - excessUnitPrice
                                          additionalProperties: false
                                        percentageOverage:
                                          type: object
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, for a
                                            charge on a resource in money, when the
                                            charge has one.
                                          properties:
                                            excessPercentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                The percentage of the usage past the
                                                last tier that the charge bills, as a
                                                decimal string from 0 to 100.
                                              examples:
                                                - '1.5'
                                          required:
                                            - excessPercentage
                                          additionalProperties: false
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      not:
                                        required:
                                          - unitOverage
                                          - percentageOverage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Advanced: tiers of mixed types price the
                                        quantity. The tiers of a charge on a
                                        resource in units are per_unit,
                                        per_package or flat, and those of a
                                        charge on a resource in money are
                                        percentage or flat. A charge priced
                                        before the other pricing models existed
                                        has it too.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            advanced.
                                          enum:
                                            - advanced
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                resourceId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the resource whose
                                    usage the charge prices.
                                currencyUnit:
                                  type: object
                                  description: >-
                                    The currency unit that the charge is priced
                                    in, or null when the charge has none. A
                                    charge with no currency unit or in BRL, the
                                    default currency unit, bills money. A charge
                                    in any other currency unit, a credit unit,
                                    decreases the balance of a credit pool in
                                    that unit and bills no money.
                                  properties:
                                    id:
                                      type: string
                                      format: uuid
                                      description: >-
                                        The unique identifier of the currency
                                        unit in our system.
                                    name:
                                      type: string
                                      description: The name of the currency unit.
                                      examples:
                                        - Real
                                    code:
                                      type: string
                                      description: The short code of the currency unit.
                                      examples:
                                        - BRL
                                  required:
                                    - id
                                    - name
                                    - code
                                  additionalProperties: false
                                  nullable: true
                                tiers:
                                  type: array
                                  items:
                                    type: object
                                    description: >-
                                      A price tier of the charge: a band of
                                      quantity, from one number to another, with
                                      its own price. The first tier starts at 0
                                      or 1, and each tier starts at the to of
                                      the tier before it plus 1.
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                        description: >-
                                          The unique identifier of the tier in our
                                          system.
                                      position:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The position of the tier in the charge,
                                          from 0, from the lowest band to the
                                          highest.
                                      from:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The first quantity of the band, which
                                          the band includes: a number of units of
                                          the resource or of the license, or of
                                          cents for a resource in money.
                                      to:
                                        type: integer
                                        minimum: 0
                                        nullable: true
                                        description: >-
                                          The last quantity of the band, which the
                                          band includes, in the unit of from, or
                                          null when the band has no end. The last
                                          tier has an end only on a charge with
                                          the pricing model tiered_fixed and an
                                          overage.
                                      pricing:
                                        type: object
                                        description: >-
                                          The price of the quantity that falls in
                                          the tier, by type: per_unit, percentage,
                                          per_package or flat.
                                        discriminator:
                                          propertyName: type
                                        oneOf:
                                          - type: object
                                            description: >-
                                              Per unit: each unit in the tier costs
                                              unitPrice. A charge on a resource in
                                              money cannot have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_unit.'
                                                enum:
                                                  - per_unit
                                              unitPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one unit in the tier, as a
                                                  decimal string.
                                                examples:
                                                  - '0.20'
                                              fixedPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                nullable: true
                                                description: >-
                                                  An amount that the tier bills on top of
                                                  its units when the tier applies, as a
                                                  decimal string, or null when it has
                                                  none. Only a tier of a charge with the
                                                  pricing model tiered_per_unit has an
                                                  amount other than zero.
                                                examples:
                                                  - '10.00'
                                            required:
                                              - type
                                              - unitPrice
                                              - fixedPrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Percentage: the tier bills a percentage
                                              of the usage that falls in it. Only a
                                              charge on a resource in money has it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: percentage.'
                                                enum:
                                                  - percentage
                                              percentage:
                                                type: string
                                                pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                description: >-
                                                  The percentage of the usage in the tier
                                                  that the tier bills, as a decimal string
                                                  from 0 to 100.
                                                examples:
                                                  - '1.5'
                                            required:
                                              - type
                                              - percentage
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Per package: the units in the tier bill
                                              packagePrice for each package of
                                              packageSize units that they start. A
                                              charge on a resource in money cannot
                                              have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_package.'
                                                enum:
                                                  - per_package
                                              packageSize:
                                                type: integer
                                                minimum: 1
                                                description: The number of units in one package.
                                              packagePrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one package, as a decimal
                                                  string.
                                                examples:
                                                  - '45.00'
                                            required:
                                              - type
                                              - packageSize
                                              - packagePrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Flat: the tier bills one amount,
                                              whatever the quantity that falls in it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: flat.'
                                                enum:
                                                  - flat
                                              amount:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The amount that the tier bills, as a
                                                  decimal string.
                                                examples:
                                                  - '199.90'
                                            required:
                                              - type
                                              - amount
                                            additionalProperties: false
                                    required:
                                      - id
                                      - position
                                      - from
                                      - to
                                      - pricing
                                    additionalProperties: false
                                  description: >-
                                    The price tiers of the charge, from the
                                    lowest band to the highest, for the pricing
                                    models tiered_per_unit, tiered_percentage,
                                    tiered_fixed and advanced, or an empty list
                                    for the other pricing models.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - resourceId
                                - currencyUnit
                                - tiers
                              additionalProperties: false
                            - type: object
                              description: >-
                                A license-based charge: a charge on the balance
                                of a license in its charge period, read by its
                                billing model and priced by its pricing model.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: license_based.'
                                  enum:
                                    - license_based
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  enum:
                                    - per_unit
                                    - per_package
                                    - tiered_per_unit
                                    - tiered_fixed
                                  description: >-
                                    The pricing model of the charge, the same as
                                    pricing.model: per_unit, per_package,
                                    tiered_per_unit or tiered_fixed. No
                                    percentage applies, because the balance of a
                                    license is a count, not an amount of money.
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a usage-based or license-based
                                    charge, by pricing model. Its model is the
                                    pricingModel of the charge.
                                  discriminator:
                                    propertyName: model
                                  oneOf:
                                    - type: object
                                      description: >-
                                        Per unit: each unit of the charge period
                                        past the included quantity costs
                                        unitPrice. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_unit.
                                          enum:
                                            - per_unit
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        unitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit, as a decimal
                                            string.
                                          examples:
                                            - '0.25'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - unitPrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Per package: the units of the charge
                                        period past the included quantity bill
                                        packagePrice for each package of
                                        packageSize units that they start. A
                                        charge on a resource in money cannot
                                        have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            per_package.
                                          enum:
                                            - per_package
                                        includedQuantity:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The number of units of each charge
                                            period that the charge does not bill,
                                            when it has one.
                                        packageSize:
                                          type: integer
                                          minimum: 1
                                          description: The number of units in one package.
                                        packagePrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one package, as a decimal
                                            string.
                                          examples:
                                            - '50.00'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - packageSize
                                        - packagePrice
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Percentage: the charge bills a
                                        percentage of the usage of its resource
                                        in the charge period. Only a charge on a
                                        resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            percentage.
                                          enum:
                                            - percentage
                                        percentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage that the
                                            charge bills, as a decimal string from 0
                                            to 100.
                                          examples:
                                            - '2.5'
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - percentage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered per unit: the tiers of the charge
                                        price its units, and each tier prices
                                        them per unit. A charge on a resource in
                                        money cannot have it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_per_unit.
                                          enum:
                                            - tiered_per_unit
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered percentage: the tiers of the
                                        charge price its usage, and each tier
                                        bills a percentage of it. Only a charge
                                        on a resource in money has it.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_percentage.
                                          enum:
                                            - tiered_percentage
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Tiered fixed: the tier that the whole
                                        quantity reaches bills its flat amount.
                                        When the last tier has an end,
                                        unitOverage or percentageOverage prices
                                        the quantity past it, and a charge never
                                        has both.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            tiered_fixed.
                                          enum:
                                            - tiered_fixed
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            Always volume, because the tier that the
                                            whole quantity reaches bills its flat
                                            amount.
                                        unitOverage:
                                          type: object
                                          description: >-
                                            The price of the units past the last
                                            tier, for a charge on a resource in
                                            units or on a license, when the charge
                                            has one.
                                          properties:
                                            excessUnitPrice:
                                              type: string
                                              pattern: ^\d+(\.\d{1,6})?$
                                              description: >-
                                                The price of one unit past the last
                                                tier, as a decimal string.
                                              examples:
                                                - '0.30'
                                          required:
                                            - excessUnitPrice
                                          additionalProperties: false
                                        percentageOverage:
                                          type: object
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, for a
                                            charge on a resource in money, when the
                                            charge has one.
                                          properties:
                                            excessPercentage:
                                              type: string
                                              pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                              description: >-
                                                The percentage of the usage past the
                                                last tier that the charge bills, as a
                                                decimal string from 0 to 100.
                                              examples:
                                                - '1.5'
                                          required:
                                            - excessPercentage
                                          additionalProperties: false
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      not:
                                        required:
                                          - unitOverage
                                          - percentageOverage
                                      additionalProperties: false
                                    - type: object
                                      description: >-
                                        Advanced: tiers of mixed types price the
                                        quantity. The tiers of a charge on a
                                        resource in units are per_unit,
                                        per_package or flat, and those of a
                                        charge on a resource in money are
                                        percentage or flat. A charge priced
                                        before the other pricing models existed
                                        has it too.
                                      properties:
                                        model:
                                          description: >-
                                            The pricing model of the price:
                                            advanced.
                                          enum:
                                            - advanced
                                        tierMode:
                                          enum:
                                            - progressive
                                            - volume
                                          description: >-
                                            How the tiers price the quantity:
                                            progressive splits it across the tiers,
                                            and volume prices all of it at the tier
                                            that it reaches.
                                        fixedAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            An amount that the charge adds in each
                                            charge period on top of its priced
                                            quantity, in cents, when it has one.
                                        minimumAmount:
                                          type: integer
                                          minimum: 0
                                          description: >-
                                            The least that the charge bills in a
                                            charge period, in cents, when it has
                                            one: when the priced quantity plus
                                            fixedAmount comes to less, the charge
                                            bills this amount.
                                      required:
                                        - model
                                        - tierMode
                                      additionalProperties: false
                                licenseId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the license whose
                                    balance the charge bills.
                                billingModel:
                                  type: string
                                  enum:
                                    - in_full
                                    - proration
                                  description: >-
                                    How the charge reads the balance of its
                                    license in a charge period: in_full bills
                                    the last balance, and proration weighs each
                                    balance by the days that it was in effect.
                                tiers:
                                  type: array
                                  items:
                                    type: object
                                    description: >-
                                      A price tier of the charge: a band of
                                      quantity, from one number to another, with
                                      its own price. The first tier starts at 0
                                      or 1, and each tier starts at the to of
                                      the tier before it plus 1.
                                    properties:
                                      id:
                                        type: string
                                        format: uuid
                                        description: >-
                                          The unique identifier of the tier in our
                                          system.
                                      position:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The position of the tier in the charge,
                                          from 0, from the lowest band to the
                                          highest.
                                      from:
                                        type: integer
                                        minimum: 0
                                        description: >-
                                          The first quantity of the band, which
                                          the band includes: a number of units of
                                          the resource or of the license, or of
                                          cents for a resource in money.
                                      to:
                                        type: integer
                                        minimum: 0
                                        nullable: true
                                        description: >-
                                          The last quantity of the band, which the
                                          band includes, in the unit of from, or
                                          null when the band has no end. The last
                                          tier has an end only on a charge with
                                          the pricing model tiered_fixed and an
                                          overage.
                                      pricing:
                                        type: object
                                        description: >-
                                          The price of the quantity that falls in
                                          the tier, by type: per_unit, percentage,
                                          per_package or flat.
                                        discriminator:
                                          propertyName: type
                                        oneOf:
                                          - type: object
                                            description: >-
                                              Per unit: each unit in the tier costs
                                              unitPrice. A charge on a resource in
                                              money cannot have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_unit.'
                                                enum:
                                                  - per_unit
                                              unitPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one unit in the tier, as a
                                                  decimal string.
                                                examples:
                                                  - '0.20'
                                              fixedPrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                nullable: true
                                                description: >-
                                                  An amount that the tier bills on top of
                                                  its units when the tier applies, as a
                                                  decimal string, or null when it has
                                                  none. Only a tier of a charge with the
                                                  pricing model tiered_per_unit has an
                                                  amount other than zero.
                                                examples:
                                                  - '10.00'
                                            required:
                                              - type
                                              - unitPrice
                                              - fixedPrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Percentage: the tier bills a percentage
                                              of the usage that falls in it. Only a
                                              charge on a resource in money has it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: percentage.'
                                                enum:
                                                  - percentage
                                              percentage:
                                                type: string
                                                pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                                description: >-
                                                  The percentage of the usage in the tier
                                                  that the tier bills, as a decimal string
                                                  from 0 to 100.
                                                examples:
                                                  - '1.5'
                                            required:
                                              - type
                                              - percentage
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Per package: the units in the tier bill
                                              packagePrice for each package of
                                              packageSize units that they start. A
                                              charge on a resource in money cannot
                                              have it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: per_package.'
                                                enum:
                                                  - per_package
                                              packageSize:
                                                type: integer
                                                minimum: 1
                                                description: The number of units in one package.
                                              packagePrice:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The price of one package, as a decimal
                                                  string.
                                                examples:
                                                  - '45.00'
                                            required:
                                              - type
                                              - packageSize
                                              - packagePrice
                                            additionalProperties: false
                                          - type: object
                                            description: >-
                                              Flat: the tier bills one amount,
                                              whatever the quantity that falls in it.
                                            properties:
                                              type:
                                                description: 'The type of the tier price: flat.'
                                                enum:
                                                  - flat
                                              amount:
                                                type: string
                                                pattern: ^\d+(\.\d{1,6})?$
                                                description: >-
                                                  The amount that the tier bills, as a
                                                  decimal string.
                                                examples:
                                                  - '199.90'
                                            required:
                                              - type
                                              - amount
                                            additionalProperties: false
                                    required:
                                      - id
                                      - position
                                      - from
                                      - to
                                      - pricing
                                    additionalProperties: false
                                  description: >-
                                    The price tiers of the charge, from the
                                    lowest band to the highest, for the pricing
                                    models tiered_per_unit and tiered_fixed, or
                                    an empty list for the other pricing models.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - licenseId
                                - billingModel
                                - tiers
                              additionalProperties: false
                            - type: object
                              description: >-
                                A custom plan charge: a charge whose price comes
                                from code that Aira writes for you, from the
                                custom charge definition that the charge follows
                                and from the parameter values of the charge. It
                                bills in arrears, in money.
                              properties:
                                category:
                                  type: string
                                  description: 'The category of the charge: custom.'
                                  enum:
                                    - custom
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the plan charge in
                                    our system.
                                position:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The position of the charge in the plan, from
                                    0, in the order that the billing app shows.
                                itemId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the item that the
                                    charge bills. The line items of the charge
                                    name the same item.
                                productId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the product that
                                    the charge belongs to.
                                name:
                                  type: string
                                  minLength: 1
                                  description: >-
                                    The name of the charge, as the invoices show
                                    it.
                                  examples:
                                    - Mensalidade
                                isCustomNameEnabled:
                                  type: boolean
                                  description: >-
                                    Whether the charge has a name of its own.
                                    When false, the name of the charge is the
                                    name of its resource, of its license or of
                                    its item.
                                billingFrequency:
                                  type: object
                                  description: >-
                                    How often the charge bills: each charge
                                    period of the charge lasts count units, the
                                    charge counts its charge periods from the
                                    contract start, and it bills each charge
                                    period once. Aira accepts 1 or 2 weeks and
                                    1, 3, 6 or 12 months, and a prorated charge
                                    bills every week or every month.
                                  properties:
                                    unit:
                                      type: string
                                      enum:
                                        - month
                                        - week
                                      description: >-
                                        The unit of the billing frequency: month
                                        or week. Every charge of a plan has the
                                        same unit.
                                    count:
                                      type: integer
                                      minimum: 1
                                      description: >-
                                        The number of units in each charge
                                        period of the charge.
                                  required:
                                    - unit
                                    - count
                                  additionalProperties: false
                                pricingModel:
                                  type: string
                                  description: >-
                                    The pricing model of the charge, always
                                    custom.
                                  enum:
                                    - custom
                                pricing:
                                  type: object
                                  description: >-
                                    The price of a custom plan charge: the
                                    parameter values that the code that Aira
                                    writes for you turns into an amount.
                                  properties:
                                    model:
                                      description: 'The pricing model of the price: custom.'
                                      enum:
                                        - custom
                                    parameters:
                                      type: object
                                      additionalProperties: true
                                      description: >-
                                        The parameter values of the charge, by
                                        the keys of the parameter schema of its
                                        custom charge definition.
                                  required:
                                    - model
                                    - parameters
                                  additionalProperties: false
                                customChargeDefinitionId:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the custom charge
                                    definition that the charge follows.
                                chosenResourceIds:
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                  description: >-
                                    The unique identifiers of the resources that
                                    the charge chose as its inputs, from the
                                    input resources of its custom charge
                                    definition.
                                chosenLicenseIds:
                                  type: array
                                  items:
                                    type: string
                                    format: uuid
                                  description: >-
                                    The unique identifiers of the licenses that
                                    the charge chose as its inputs, from the
                                    input licenses of its custom charge
                                    definition.
                              required:
                                - id
                                - position
                                - itemId
                                - productId
                                - name
                                - isCustomNameEnabled
                                - category
                                - pricingModel
                                - pricing
                                - billingFrequency
                                - customChargeDefinitionId
                                - chosenResourceIds
                                - chosenLicenseIds
                              additionalProperties: false
                        description: The plan charges of the plan version.
                    required:
                      - id
                      - versionNumber
                      - isActive
                      - planCharges
                    additionalProperties: false
                required:
                  - id
                  - name
                  - description
                  - product
                  - activePlanVersion
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plans:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `plan_not_found`: no plan has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_not_found:
                  value:
                    message: plan "{planId}" not found
                    code: plan_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/plans/version/{id}/rollback:
    post:
      summary: Restore plan version
      tags:
        - Plans
      description: >-
        Restores a plan version: a new plan version of its plan, with the plan
        charges of the restored plan version and the reason rollback, becomes
        the active plan version of the plan. The request answers the new plan
        version.


        Requires the role `plans:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the plan version.
      x-public-api: true
      x-errors:
        - status: 400
          code: plan_version_already_active
          when: the plan version is already the active plan version of its plan
        - status: 404
          code: plan_version_not_found
          when: no plan version has the `id`
      x-required-roles: *ref_20
      responses:
        '200':
          description: 'A plan version: one saved state of the plan charges of a plan.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the plan version in our system.
                  versionNumber:
                    type: number
                    minimum: 1
                    description: >-
                      The number of the plan version in its plan, from 1, one
                      more for each new plan version.
                  isActive:
                    type: boolean
                    description: >-
                      Whether the plan version is the active plan version of its
                      plan, whose plan charges a new plan instance of the plan
                      bills. A plan has one active plan version.
                  planCharges:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a plan charge, one priced line of a
                        plan: its item names what it bills, its category says
                        what it bills from, its pricing model turns a quantity
                        into money, and its billing frequency says how often it
                        bills. The fields of a charge depend on its category. An
                        amount is an integer number of cents, and a price is a
                        decimal string with up to 6 decimal places, in BRL or in
                        the credit unit of the charge.
                      discriminator:
                        propertyName: category
                      oneOf:
                        - type: object
                          description: >-
                            A fixed charge: the same amount in every charge
                            period, billed on the invoice that its billing
                            timing names.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: fixed.'
                              enum:
                                - fixed
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              description: The pricing model of the charge, always fixed.
                              enum:
                                - fixed
                            pricing:
                              type: object
                              description: >-
                                The price of a fixed charge or of a minimum
                                commitment.
                              properties:
                                model:
                                  description: 'The pricing model of the price: fixed.'
                                  enum:
                                    - fixed
                                amount:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The amount that the charge bills in each
                                    charge period, in cents, or the amount of
                                    one unit when the charge has a quantity. For
                                    a minimum commitment, the least that the
                                    charges of the plan with its billing
                                    frequency bill.
                                quantity:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units that a fixed charge
                                    bills in each charge period, when it has
                                    one, so that each charge period bills
                                    quantity times amount. A minimum commitment
                                    has none.
                              required:
                                - model
                                - amount
                              additionalProperties: false
                            billingTiming:
                              type: string
                              enum:
                                - in_advance
                                - in_arrears
                              description: >-
                                When the charge bills a charge period:
                                in_arrears bills it on the closing invoice of
                                its last cycle, and in_advance bills it before
                                it starts, on the activation invoice or on the
                                closing invoice of the cycle before. The billing
                                timing moves the invoice, never the amount.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - billingTiming
                          additionalProperties: false
                        - type: object
                          description: >-
                            A minimum commitment: the least that the plan bills
                            in a charge period. When the charges of the plan
                            with the same billing frequency total less, the
                            charge bills the difference. A plan has at most one
                            for each billing frequency.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: minimum_commitment.'
                              enum:
                                - minimum_commitment
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              description: The pricing model of the charge, always fixed.
                              enum:
                                - fixed
                            pricing:
                              type: object
                              description: >-
                                The price of a fixed charge or of a minimum
                                commitment.
                              properties:
                                model:
                                  description: 'The pricing model of the price: fixed.'
                                  enum:
                                    - fixed
                                amount:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The amount that the charge bills in each
                                    charge period, in cents, or the amount of
                                    one unit when the charge has a quantity. For
                                    a minimum commitment, the least that the
                                    charges of the plan with its billing
                                    frequency bill.
                                quantity:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units that a fixed charge
                                    bills in each charge period, when it has
                                    one, so that each charge period bills
                                    quantity times amount. A minimum commitment
                                    has none.
                              required:
                                - model
                                - amount
                              additionalProperties: false
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                          additionalProperties: false
                        - type: object
                          description: >-
                            A usage-based charge: a charge on the usage of a
                            resource in its charge period, priced by its pricing
                            model.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: usage_based.'
                              enum:
                                - usage_based
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              enum:
                                - per_unit
                                - per_package
                                - percentage
                                - tiered_per_unit
                                - tiered_percentage
                                - tiered_fixed
                                - advanced
                              description: >-
                                The pricing model of the charge, the same as
                                pricing.model. per_unit, per_package and
                                tiered_per_unit price a resource in units,
                                percentage and tiered_percentage price a
                                resource in money, and tiered_fixed and advanced
                                price either.
                            pricing:
                              type: object
                              description: >-
                                The price of a usage-based or license-based
                                charge, by pricing model. Its model is the
                                pricingModel of the charge.
                              discriminator:
                                propertyName: model
                              oneOf:
                                - type: object
                                  description: >-
                                    Per unit: each unit of the charge period
                                    past the included quantity costs unitPrice.
                                    A charge on a resource in money cannot have
                                    it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_unit.
                                      enum:
                                        - per_unit
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    unitPrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one unit, as a decimal
                                        string.
                                      examples:
                                        - '0.25'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - unitPrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Per package: the units of the charge period
                                    past the included quantity bill packagePrice
                                    for each package of packageSize units that
                                    they start. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_package.
                                      enum:
                                        - per_package
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    packageSize:
                                      type: integer
                                      minimum: 1
                                      description: The number of units in one package.
                                    packagePrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one package, as a decimal
                                        string.
                                      examples:
                                        - '50.00'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - packageSize
                                    - packagePrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Percentage: the charge bills a percentage of
                                    the usage of its resource in the charge
                                    period. Only a charge on a resource in money
                                    has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        percentage.
                                      enum:
                                        - percentage
                                    percentage:
                                      type: string
                                      pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                      description: >-
                                        The percentage of the usage that the
                                        charge bills, as a decimal string from 0
                                        to 100.
                                      examples:
                                        - '2.5'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - percentage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered per unit: the tiers of the charge
                                    price its units, and each tier prices them
                                    per unit. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_per_unit.
                                      enum:
                                        - tiered_per_unit
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered percentage: the tiers of the charge
                                    price its usage, and each tier bills a
                                    percentage of it. Only a charge on a
                                    resource in money has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_percentage.
                                      enum:
                                        - tiered_percentage
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered fixed: the tier that the whole
                                    quantity reaches bills its flat amount. When
                                    the last tier has an end, unitOverage or
                                    percentageOverage prices the quantity past
                                    it, and a charge never has both.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_fixed.
                                      enum:
                                        - tiered_fixed
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        Always volume, because the tier that the
                                        whole quantity reaches bills its flat
                                        amount.
                                    unitOverage:
                                      type: object
                                      description: >-
                                        The price of the units past the last
                                        tier, for a charge on a resource in
                                        units or on a license, when the charge
                                        has one.
                                      properties:
                                        excessUnitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit past the last
                                            tier, as a decimal string.
                                          examples:
                                            - '0.30'
                                      required:
                                        - excessUnitPrice
                                      additionalProperties: false
                                    percentageOverage:
                                      type: object
                                      description: >-
                                        The percentage of the usage past the
                                        last tier that the charge bills, for a
                                        charge on a resource in money, when the
                                        charge has one.
                                      properties:
                                        excessPercentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, as a
                                            decimal string from 0 to 100.
                                          examples:
                                            - '1.5'
                                      required:
                                        - excessPercentage
                                      additionalProperties: false
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  not:
                                    required:
                                      - unitOverage
                                      - percentageOverage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Advanced: tiers of mixed types price the
                                    quantity. The tiers of a charge on a
                                    resource in units are per_unit, per_package
                                    or flat, and those of a charge on a resource
                                    in money are percentage or flat. A charge
                                    priced before the other pricing models
                                    existed has it too.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        advanced.
                                      enum:
                                        - advanced
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                            resourceId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the resource whose
                                usage the charge prices.
                            currencyUnit:
                              type: object
                              description: >-
                                The currency unit that the charge is priced in,
                                or null when the charge has none. A charge with
                                no currency unit or in BRL, the default currency
                                unit, bills money. A charge in any other
                                currency unit, a credit unit, decreases the
                                balance of a credit pool in that unit and bills
                                no money.
                              properties:
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the currency unit
                                    in our system.
                                name:
                                  type: string
                                  description: The name of the currency unit.
                                  examples:
                                    - Real
                                code:
                                  type: string
                                  description: The short code of the currency unit.
                                  examples:
                                    - BRL
                              required:
                                - id
                                - name
                                - code
                              additionalProperties: false
                              nullable: true
                            tiers:
                              type: array
                              items:
                                type: object
                                description: >-
                                  A price tier of the charge: a band of
                                  quantity, from one number to another, with its
                                  own price. The first tier starts at 0 or 1,
                                  and each tier starts at the to of the tier
                                  before it plus 1.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the tier in our
                                      system.
                                  position:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The position of the tier in the charge,
                                      from 0, from the lowest band to the
                                      highest.
                                  from:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The first quantity of the band, which the
                                      band includes: a number of units of the
                                      resource or of the license, or of cents
                                      for a resource in money.
                                  to:
                                    type: integer
                                    minimum: 0
                                    nullable: true
                                    description: >-
                                      The last quantity of the band, which the
                                      band includes, in the unit of from, or
                                      null when the band has no end. The last
                                      tier has an end only on a charge with the
                                      pricing model tiered_fixed and an overage.
                                  pricing:
                                    type: object
                                    description: >-
                                      The price of the quantity that falls in
                                      the tier, by type: per_unit, percentage,
                                      per_package or flat.
                                    discriminator:
                                      propertyName: type
                                    oneOf:
                                      - type: object
                                        description: >-
                                          Per unit: each unit in the tier costs
                                          unitPrice. A charge on a resource in
                                          money cannot have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_unit.'
                                            enum:
                                              - per_unit
                                          unitPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one unit in the tier, as a
                                              decimal string.
                                            examples:
                                              - '0.20'
                                          fixedPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            nullable: true
                                            description: >-
                                              An amount that the tier bills on top of
                                              its units when the tier applies, as a
                                              decimal string, or null when it has
                                              none. Only a tier of a charge with the
                                              pricing model tiered_per_unit has an
                                              amount other than zero.
                                            examples:
                                              - '10.00'
                                        required:
                                          - type
                                          - unitPrice
                                          - fixedPrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Percentage: the tier bills a percentage
                                          of the usage that falls in it. Only a
                                          charge on a resource in money has it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: percentage.'
                                            enum:
                                              - percentage
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              The percentage of the usage in the tier
                                              that the tier bills, as a decimal string
                                              from 0 to 100.
                                            examples:
                                              - '1.5'
                                        required:
                                          - type
                                          - percentage
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Per package: the units in the tier bill
                                          packagePrice for each package of
                                          packageSize units that they start. A
                                          charge on a resource in money cannot
                                          have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_package.'
                                            enum:
                                              - per_package
                                          packageSize:
                                            type: integer
                                            minimum: 1
                                            description: The number of units in one package.
                                          packagePrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one package, as a decimal
                                              string.
                                            examples:
                                              - '45.00'
                                        required:
                                          - type
                                          - packageSize
                                          - packagePrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Flat: the tier bills one amount,
                                          whatever the quantity that falls in it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: flat.'
                                            enum:
                                              - flat
                                          amount:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The amount that the tier bills, as a
                                              decimal string.
                                            examples:
                                              - '199.90'
                                        required:
                                          - type
                                          - amount
                                        additionalProperties: false
                                required:
                                  - id
                                  - position
                                  - from
                                  - to
                                  - pricing
                                additionalProperties: false
                              description: >-
                                The price tiers of the charge, from the lowest
                                band to the highest, for the pricing models
                                tiered_per_unit, tiered_percentage, tiered_fixed
                                and advanced, or an empty list for the other
                                pricing models.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - resourceId
                            - currencyUnit
                            - tiers
                          additionalProperties: false
                        - type: object
                          description: >-
                            A license-based charge: a charge on the balance of a
                            license in its charge period, read by its billing
                            model and priced by its pricing model.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: license_based.'
                              enum:
                                - license_based
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              enum:
                                - per_unit
                                - per_package
                                - tiered_per_unit
                                - tiered_fixed
                              description: >-
                                The pricing model of the charge, the same as
                                pricing.model: per_unit, per_package,
                                tiered_per_unit or tiered_fixed. No percentage
                                applies, because the balance of a license is a
                                count, not an amount of money.
                            pricing:
                              type: object
                              description: >-
                                The price of a usage-based or license-based
                                charge, by pricing model. Its model is the
                                pricingModel of the charge.
                              discriminator:
                                propertyName: model
                              oneOf:
                                - type: object
                                  description: >-
                                    Per unit: each unit of the charge period
                                    past the included quantity costs unitPrice.
                                    A charge on a resource in money cannot have
                                    it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_unit.
                                      enum:
                                        - per_unit
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    unitPrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one unit, as a decimal
                                        string.
                                      examples:
                                        - '0.25'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - unitPrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Per package: the units of the charge period
                                    past the included quantity bill packagePrice
                                    for each package of packageSize units that
                                    they start. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_package.
                                      enum:
                                        - per_package
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    packageSize:
                                      type: integer
                                      minimum: 1
                                      description: The number of units in one package.
                                    packagePrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one package, as a decimal
                                        string.
                                      examples:
                                        - '50.00'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - packageSize
                                    - packagePrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Percentage: the charge bills a percentage of
                                    the usage of its resource in the charge
                                    period. Only a charge on a resource in money
                                    has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        percentage.
                                      enum:
                                        - percentage
                                    percentage:
                                      type: string
                                      pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                      description: >-
                                        The percentage of the usage that the
                                        charge bills, as a decimal string from 0
                                        to 100.
                                      examples:
                                        - '2.5'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - percentage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered per unit: the tiers of the charge
                                    price its units, and each tier prices them
                                    per unit. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_per_unit.
                                      enum:
                                        - tiered_per_unit
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered percentage: the tiers of the charge
                                    price its usage, and each tier bills a
                                    percentage of it. Only a charge on a
                                    resource in money has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_percentage.
                                      enum:
                                        - tiered_percentage
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered fixed: the tier that the whole
                                    quantity reaches bills its flat amount. When
                                    the last tier has an end, unitOverage or
                                    percentageOverage prices the quantity past
                                    it, and a charge never has both.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_fixed.
                                      enum:
                                        - tiered_fixed
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        Always volume, because the tier that the
                                        whole quantity reaches bills its flat
                                        amount.
                                    unitOverage:
                                      type: object
                                      description: >-
                                        The price of the units past the last
                                        tier, for a charge on a resource in
                                        units or on a license, when the charge
                                        has one.
                                      properties:
                                        excessUnitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit past the last
                                            tier, as a decimal string.
                                          examples:
                                            - '0.30'
                                      required:
                                        - excessUnitPrice
                                      additionalProperties: false
                                    percentageOverage:
                                      type: object
                                      description: >-
                                        The percentage of the usage past the
                                        last tier that the charge bills, for a
                                        charge on a resource in money, when the
                                        charge has one.
                                      properties:
                                        excessPercentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, as a
                                            decimal string from 0 to 100.
                                          examples:
                                            - '1.5'
                                      required:
                                        - excessPercentage
                                      additionalProperties: false
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  not:
                                    required:
                                      - unitOverage
                                      - percentageOverage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Advanced: tiers of mixed types price the
                                    quantity. The tiers of a charge on a
                                    resource in units are per_unit, per_package
                                    or flat, and those of a charge on a resource
                                    in money are percentage or flat. A charge
                                    priced before the other pricing models
                                    existed has it too.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        advanced.
                                      enum:
                                        - advanced
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                            licenseId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the license whose
                                balance the charge bills.
                            billingModel:
                              type: string
                              enum:
                                - in_full
                                - proration
                              description: >-
                                How the charge reads the balance of its license
                                in a charge period: in_full bills the last
                                balance, and proration weighs each balance by
                                the days that it was in effect.
                            tiers:
                              type: array
                              items:
                                type: object
                                description: >-
                                  A price tier of the charge: a band of
                                  quantity, from one number to another, with its
                                  own price. The first tier starts at 0 or 1,
                                  and each tier starts at the to of the tier
                                  before it plus 1.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the tier in our
                                      system.
                                  position:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The position of the tier in the charge,
                                      from 0, from the lowest band to the
                                      highest.
                                  from:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The first quantity of the band, which the
                                      band includes: a number of units of the
                                      resource or of the license, or of cents
                                      for a resource in money.
                                  to:
                                    type: integer
                                    minimum: 0
                                    nullable: true
                                    description: >-
                                      The last quantity of the band, which the
                                      band includes, in the unit of from, or
                                      null when the band has no end. The last
                                      tier has an end only on a charge with the
                                      pricing model tiered_fixed and an overage.
                                  pricing:
                                    type: object
                                    description: >-
                                      The price of the quantity that falls in
                                      the tier, by type: per_unit, percentage,
                                      per_package or flat.
                                    discriminator:
                                      propertyName: type
                                    oneOf:
                                      - type: object
                                        description: >-
                                          Per unit: each unit in the tier costs
                                          unitPrice. A charge on a resource in
                                          money cannot have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_unit.'
                                            enum:
                                              - per_unit
                                          unitPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one unit in the tier, as a
                                              decimal string.
                                            examples:
                                              - '0.20'
                                          fixedPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            nullable: true
                                            description: >-
                                              An amount that the tier bills on top of
                                              its units when the tier applies, as a
                                              decimal string, or null when it has
                                              none. Only a tier of a charge with the
                                              pricing model tiered_per_unit has an
                                              amount other than zero.
                                            examples:
                                              - '10.00'
                                        required:
                                          - type
                                          - unitPrice
                                          - fixedPrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Percentage: the tier bills a percentage
                                          of the usage that falls in it. Only a
                                          charge on a resource in money has it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: percentage.'
                                            enum:
                                              - percentage
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              The percentage of the usage in the tier
                                              that the tier bills, as a decimal string
                                              from 0 to 100.
                                            examples:
                                              - '1.5'
                                        required:
                                          - type
                                          - percentage
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Per package: the units in the tier bill
                                          packagePrice for each package of
                                          packageSize units that they start. A
                                          charge on a resource in money cannot
                                          have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_package.'
                                            enum:
                                              - per_package
                                          packageSize:
                                            type: integer
                                            minimum: 1
                                            description: The number of units in one package.
                                          packagePrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one package, as a decimal
                                              string.
                                            examples:
                                              - '45.00'
                                        required:
                                          - type
                                          - packageSize
                                          - packagePrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Flat: the tier bills one amount,
                                          whatever the quantity that falls in it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: flat.'
                                            enum:
                                              - flat
                                          amount:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The amount that the tier bills, as a
                                              decimal string.
                                            examples:
                                              - '199.90'
                                        required:
                                          - type
                                          - amount
                                        additionalProperties: false
                                required:
                                  - id
                                  - position
                                  - from
                                  - to
                                  - pricing
                                additionalProperties: false
                              description: >-
                                The price tiers of the charge, from the lowest
                                band to the highest, for the pricing models
                                tiered_per_unit and tiered_fixed, or an empty
                                list for the other pricing models.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - licenseId
                            - billingModel
                            - tiers
                          additionalProperties: false
                        - type: object
                          description: >-
                            A custom plan charge: a charge whose price comes
                            from code that Aira writes for you, from the custom
                            charge definition that the charge follows and from
                            the parameter values of the charge. It bills in
                            arrears, in money.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: custom.'
                              enum:
                                - custom
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              description: The pricing model of the charge, always custom.
                              enum:
                                - custom
                            pricing:
                              type: object
                              description: >-
                                The price of a custom plan charge: the parameter
                                values that the code that Aira writes for you
                                turns into an amount.
                              properties:
                                model:
                                  description: 'The pricing model of the price: custom.'
                                  enum:
                                    - custom
                                parameters:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The parameter values of the charge, by the
                                    keys of the parameter schema of its custom
                                    charge definition.
                              required:
                                - model
                                - parameters
                              additionalProperties: false
                            customChargeDefinitionId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the custom charge
                                definition that the charge follows.
                            chosenResourceIds:
                              type: array
                              items:
                                type: string
                                format: uuid
                              description: >-
                                The unique identifiers of the resources that the
                                charge chose as its inputs, from the input
                                resources of its custom charge definition.
                            chosenLicenseIds:
                              type: array
                              items:
                                type: string
                                format: uuid
                              description: >-
                                The unique identifiers of the licenses that the
                                charge chose as its inputs, from the input
                                licenses of its custom charge definition.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - customChargeDefinitionId
                            - chosenResourceIds
                            - chosenLicenseIds
                          additionalProperties: false
                    description: The plan charges of the plan version.
                required:
                  - id
                  - versionNumber
                  - isActive
                  - planCharges
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `plan_version_already_active`: the plan version is already the
            active plan version of its plan.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - plan_version_already_active
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                plan_version_already_active:
                  value:
                    message: cannot roll back to the currently active plan version
                    code: plan_version_already_active
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plans:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `plan_version_not_found`: no plan version has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_version_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_version_not_found:
                  value:
                    message: plan version not found
                    code: plan_version_not_found
  /v1/plans/{id}/versions:
    get:
      summary: List plan versions
      tags:
        - Plans
      description: >-
        Lists the plan versions of a plan, newest first, without their plan
        charges, which `GET /v1/plans/version/{id}` fetches. A plan that does
        not exist answers an empty list.


        Requires the role `plans:read`.
      parameters:
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: >-
            The unique identifier of the plan whose plan versions the request
            lists.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: *ref_21
      responses:
        '200':
          description: The plan versions of the plan, newest first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A plan version in a list: one saved state of the plan
                        charges of a plan, without the plan charges.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the plan version in our
                            system.
                        versionNumber:
                          type: number
                          minimum: 1
                          description: >-
                            The number of the plan version in its plan, from 1,
                            one more for each new plan version.
                        isActive:
                          type: boolean
                          description: >-
                            Whether the plan version is the active plan version
                            of its plan, whose plan charges a new plan instance
                            of the plan bills. A plan has one active plan
                            version.
                        reason:
                          type: string
                          enum:
                            - created
                            - manual_override
                            - rollback
                          description: >-
                            Why the plan version exists: created (the first plan
                            version of the plan), manual_override (a change of
                            the plan charges of the plan) or rollback (a restore
                            of an earlier plan version).
                        createdAt:
                          type: string
                          format: date-time
                          description: The moment when Aira created the plan version.
                      required:
                        - id
                        - versionNumber
                        - isActive
                        - reason
                        - createdAt
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or a query
            parameter breaks the schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plans:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/plans/version/{id}:
    get:
      summary: Fetch plan version
      tags:
        - Plans
      description: |-
        Fetches a plan version by id, with its plan charges.

        Requires the role `plans:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the plan version.
      x-public-api: true
      x-errors:
        - status: 404
          code: plan_version_not_found
          when: no plan version has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_21
      responses:
        '200':
          description: 'A plan version: one saved state of the plan charges of a plan.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the plan version in our system.
                  versionNumber:
                    type: number
                    minimum: 1
                    description: >-
                      The number of the plan version in its plan, from 1, one
                      more for each new plan version.
                  isActive:
                    type: boolean
                    description: >-
                      Whether the plan version is the active plan version of its
                      plan, whose plan charges a new plan instance of the plan
                      bills. A plan has one active plan version.
                  planCharges:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing a plan charge, one priced line of a
                        plan: its item names what it bills, its category says
                        what it bills from, its pricing model turns a quantity
                        into money, and its billing frequency says how often it
                        bills. The fields of a charge depend on its category. An
                        amount is an integer number of cents, and a price is a
                        decimal string with up to 6 decimal places, in BRL or in
                        the credit unit of the charge.
                      discriminator:
                        propertyName: category
                      oneOf:
                        - type: object
                          description: >-
                            A fixed charge: the same amount in every charge
                            period, billed on the invoice that its billing
                            timing names.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: fixed.'
                              enum:
                                - fixed
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              description: The pricing model of the charge, always fixed.
                              enum:
                                - fixed
                            pricing:
                              type: object
                              description: >-
                                The price of a fixed charge or of a minimum
                                commitment.
                              properties:
                                model:
                                  description: 'The pricing model of the price: fixed.'
                                  enum:
                                    - fixed
                                amount:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The amount that the charge bills in each
                                    charge period, in cents, or the amount of
                                    one unit when the charge has a quantity. For
                                    a minimum commitment, the least that the
                                    charges of the plan with its billing
                                    frequency bill.
                                quantity:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units that a fixed charge
                                    bills in each charge period, when it has
                                    one, so that each charge period bills
                                    quantity times amount. A minimum commitment
                                    has none.
                              required:
                                - model
                                - amount
                              additionalProperties: false
                            billingTiming:
                              type: string
                              enum:
                                - in_advance
                                - in_arrears
                              description: >-
                                When the charge bills a charge period:
                                in_arrears bills it on the closing invoice of
                                its last cycle, and in_advance bills it before
                                it starts, on the activation invoice or on the
                                closing invoice of the cycle before. The billing
                                timing moves the invoice, never the amount.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - billingTiming
                          additionalProperties: false
                        - type: object
                          description: >-
                            A minimum commitment: the least that the plan bills
                            in a charge period. When the charges of the plan
                            with the same billing frequency total less, the
                            charge bills the difference. A plan has at most one
                            for each billing frequency.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: minimum_commitment.'
                              enum:
                                - minimum_commitment
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              description: The pricing model of the charge, always fixed.
                              enum:
                                - fixed
                            pricing:
                              type: object
                              description: >-
                                The price of a fixed charge or of a minimum
                                commitment.
                              properties:
                                model:
                                  description: 'The pricing model of the price: fixed.'
                                  enum:
                                    - fixed
                                amount:
                                  type: integer
                                  minimum: 0
                                  description: >-
                                    The amount that the charge bills in each
                                    charge period, in cents, or the amount of
                                    one unit when the charge has a quantity. For
                                    a minimum commitment, the least that the
                                    charges of the plan with its billing
                                    frequency bill.
                                quantity:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units that a fixed charge
                                    bills in each charge period, when it has
                                    one, so that each charge period bills
                                    quantity times amount. A minimum commitment
                                    has none.
                              required:
                                - model
                                - amount
                              additionalProperties: false
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                          additionalProperties: false
                        - type: object
                          description: >-
                            A usage-based charge: a charge on the usage of a
                            resource in its charge period, priced by its pricing
                            model.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: usage_based.'
                              enum:
                                - usage_based
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              enum:
                                - per_unit
                                - per_package
                                - percentage
                                - tiered_per_unit
                                - tiered_percentage
                                - tiered_fixed
                                - advanced
                              description: >-
                                The pricing model of the charge, the same as
                                pricing.model. per_unit, per_package and
                                tiered_per_unit price a resource in units,
                                percentage and tiered_percentage price a
                                resource in money, and tiered_fixed and advanced
                                price either.
                            pricing:
                              type: object
                              description: >-
                                The price of a usage-based or license-based
                                charge, by pricing model. Its model is the
                                pricingModel of the charge.
                              discriminator:
                                propertyName: model
                              oneOf:
                                - type: object
                                  description: >-
                                    Per unit: each unit of the charge period
                                    past the included quantity costs unitPrice.
                                    A charge on a resource in money cannot have
                                    it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_unit.
                                      enum:
                                        - per_unit
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    unitPrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one unit, as a decimal
                                        string.
                                      examples:
                                        - '0.25'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - unitPrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Per package: the units of the charge period
                                    past the included quantity bill packagePrice
                                    for each package of packageSize units that
                                    they start. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_package.
                                      enum:
                                        - per_package
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    packageSize:
                                      type: integer
                                      minimum: 1
                                      description: The number of units in one package.
                                    packagePrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one package, as a decimal
                                        string.
                                      examples:
                                        - '50.00'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - packageSize
                                    - packagePrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Percentage: the charge bills a percentage of
                                    the usage of its resource in the charge
                                    period. Only a charge on a resource in money
                                    has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        percentage.
                                      enum:
                                        - percentage
                                    percentage:
                                      type: string
                                      pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                      description: >-
                                        The percentage of the usage that the
                                        charge bills, as a decimal string from 0
                                        to 100.
                                      examples:
                                        - '2.5'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - percentage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered per unit: the tiers of the charge
                                    price its units, and each tier prices them
                                    per unit. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_per_unit.
                                      enum:
                                        - tiered_per_unit
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered percentage: the tiers of the charge
                                    price its usage, and each tier bills a
                                    percentage of it. Only a charge on a
                                    resource in money has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_percentage.
                                      enum:
                                        - tiered_percentage
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered fixed: the tier that the whole
                                    quantity reaches bills its flat amount. When
                                    the last tier has an end, unitOverage or
                                    percentageOverage prices the quantity past
                                    it, and a charge never has both.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_fixed.
                                      enum:
                                        - tiered_fixed
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        Always volume, because the tier that the
                                        whole quantity reaches bills its flat
                                        amount.
                                    unitOverage:
                                      type: object
                                      description: >-
                                        The price of the units past the last
                                        tier, for a charge on a resource in
                                        units or on a license, when the charge
                                        has one.
                                      properties:
                                        excessUnitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit past the last
                                            tier, as a decimal string.
                                          examples:
                                            - '0.30'
                                      required:
                                        - excessUnitPrice
                                      additionalProperties: false
                                    percentageOverage:
                                      type: object
                                      description: >-
                                        The percentage of the usage past the
                                        last tier that the charge bills, for a
                                        charge on a resource in money, when the
                                        charge has one.
                                      properties:
                                        excessPercentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, as a
                                            decimal string from 0 to 100.
                                          examples:
                                            - '1.5'
                                      required:
                                        - excessPercentage
                                      additionalProperties: false
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  not:
                                    required:
                                      - unitOverage
                                      - percentageOverage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Advanced: tiers of mixed types price the
                                    quantity. The tiers of a charge on a
                                    resource in units are per_unit, per_package
                                    or flat, and those of a charge on a resource
                                    in money are percentage or flat. A charge
                                    priced before the other pricing models
                                    existed has it too.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        advanced.
                                      enum:
                                        - advanced
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                            resourceId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the resource whose
                                usage the charge prices.
                            currencyUnit:
                              type: object
                              description: >-
                                The currency unit that the charge is priced in,
                                or null when the charge has none. A charge with
                                no currency unit or in BRL, the default currency
                                unit, bills money. A charge in any other
                                currency unit, a credit unit, decreases the
                                balance of a credit pool in that unit and bills
                                no money.
                              properties:
                                id:
                                  type: string
                                  format: uuid
                                  description: >-
                                    The unique identifier of the currency unit
                                    in our system.
                                name:
                                  type: string
                                  description: The name of the currency unit.
                                  examples:
                                    - Real
                                code:
                                  type: string
                                  description: The short code of the currency unit.
                                  examples:
                                    - BRL
                              required:
                                - id
                                - name
                                - code
                              additionalProperties: false
                              nullable: true
                            tiers:
                              type: array
                              items:
                                type: object
                                description: >-
                                  A price tier of the charge: a band of
                                  quantity, from one number to another, with its
                                  own price. The first tier starts at 0 or 1,
                                  and each tier starts at the to of the tier
                                  before it plus 1.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the tier in our
                                      system.
                                  position:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The position of the tier in the charge,
                                      from 0, from the lowest band to the
                                      highest.
                                  from:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The first quantity of the band, which the
                                      band includes: a number of units of the
                                      resource or of the license, or of cents
                                      for a resource in money.
                                  to:
                                    type: integer
                                    minimum: 0
                                    nullable: true
                                    description: >-
                                      The last quantity of the band, which the
                                      band includes, in the unit of from, or
                                      null when the band has no end. The last
                                      tier has an end only on a charge with the
                                      pricing model tiered_fixed and an overage.
                                  pricing:
                                    type: object
                                    description: >-
                                      The price of the quantity that falls in
                                      the tier, by type: per_unit, percentage,
                                      per_package or flat.
                                    discriminator:
                                      propertyName: type
                                    oneOf:
                                      - type: object
                                        description: >-
                                          Per unit: each unit in the tier costs
                                          unitPrice. A charge on a resource in
                                          money cannot have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_unit.'
                                            enum:
                                              - per_unit
                                          unitPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one unit in the tier, as a
                                              decimal string.
                                            examples:
                                              - '0.20'
                                          fixedPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            nullable: true
                                            description: >-
                                              An amount that the tier bills on top of
                                              its units when the tier applies, as a
                                              decimal string, or null when it has
                                              none. Only a tier of a charge with the
                                              pricing model tiered_per_unit has an
                                              amount other than zero.
                                            examples:
                                              - '10.00'
                                        required:
                                          - type
                                          - unitPrice
                                          - fixedPrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Percentage: the tier bills a percentage
                                          of the usage that falls in it. Only a
                                          charge on a resource in money has it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: percentage.'
                                            enum:
                                              - percentage
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              The percentage of the usage in the tier
                                              that the tier bills, as a decimal string
                                              from 0 to 100.
                                            examples:
                                              - '1.5'
                                        required:
                                          - type
                                          - percentage
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Per package: the units in the tier bill
                                          packagePrice for each package of
                                          packageSize units that they start. A
                                          charge on a resource in money cannot
                                          have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_package.'
                                            enum:
                                              - per_package
                                          packageSize:
                                            type: integer
                                            minimum: 1
                                            description: The number of units in one package.
                                          packagePrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one package, as a decimal
                                              string.
                                            examples:
                                              - '45.00'
                                        required:
                                          - type
                                          - packageSize
                                          - packagePrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Flat: the tier bills one amount,
                                          whatever the quantity that falls in it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: flat.'
                                            enum:
                                              - flat
                                          amount:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The amount that the tier bills, as a
                                              decimal string.
                                            examples:
                                              - '199.90'
                                        required:
                                          - type
                                          - amount
                                        additionalProperties: false
                                required:
                                  - id
                                  - position
                                  - from
                                  - to
                                  - pricing
                                additionalProperties: false
                              description: >-
                                The price tiers of the charge, from the lowest
                                band to the highest, for the pricing models
                                tiered_per_unit, tiered_percentage, tiered_fixed
                                and advanced, or an empty list for the other
                                pricing models.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - resourceId
                            - currencyUnit
                            - tiers
                          additionalProperties: false
                        - type: object
                          description: >-
                            A license-based charge: a charge on the balance of a
                            license in its charge period, read by its billing
                            model and priced by its pricing model.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: license_based.'
                              enum:
                                - license_based
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              enum:
                                - per_unit
                                - per_package
                                - tiered_per_unit
                                - tiered_fixed
                              description: >-
                                The pricing model of the charge, the same as
                                pricing.model: per_unit, per_package,
                                tiered_per_unit or tiered_fixed. No percentage
                                applies, because the balance of a license is a
                                count, not an amount of money.
                            pricing:
                              type: object
                              description: >-
                                The price of a usage-based or license-based
                                charge, by pricing model. Its model is the
                                pricingModel of the charge.
                              discriminator:
                                propertyName: model
                              oneOf:
                                - type: object
                                  description: >-
                                    Per unit: each unit of the charge period
                                    past the included quantity costs unitPrice.
                                    A charge on a resource in money cannot have
                                    it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_unit.
                                      enum:
                                        - per_unit
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    unitPrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one unit, as a decimal
                                        string.
                                      examples:
                                        - '0.25'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - unitPrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Per package: the units of the charge period
                                    past the included quantity bill packagePrice
                                    for each package of packageSize units that
                                    they start. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        per_package.
                                      enum:
                                        - per_package
                                    includedQuantity:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The number of units of each charge
                                        period that the charge does not bill,
                                        when it has one.
                                    packageSize:
                                      type: integer
                                      minimum: 1
                                      description: The number of units in one package.
                                    packagePrice:
                                      type: string
                                      pattern: ^\d+(\.\d{1,6})?$
                                      description: >-
                                        The price of one package, as a decimal
                                        string.
                                      examples:
                                        - '50.00'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - packageSize
                                    - packagePrice
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Percentage: the charge bills a percentage of
                                    the usage of its resource in the charge
                                    period. Only a charge on a resource in money
                                    has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        percentage.
                                      enum:
                                        - percentage
                                    percentage:
                                      type: string
                                      pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                      description: >-
                                        The percentage of the usage that the
                                        charge bills, as a decimal string from 0
                                        to 100.
                                      examples:
                                        - '2.5'
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - percentage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered per unit: the tiers of the charge
                                    price its units, and each tier prices them
                                    per unit. A charge on a resource in money
                                    cannot have it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_per_unit.
                                      enum:
                                        - tiered_per_unit
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered percentage: the tiers of the charge
                                    price its usage, and each tier bills a
                                    percentage of it. Only a charge on a
                                    resource in money has it.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_percentage.
                                      enum:
                                        - tiered_percentage
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Tiered fixed: the tier that the whole
                                    quantity reaches bills its flat amount. When
                                    the last tier has an end, unitOverage or
                                    percentageOverage prices the quantity past
                                    it, and a charge never has both.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        tiered_fixed.
                                      enum:
                                        - tiered_fixed
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        Always volume, because the tier that the
                                        whole quantity reaches bills its flat
                                        amount.
                                    unitOverage:
                                      type: object
                                      description: >-
                                        The price of the units past the last
                                        tier, for a charge on a resource in
                                        units or on a license, when the charge
                                        has one.
                                      properties:
                                        excessUnitPrice:
                                          type: string
                                          pattern: ^\d+(\.\d{1,6})?$
                                          description: >-
                                            The price of one unit past the last
                                            tier, as a decimal string.
                                          examples:
                                            - '0.30'
                                      required:
                                        - excessUnitPrice
                                      additionalProperties: false
                                    percentageOverage:
                                      type: object
                                      description: >-
                                        The percentage of the usage past the
                                        last tier that the charge bills, for a
                                        charge on a resource in money, when the
                                        charge has one.
                                      properties:
                                        excessPercentage:
                                          type: string
                                          pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                          description: >-
                                            The percentage of the usage past the
                                            last tier that the charge bills, as a
                                            decimal string from 0 to 100.
                                          examples:
                                            - '1.5'
                                      required:
                                        - excessPercentage
                                      additionalProperties: false
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  not:
                                    required:
                                      - unitOverage
                                      - percentageOverage
                                  additionalProperties: false
                                - type: object
                                  description: >-
                                    Advanced: tiers of mixed types price the
                                    quantity. The tiers of a charge on a
                                    resource in units are per_unit, per_package
                                    or flat, and those of a charge on a resource
                                    in money are percentage or flat. A charge
                                    priced before the other pricing models
                                    existed has it too.
                                  properties:
                                    model:
                                      description: >-
                                        The pricing model of the price:
                                        advanced.
                                      enum:
                                        - advanced
                                    tierMode:
                                      enum:
                                        - progressive
                                        - volume
                                      description: >-
                                        How the tiers price the quantity:
                                        progressive splits it across the tiers,
                                        and volume prices all of it at the tier
                                        that it reaches.
                                    fixedAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        An amount that the charge adds in each
                                        charge period on top of its priced
                                        quantity, in cents, when it has one.
                                    minimumAmount:
                                      type: integer
                                      minimum: 0
                                      description: >-
                                        The least that the charge bills in a
                                        charge period, in cents, when it has
                                        one: when the priced quantity plus
                                        fixedAmount comes to less, the charge
                                        bills this amount.
                                  required:
                                    - model
                                    - tierMode
                                  additionalProperties: false
                            licenseId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the license whose
                                balance the charge bills.
                            billingModel:
                              type: string
                              enum:
                                - in_full
                                - proration
                              description: >-
                                How the charge reads the balance of its license
                                in a charge period: in_full bills the last
                                balance, and proration weighs each balance by
                                the days that it was in effect.
                            tiers:
                              type: array
                              items:
                                type: object
                                description: >-
                                  A price tier of the charge: a band of
                                  quantity, from one number to another, with its
                                  own price. The first tier starts at 0 or 1,
                                  and each tier starts at the to of the tier
                                  before it plus 1.
                                properties:
                                  id:
                                    type: string
                                    format: uuid
                                    description: >-
                                      The unique identifier of the tier in our
                                      system.
                                  position:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The position of the tier in the charge,
                                      from 0, from the lowest band to the
                                      highest.
                                  from:
                                    type: integer
                                    minimum: 0
                                    description: >-
                                      The first quantity of the band, which the
                                      band includes: a number of units of the
                                      resource or of the license, or of cents
                                      for a resource in money.
                                  to:
                                    type: integer
                                    minimum: 0
                                    nullable: true
                                    description: >-
                                      The last quantity of the band, which the
                                      band includes, in the unit of from, or
                                      null when the band has no end. The last
                                      tier has an end only on a charge with the
                                      pricing model tiered_fixed and an overage.
                                  pricing:
                                    type: object
                                    description: >-
                                      The price of the quantity that falls in
                                      the tier, by type: per_unit, percentage,
                                      per_package or flat.
                                    discriminator:
                                      propertyName: type
                                    oneOf:
                                      - type: object
                                        description: >-
                                          Per unit: each unit in the tier costs
                                          unitPrice. A charge on a resource in
                                          money cannot have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_unit.'
                                            enum:
                                              - per_unit
                                          unitPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one unit in the tier, as a
                                              decimal string.
                                            examples:
                                              - '0.20'
                                          fixedPrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            nullable: true
                                            description: >-
                                              An amount that the tier bills on top of
                                              its units when the tier applies, as a
                                              decimal string, or null when it has
                                              none. Only a tier of a charge with the
                                              pricing model tiered_per_unit has an
                                              amount other than zero.
                                            examples:
                                              - '10.00'
                                        required:
                                          - type
                                          - unitPrice
                                          - fixedPrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Percentage: the tier bills a percentage
                                          of the usage that falls in it. Only a
                                          charge on a resource in money has it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: percentage.'
                                            enum:
                                              - percentage
                                          percentage:
                                            type: string
                                            pattern: ^(100(\.0{1,6})?|\d{1,2}(\.\d{1,6})?)$
                                            description: >-
                                              The percentage of the usage in the tier
                                              that the tier bills, as a decimal string
                                              from 0 to 100.
                                            examples:
                                              - '1.5'
                                        required:
                                          - type
                                          - percentage
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Per package: the units in the tier bill
                                          packagePrice for each package of
                                          packageSize units that they start. A
                                          charge on a resource in money cannot
                                          have it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: per_package.'
                                            enum:
                                              - per_package
                                          packageSize:
                                            type: integer
                                            minimum: 1
                                            description: The number of units in one package.
                                          packagePrice:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The price of one package, as a decimal
                                              string.
                                            examples:
                                              - '45.00'
                                        required:
                                          - type
                                          - packageSize
                                          - packagePrice
                                        additionalProperties: false
                                      - type: object
                                        description: >-
                                          Flat: the tier bills one amount,
                                          whatever the quantity that falls in it.
                                        properties:
                                          type:
                                            description: 'The type of the tier price: flat.'
                                            enum:
                                              - flat
                                          amount:
                                            type: string
                                            pattern: ^\d+(\.\d{1,6})?$
                                            description: >-
                                              The amount that the tier bills, as a
                                              decimal string.
                                            examples:
                                              - '199.90'
                                        required:
                                          - type
                                          - amount
                                        additionalProperties: false
                                required:
                                  - id
                                  - position
                                  - from
                                  - to
                                  - pricing
                                additionalProperties: false
                              description: >-
                                The price tiers of the charge, from the lowest
                                band to the highest, for the pricing models
                                tiered_per_unit and tiered_fixed, or an empty
                                list for the other pricing models.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - licenseId
                            - billingModel
                            - tiers
                          additionalProperties: false
                        - type: object
                          description: >-
                            A custom plan charge: a charge whose price comes
                            from code that Aira writes for you, from the custom
                            charge definition that the charge follows and from
                            the parameter values of the charge. It bills in
                            arrears, in money.
                          properties:
                            category:
                              type: string
                              description: 'The category of the charge: custom.'
                              enum:
                                - custom
                            id:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the plan charge in our
                                system.
                            position:
                              type: integer
                              minimum: 0
                              description: >-
                                The position of the charge in the plan, from 0,
                                in the order that the billing app shows.
                            itemId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the item that the
                                charge bills. The line items of the charge name
                                the same item.
                            productId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the product that the
                                charge belongs to.
                            name:
                              type: string
                              minLength: 1
                              description: The name of the charge, as the invoices show it.
                              examples:
                                - Mensalidade
                            isCustomNameEnabled:
                              type: boolean
                              description: >-
                                Whether the charge has a name of its own. When
                                false, the name of the charge is the name of its
                                resource, of its license or of its item.
                            billingFrequency:
                              type: object
                              description: >-
                                How often the charge bills: each charge period
                                of the charge lasts count units, the charge
                                counts its charge periods from the contract
                                start, and it bills each charge period once.
                                Aira accepts 1 or 2 weeks and 1, 3, 6 or 12
                                months, and a prorated charge bills every week
                                or every month.
                              properties:
                                unit:
                                  type: string
                                  enum:
                                    - month
                                    - week
                                  description: >-
                                    The unit of the billing frequency: month or
                                    week. Every charge of a plan has the same
                                    unit.
                                count:
                                  type: integer
                                  minimum: 1
                                  description: >-
                                    The number of units in each charge period of
                                    the charge.
                              required:
                                - unit
                                - count
                              additionalProperties: false
                            pricingModel:
                              type: string
                              description: The pricing model of the charge, always custom.
                              enum:
                                - custom
                            pricing:
                              type: object
                              description: >-
                                The price of a custom plan charge: the parameter
                                values that the code that Aira writes for you
                                turns into an amount.
                              properties:
                                model:
                                  description: 'The pricing model of the price: custom.'
                                  enum:
                                    - custom
                                parameters:
                                  type: object
                                  additionalProperties: true
                                  description: >-
                                    The parameter values of the charge, by the
                                    keys of the parameter schema of its custom
                                    charge definition.
                              required:
                                - model
                                - parameters
                              additionalProperties: false
                            customChargeDefinitionId:
                              type: string
                              format: uuid
                              description: >-
                                The unique identifier of the custom charge
                                definition that the charge follows.
                            chosenResourceIds:
                              type: array
                              items:
                                type: string
                                format: uuid
                              description: >-
                                The unique identifiers of the resources that the
                                charge chose as its inputs, from the input
                                resources of its custom charge definition.
                            chosenLicenseIds:
                              type: array
                              items:
                                type: string
                                format: uuid
                              description: >-
                                The unique identifiers of the licenses that the
                                charge chose as its inputs, from the input
                                licenses of its custom charge definition.
                          required:
                            - id
                            - position
                            - itemId
                            - productId
                            - name
                            - isCustomNameEnabled
                            - category
                            - pricingModel
                            - pricing
                            - billingFrequency
                            - customChargeDefinitionId
                            - chosenResourceIds
                            - chosenLicenseIds
                          additionalProperties: false
                    description: The plan charges of the plan version.
                required:
                  - id
                  - versionNumber
                  - isActive
                  - planCharges
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role plans:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `plan_version_not_found`: no plan version has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - plan_version_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                plan_version_not_found:
                  value:
                    message: plan version not found
                    code: plan_version_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/legal-entities/:
    get:
      summary: List legal entities
      tags:
        - Legal Entities
      description: >-
        Lists the legal entities, the registered companies that issue the
        invoices, newest first by creation time. A contract names one of them in
        its `legalEntityId`.


        Requires the role `legal_entities:read`.
      parameters:
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles:
        - legal_entities:read
      responses:
        '200':
          description: A page of the legal entities.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A legal entity: a registered company that issues
                        invoices. At least one exists, and each contract names
                        one in its `legalEntityId`.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: The unique identifier of the legal entity.
                        businessName:
                          type: string
                          description: >-
                            The registered business name (razão social) of the
                            legal entity.
                          example: Padaria Central Ltda
                        taxId:
                          type: string
                          pattern: ^(^\d{14}$|^\d{11}$)$
                          description: >-
                            The tax id of the legal entity, digits only: the 14
                            digits of a CNPJ or the 11 digits of a CPF.
                          example: '01234567000195'
                        taxIdType:
                          type: string
                          enum:
                            - cnpj
                            - cpf
                          description: >-
                            The kind of tax id in `taxId`: `cnpj` for a company
                            or `cpf` for a person.
                        tradeName:
                          description: >-
                            The trade name (nome fantasia) of the legal entity,
                            or null when it has none.
                          type:
                            - 'null'
                            - string
                          example: Padaria Central
                      required:
                        - id
                        - businessName
                        - tradeName
                        - taxId
                        - taxIdType
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''offset'' must be integer'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role legal_entities:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/watchtower/contract-ingestion:
    post:
      summary: Upload a contract PDF for ingestion
      tags:
        - Watchtower
      description: >-
        Creates a contract ingestion task from the uploaded contract PDF and
        adds it to the review inbox of the billing app. Aira then reads the PDF
        in the background into a proposal of a contract, which a user approves
        or rejects in the billing app. The multipart form takes the PDF as its
        one file and, in the optional `contractShape` field, the contract shape
        of the PDF.


        Requires the role `watchtower:write`.
      x-public-api: true
      x-errors:
        - status: 400
          code: multiple_contract_pdfs_not_allowed
          when: the form has more than one file
        - status: 400
          code: contract_pdf_not_provided
          when: the form has no file, or its file has no name
        - status: 400
          code: invalid_contract_shape
          when: '`contractShape` does not start with `default:` or `custom:`'
        - status: 400
          code: invalid_contract_pdf
          when: the file is not a PDF
        - status: 422
          code: contract_pdf_too_large
          when: the PDF is larger than the size that Aira can read
      x-required-roles:
        - watchtower:write
      responses:
        '201':
          description: >-
            The task that reads the uploaded contract PDF, and whether another
            task holds the same PDF.
          content:
            application/json:
              schema:
                type: object
                properties:
                  task:
                    type: object
                    description: The contract ingestion task that the upload created.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the task in our system.
                      type:
                        type: string
                        enum:
                          - contract_ingestion
                        description: >-
                          The kind of the task: `contract_ingestion` reads a
                          contract PDF into a proposal of a contract.
                      status:
                        type: string
                        enum:
                          - pending
                          - processing
                          - awaiting_action
                          - completed
                          - dismissed
                          - failed
                        description: >-
                          Where the task stands: `pending` until Aira starts to
                          read the PDF, `processing` while Aira reads it,
                          `awaiting_action` until a user approves or rejects it,
                          `completed` once a user approves it, `dismissed` once
                          a user rejects it, and `failed` when the reading of
                          the PDF or an approval failed.
                      createdAt:
                        type: string
                        format: date-time
                        description: >-
                          ISO 8601 timestamp in UTC indicating when Aira created
                          the task.
                    required:
                      - id
                      - type
                      - status
                      - createdAt
                    additionalProperties: false
                  duplicateWarning:
                    type: boolean
                    description: >-
                      Whether another task holds the same PDF, leaving out a
                      task that a user rejected and a task whose PDF Aira failed
                      to read.
                required:
                  - task
                  - duplicateWarning
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `multiple_contract_pdfs_not_allowed`: the form has more than one
            file.

            - `contract_pdf_not_provided`: the form has no file, or its file has
            no name.

            - `invalid_contract_shape`: `contractShape` does not start with
            `default:` or `custom:`.

            - `invalid_contract_pdf`: the file is not a PDF.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - multiple_contract_pdfs_not_allowed
                      - contract_pdf_not_provided
                      - invalid_contract_shape
                      - invalid_contract_pdf
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                multiple_contract_pdfs_not_allowed:
                  value:
                    message: only one contract pdf may be uploaded at a time
                    code: multiple_contract_pdfs_not_allowed
                contract_pdf_not_provided:
                  value:
                    message: contract pdf not provided
                    code: contract_pdf_not_provided
                invalid_contract_shape:
                  value:
                    message: 'contract shape must be a default: or custom: key'
                    code: invalid_contract_shape
                invalid_contract_pdf:
                  value:
                    message: uploaded file is not a pdf
                    code: invalid_contract_pdf
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role watchtower:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '413':
          description: >-
            A file or the body of the request is larger than its limit.


            - `file_too_large`: a file of the form is larger than the limit of
            the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - file_too_large
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                file_too_large:
                  value:
                    message: a file of the request is larger than the limit
                    code: file_too_large
        '422':
          description: >-
            An outside service refuses the data of the request.


            - `contract_pdf_too_large`: the PDF is larger than the size that
            Aira can read.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - contract_pdf_too_large
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                contract_pdf_too_large:
                  value:
                    message: the PDF is larger than the size that Aira can read
                    code: contract_pdf_too_large
  /v1/payment-accounts/:
    post:
      summary: Create payment account
      tags:
        - Payment Accounts
      description: >-
        Creates a payment account for a customer, with the company or person who
        pays its invoices: its names, its tax id, its phone, its address and its
        invoice recipients. The payment account becomes the default one of its
        customer when the customer has none.


        Requires the role `payment_accounts:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                customerId:
                  description: >-
                    The unique identifier of the customer that owns the payment
                    account.
                  type: string
                  format: uuid
                legalEntity:
                  type: object
                  description: >-
                    The company or person who pays the invoices of the payment
                    account: its names, its tax id, its phone, its address and
                    its invoice recipients.
                  properties:
                    tradeName:
                      type: string
                      nullable: true
                      description: >-
                        The trade name (nome fantasia) of the legal entity, or
                        null when it has none.
                      example: Padaria Central
                    businessName:
                      type: string
                      description: >-
                        The registered business name (razão social) of the legal
                        entity.
                      example: Padaria Central Ltda
                    emails:
                      type: array
                      items:
                        type: string
                        format: email
                      default: []
                      description: >-
                        The e-mails of the legal entity. When the legal entity
                        belongs to a payment account, its e-mails are the
                        invoice recipients of that account: they receive the
                        invoices billed to it.
                    taxId:
                      type: string
                      pattern: ^(^\d{14}$|^\d{11}$)$
                      description: >-
                        The tax id of the legal entity, digits only: the 14
                        digits of a CNPJ or the 11 digits of a CPF.
                      example: '01234567000195'
                    taxIdType:
                      type: string
                      enum:
                        - cnpj
                        - cpf
                      description: >-
                        The kind of tax id in `taxId`: `cnpj` for a company or
                        `cpf` for a person.
                    zipCode:
                      type: string
                      pattern: ^[0-9]{8}$
                      nullable: true
                      description: >-
                        The postal code (CEP) of the address of the legal
                        entity, as 8 digits with no mask, or null when it has
                        none.
                      example: '01310100'
                    street:
                      type: string
                      nullable: true
                      description: >-
                        The street of the address of the legal entity, or null
                        when it has none.
                      example: Avenida Paulista
                    number:
                      type: string
                      nullable: true
                      description: >-
                        The street number of the address of the legal entity, or
                        null when it has none.
                      example: '1000'
                    neighborhood:
                      type: string
                      nullable: true
                      description: >-
                        The neighborhood (bairro) of the address of the legal
                        entity, or null when it has none.
                      example: Bela Vista
                    city:
                      type: string
                      nullable: true
                      description: >-
                        The city of the address of the legal entity, or null
                        when it has none.
                      example: São Paulo
                    state:
                      type:
                        - 'null'
                        - string
                      enum:
                        - AC
                        - AL
                        - AP
                        - AM
                        - BA
                        - CE
                        - DF
                        - ES
                        - GO
                        - MA
                        - MT
                        - MS
                        - MG
                        - PA
                        - PB
                        - PR
                        - PE
                        - PI
                        - RJ
                        - RN
                        - RS
                        - RO
                        - RR
                        - SC
                        - SP
                        - SE
                        - TO
                        - null
                      description: >-
                        The state of the address of the legal entity, as its
                        two-letter code, or null when it has none.
                    country:
                      type:
                        - 'null'
                        - string
                      enum:
                        - Brasil
                        - null
                      description: >-
                        The country of the address of the legal entity, or null
                        when it has none.
                    complement:
                      type: string
                      nullable: true
                      description: >-
                        The complement of the address of the legal entity, such
                        as a suite or a floor, or null when it has none.
                      example: Sala 12
                    customFields:
                      type: object
                      description: >-
                        Custom fields that can be associated with the entity.
                        The fields must be previously created in the system
                        before they can be used.
                      additionalProperties:
                        anyOf:
                          - type: string
                          - type: array
                            items:
                              type: string
                      default: {}
                      example:
                        customField1: value1
                        customField2:
                          - value2
                          - value3
                    phone:
                      type: string
                      pattern: ^\d{10,11}$
                      nullable: true
                      description: >-
                        Phone of the payment account: the 10 or 11 digits of a
                        Brazilian landline or mobile number with its area code,
                        with no mask and no country code. Aira rejects a number
                        that does not exist in Brazil, such as one with an area
                        code that does not exist. Null when absent.
                      errorMessage:
                        pattern: >-
                          must hold only the 10 or 11 digits of a Brazilian
                          number with its area code, as in 11987654321
                      example: '11987654321'
                  required:
                    - businessName
                    - taxId
                    - taxIdType
                    - customFields
                  additionalProperties: false
              required:
                - customerId
                - legalEntity
              additionalProperties: false
        required: true
        description: >-
          A payment account for a customer, with the company or person who pays
          its invoices.
      parameters:
        - schema:
            type: boolean
            default: false
          in: header
          name: override-tax-id-uniqueness
          required: false
          description: When true, accepts a tax ID that another payment account holds.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_tax_id
          when: the `taxId` is not a valid CNPJ or CPF for its `taxIdType`
        - status: 400
          code: invalid_phone
          when: >-
            the `phone` is not a valid Brazilian number, such as one with an
            area code that does not exist
        - status: 400
          code: tax_id_belongs_to_payment_account_from_the_same_customer
          when: >-
            another payment account of the customer that is not archived holds
            the `taxId`, and the `override-tax-id-uniqueness` header is not true
        - status: 400
          code: tax_id_belongs_to_another_payment_account
          when: >-
            a payment account of another customer holds the `taxId`, with
            neither that payment account nor that customer archived, and the
            `override-tax-id-uniqueness` header is not true
        - status: 400
          code: payment_account_without_address
          when: >-
            the `legalEntity` has some but not all of `zipCode`, `number`,
            `street`, `neighborhood`, `city`, `state` and `country`, or has none
            of them while the integration with Celcash is on
        - status: 404
          code: customer_not_found
          when: no customer has the `customerId`
      x-required-roles: &ref_22
        - payment_accounts:write
      responses:
        '201':
          description: >-
            A payment account, the record of who pays a customer's invoices: a
            name, a tax id, an optional phone and the e-mails that receive the
            invoices. A customer can have several, with one as the default.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: >-
                      The unique identifier of the payment account in our
                      system.
                    type: string
                    format: uuid
                  customerId:
                    description: >-
                      The unique identifier of the customer that owns the
                      payment account.
                    type: string
                    format: uuid
                  archivedAt:
                    description: Archive timestamp for payment accounts that were archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                  isDefault:
                    description: >-
                      Whether the payment account is the default payment account
                      of its customer.
                    type: boolean
                  legalEntity:
                    type: object
                    description: >-
                      The company or person who pays the invoices of the payment
                      account: its names, its tax id, its phone, its address and
                      its invoice recipients.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the legal entity.
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          The trade name (nome fantasia) of the legal entity, or
                          null when it has none.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          The registered business name (razão social) of the
                          legal entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        default: []
                        description: >-
                          The e-mails of the legal entity. When the legal entity
                          belongs to a payment account, its e-mails are the
                          invoice recipients of that account: they receive the
                          invoices billed to it.
                      taxId:
                        type: string
                        pattern: ^(^\d{14}$|^\d{11}$)$
                        description: >-
                          The tax id of the legal entity, digits only: the 14
                          digits of a CNPJ or the 11 digits of a CPF.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax id in `taxId`: `cnpj` for a company or
                          `cpf` for a person.
                      zipCode:
                        type: string
                        pattern: ^[0-9]{8}$
                        nullable: true
                        description: >-
                          The postal code (CEP) of the address of the legal
                          entity, as 8 digits with no mask, or null when it has
                          none.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: >-
                          The street of the address of the legal entity, or null
                          when it has none.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          The street number of the address of the legal entity,
                          or null when it has none.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          The neighborhood (bairro) of the address of the legal
                          entity, or null when it has none.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: >-
                          The city of the address of the legal entity, or null
                          when it has none.
                        example: São Paulo
                      state:
                        type:
                          - 'null'
                          - string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        description: >-
                          The state of the address of the legal entity, as its
                          two-letter code, or null when it has none.
                      country:
                        type:
                          - 'null'
                          - string
                        enum:
                          - Brasil
                          - null
                        description: >-
                          The country of the address of the legal entity, or
                          null when it has none.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          The complement of the address of the legal entity,
                          such as a suite or a floor, or null when it has none.
                        example: Sala 12
                      customFields:
                        type: object
                        description: >-
                          Custom fields that can be associated with the entity.
                          The fields must be previously created in the system
                          before they can be used.
                        additionalProperties:
                          anyOf:
                            - type: string
                            - type: array
                              items:
                                type: string
                        default: {}
                        example:
                          customField1: value1
                          customField2:
                            - value2
                            - value3
                      phone:
                        type: string
                        pattern: ^\d{10,11}$
                        nullable: true
                        description: >-
                          Phone of the payment account: the 10 or 11 digits of a
                          Brazilian landline or mobile number with its area
                          code, with no mask and no country code. Aira rejects a
                          number that does not exist in Brazil, such as one with
                          an area code that does not exist. Null when absent.
                        errorMessage:
                          pattern: >-
                            must hold only the 10 or 11 digits of a Brazilian
                            number with its area code, as in 11987654321
                        example: '11987654321'
                    required:
                      - id
                      - businessName
                      - taxId
                      - taxIdType
                      - customFields
                    additionalProperties: false
                required:
                  - id
                  - customerId
                  - archivedAt
                  - isDefault
                  - legalEntity
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `invalid_tax_id`: the `taxId` is not a valid CNPJ or CPF for its
            `taxIdType`.

            - `invalid_phone`: the `phone` is not a valid Brazilian number, such
            as one with an area code that does not exist.

            - `tax_id_belongs_to_payment_account_from_the_same_customer`:
            another payment account of the customer that is not archived holds
            the `taxId`, and the `override-tax-id-uniqueness` header is not
            true.

            - `tax_id_belongs_to_another_payment_account`: a payment account of
            another customer holds the `taxId`, with neither that payment
            account nor that customer archived, and the
            `override-tax-id-uniqueness` header is not true.

            - `payment_account_without_address`: the `legalEntity` has some but
            not all of `zipCode`, `number`, `street`, `neighborhood`, `city`,
            `state` and `country`, or has none of them while the integration
            with Celcash is on.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_tax_id
                      - invalid_phone
                      - tax_id_belongs_to_payment_account_from_the_same_customer
                      - tax_id_belongs_to_another_payment_account
                      - payment_account_without_address
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''customerId'' is required'
                    code: json_schema_validation_error
                invalid_tax_id:
                  value:
                    message: Invalid tax id
                    code: invalid_tax_id
                invalid_phone:
                  value:
                    message: >-
                      Invalid phone: send the 10 or 11 digits of a Brazilian
                      number with its area code, as in 11987654321
                    code: invalid_phone
                tax_id_belongs_to_payment_account_from_the_same_customer:
                  value:
                    message: Tax id belongs to a payment account from the same customer
                    code: tax_id_belongs_to_payment_account_from_the_same_customer
                tax_id_belongs_to_another_payment_account:
                  value:
                    message: >-
                      Tax id belongs to a payment account from a different
                      customer
                    code: tax_id_belongs_to_another_payment_account
                payment_account_without_address:
                  value:
                    message: payment account without address
                    code: payment_account_without_address
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role payment_accounts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `customer_not_found`: no customer has the `customerId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - customer_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
  /v1/payment-accounts/{id}:
    put:
      summary: Update payment account
      tags:
        - Payment Accounts
      description: >-
        Replaces the company or person who pays the invoices of a payment
        account, archived or not, with the `legalEntity` of the body, so send
        each field to keep: a trade name, a phone, an address or e-mails that
        the body leaves out become empty. When the body gives e-mails, Aira
        tries again each blocked invoice delivery of an invoice that bills the
        payment account, if the delivery can now go out.


        Requires the role `payment_accounts:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                customerId:
                  description: >-
                    The unique identifier of the customer that owns the payment
                    account.
                  type: string
                  format: uuid
                legalEntity:
                  type: object
                  description: >-
                    The company or person who pays the invoices of the payment
                    account: its names, its tax id, its phone, its address and
                    its invoice recipients.
                  properties:
                    tradeName:
                      type: string
                      nullable: true
                      description: >-
                        The trade name (nome fantasia) of the legal entity, or
                        null when it has none.
                      example: Padaria Central
                    businessName:
                      type: string
                      description: >-
                        The registered business name (razão social) of the legal
                        entity.
                      example: Padaria Central Ltda
                    emails:
                      type: array
                      items:
                        type: string
                        format: email
                      default: []
                      description: >-
                        The e-mails of the legal entity. When the legal entity
                        belongs to a payment account, its e-mails are the
                        invoice recipients of that account: they receive the
                        invoices billed to it.
                    taxId:
                      type: string
                      pattern: ^(^\d{14}$|^\d{11}$)$
                      description: >-
                        The tax id of the legal entity, digits only: the 14
                        digits of a CNPJ or the 11 digits of a CPF.
                      example: '01234567000195'
                    taxIdType:
                      type: string
                      enum:
                        - cnpj
                        - cpf
                      description: >-
                        The kind of tax id in `taxId`: `cnpj` for a company or
                        `cpf` for a person.
                    zipCode:
                      type: string
                      pattern: ^[0-9]{8}$
                      nullable: true
                      description: >-
                        The postal code (CEP) of the address of the legal
                        entity, as 8 digits with no mask, or null when it has
                        none.
                      example: '01310100'
                    street:
                      type: string
                      nullable: true
                      description: >-
                        The street of the address of the legal entity, or null
                        when it has none.
                      example: Avenida Paulista
                    number:
                      type: string
                      nullable: true
                      description: >-
                        The street number of the address of the legal entity, or
                        null when it has none.
                      example: '1000'
                    neighborhood:
                      type: string
                      nullable: true
                      description: >-
                        The neighborhood (bairro) of the address of the legal
                        entity, or null when it has none.
                      example: Bela Vista
                    city:
                      type: string
                      nullable: true
                      description: >-
                        The city of the address of the legal entity, or null
                        when it has none.
                      example: São Paulo
                    state:
                      type:
                        - 'null'
                        - string
                      enum:
                        - AC
                        - AL
                        - AP
                        - AM
                        - BA
                        - CE
                        - DF
                        - ES
                        - GO
                        - MA
                        - MT
                        - MS
                        - MG
                        - PA
                        - PB
                        - PR
                        - PE
                        - PI
                        - RJ
                        - RN
                        - RS
                        - RO
                        - RR
                        - SC
                        - SP
                        - SE
                        - TO
                        - null
                      description: >-
                        The state of the address of the legal entity, as its
                        two-letter code, or null when it has none.
                    country:
                      type:
                        - 'null'
                        - string
                      enum:
                        - Brasil
                        - null
                      description: >-
                        The country of the address of the legal entity, or null
                        when it has none.
                    complement:
                      type: string
                      nullable: true
                      description: >-
                        The complement of the address of the legal entity, such
                        as a suite or a floor, or null when it has none.
                      example: Sala 12
                    customFields:
                      type: object
                      description: >-
                        Custom fields that can be associated with the entity.
                        The fields must be previously created in the system
                        before they can be used.
                      additionalProperties:
                        anyOf:
                          - type: string
                          - type: array
                            items:
                              type: string
                      default: {}
                      example:
                        customField1: value1
                        customField2:
                          - value2
                          - value3
                    phone:
                      type: string
                      pattern: ^\d{10,11}$
                      nullable: true
                      description: >-
                        Phone of the payment account: the 10 or 11 digits of a
                        Brazilian landline or mobile number with its area code,
                        with no mask and no country code. Aira rejects a number
                        that does not exist in Brazil, such as one with an area
                        code that does not exist. Null when absent.
                      errorMessage:
                        pattern: >-
                          must hold only the 10 or 11 digits of a Brazilian
                          number with its area code, as in 11987654321
                      example: '11987654321'
                  required:
                    - businessName
                    - taxId
                    - taxIdType
                    - customFields
                  additionalProperties: false
              required:
                - customerId
                - legalEntity
              additionalProperties: false
        required: true
        description: >-
          The customer that the payment account belongs to, and the company or
          person who pays its invoices in place of the current one.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the payment account in our system.
        - schema:
            type: boolean
            default: false
          in: header
          name: override-tax-id-uniqueness
          required: false
          description: When true, accepts a tax ID that another payment account holds.
      x-public-api: true
      x-errors:
        - status: 400
          code: cannot_update_payment_accounts_of_other_customers
          when: >-
            the payment account belongs to a customer other than the one of
            `customerId`
        - status: 400
          code: invalid_tax_id
          when: the `taxId` is not a valid CNPJ or CPF for its `taxIdType`
        - status: 400
          code: invalid_phone
          when: >-
            the `phone` is not a valid Brazilian number, such as one with an
            area code that does not exist
        - status: 400
          code: tax_id_belongs_to_payment_account_from_the_same_customer
          when: >-
            another payment account of the customer that is not archived holds
            the `taxId`, and the `override-tax-id-uniqueness` header is not true
        - status: 400
          code: tax_id_belongs_to_another_payment_account
          when: >-
            a payment account of another customer holds the `taxId`, with
            neither that payment account nor that customer archived, and the
            `override-tax-id-uniqueness` header is not true
        - status: 400
          code: payment_account_without_address
          when: >-
            the `legalEntity` has some but not all of `zipCode`, `number`,
            `street`, `neighborhood`, `city`, `state` and `country`, or has none
            of them while the integration with Celcash is on
        - status: 404
          code: customer_not_found
          when: no customer has the `customerId`
        - status: 404
          code: payment_account_not_found
          when: no payment account has the `id`
      x-required-roles: *ref_22
      responses:
        '200':
          description: >-
            A payment account, the record of who pays a customer's invoices: a
            name, a tax id, an optional phone and the e-mails that receive the
            invoices. A customer can have several, with one as the default.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: >-
                      The unique identifier of the payment account in our
                      system.
                    type: string
                    format: uuid
                  customerId:
                    description: >-
                      The unique identifier of the customer that owns the
                      payment account.
                    type: string
                    format: uuid
                  archivedAt:
                    description: Archive timestamp for payment accounts that were archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                  isDefault:
                    description: >-
                      Whether the payment account is the default payment account
                      of its customer.
                    type: boolean
                  legalEntity:
                    type: object
                    description: >-
                      The company or person who pays the invoices of the payment
                      account: its names, its tax id, its phone, its address and
                      its invoice recipients.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the legal entity.
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          The trade name (nome fantasia) of the legal entity, or
                          null when it has none.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          The registered business name (razão social) of the
                          legal entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        default: []
                        description: >-
                          The e-mails of the legal entity. When the legal entity
                          belongs to a payment account, its e-mails are the
                          invoice recipients of that account: they receive the
                          invoices billed to it.
                      taxId:
                        type: string
                        pattern: ^(^\d{14}$|^\d{11}$)$
                        description: >-
                          The tax id of the legal entity, digits only: the 14
                          digits of a CNPJ or the 11 digits of a CPF.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax id in `taxId`: `cnpj` for a company or
                          `cpf` for a person.
                      zipCode:
                        type: string
                        pattern: ^[0-9]{8}$
                        nullable: true
                        description: >-
                          The postal code (CEP) of the address of the legal
                          entity, as 8 digits with no mask, or null when it has
                          none.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: >-
                          The street of the address of the legal entity, or null
                          when it has none.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          The street number of the address of the legal entity,
                          or null when it has none.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          The neighborhood (bairro) of the address of the legal
                          entity, or null when it has none.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: >-
                          The city of the address of the legal entity, or null
                          when it has none.
                        example: São Paulo
                      state:
                        type:
                          - 'null'
                          - string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        description: >-
                          The state of the address of the legal entity, as its
                          two-letter code, or null when it has none.
                      country:
                        type:
                          - 'null'
                          - string
                        enum:
                          - Brasil
                          - null
                        description: >-
                          The country of the address of the legal entity, or
                          null when it has none.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          The complement of the address of the legal entity,
                          such as a suite or a floor, or null when it has none.
                        example: Sala 12
                      customFields:
                        type: object
                        description: >-
                          Custom fields that can be associated with the entity.
                          The fields must be previously created in the system
                          before they can be used.
                        additionalProperties:
                          anyOf:
                            - type: string
                            - type: array
                              items:
                                type: string
                        default: {}
                        example:
                          customField1: value1
                          customField2:
                            - value2
                            - value3
                      phone:
                        type: string
                        pattern: ^\d{10,11}$
                        nullable: true
                        description: >-
                          Phone of the payment account: the 10 or 11 digits of a
                          Brazilian landline or mobile number with its area
                          code, with no mask and no country code. Aira rejects a
                          number that does not exist in Brazil, such as one with
                          an area code that does not exist. Null when absent.
                        errorMessage:
                          pattern: >-
                            must hold only the 10 or 11 digits of a Brazilian
                            number with its area code, as in 11987654321
                        example: '11987654321'
                    required:
                      - id
                      - businessName
                      - taxId
                      - taxIdType
                      - customFields
                    additionalProperties: false
                required:
                  - id
                  - customerId
                  - archivedAt
                  - isDefault
                  - legalEntity
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `cannot_update_payment_accounts_of_other_customers`: the payment
            account belongs to a customer other than the one of `customerId`.

            - `invalid_tax_id`: the `taxId` is not a valid CNPJ or CPF for its
            `taxIdType`.

            - `invalid_phone`: the `phone` is not a valid Brazilian number, such
            as one with an area code that does not exist.

            - `tax_id_belongs_to_payment_account_from_the_same_customer`:
            another payment account of the customer that is not archived holds
            the `taxId`, and the `override-tax-id-uniqueness` header is not
            true.

            - `tax_id_belongs_to_another_payment_account`: a payment account of
            another customer holds the `taxId`, with neither that payment
            account nor that customer archived, and the
            `override-tax-id-uniqueness` header is not true.

            - `payment_account_without_address`: the `legalEntity` has some but
            not all of `zipCode`, `number`, `street`, `neighborhood`, `city`,
            `state` and `country`, or has none of them while the integration
            with Celcash is on.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - cannot_update_payment_accounts_of_other_customers
                      - invalid_tax_id
                      - invalid_phone
                      - tax_id_belongs_to_payment_account_from_the_same_customer
                      - tax_id_belongs_to_another_payment_account
                      - payment_account_without_address
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''customerId'' is required'
                    code: json_schema_validation_error
                cannot_update_payment_accounts_of_other_customers:
                  value:
                    message: cannot update payment accounts of other customers
                    code: cannot_update_payment_accounts_of_other_customers
                invalid_tax_id:
                  value:
                    message: Invalid tax id
                    code: invalid_tax_id
                invalid_phone:
                  value:
                    message: >-
                      Invalid phone: send the 10 or 11 digits of a Brazilian
                      number with its area code, as in 11987654321
                    code: invalid_phone
                tax_id_belongs_to_payment_account_from_the_same_customer:
                  value:
                    message: Tax id belongs to a payment account from the same customer
                    code: tax_id_belongs_to_payment_account_from_the_same_customer
                tax_id_belongs_to_another_payment_account:
                  value:
                    message: >-
                      Tax id belongs to a payment account from a different
                      customer
                    code: tax_id_belongs_to_another_payment_account
                payment_account_without_address:
                  value:
                    message: payment account without address
                    code: payment_account_without_address
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role payment_accounts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `customer_not_found`: no customer has the `customerId`.
            - `payment_account_not_found`: no payment account has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - customer_not_found
                      - payment_account_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
                payment_account_not_found:
                  value:
                    message: payment account not found
                    code: payment_account_not_found
  /v1/payment-accounts/{id}/archive:
    post:
      summary: Archive payment account
      tags:
        - Payment Accounts
      description: >-
        Archives a payment account, so that `GET
        /v1/payment-accounts/by-customer` lists it only when `includeArchived`
        is true, and no contract allocation can name it. When the payment
        account is the default one of its customer, the oldest payment account
        of the customer that is not archived becomes the default.


        Requires the role `payment_accounts:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the payment account in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: payment_account_is_already_archived
          when: the payment account is already archived
        - status: 400
          code: payment_account_being_used_by_contracts
          when: >-
            the payment account is in the contract allocation of a draft or
            active contract
        - status: 404
          code: payment_account_not_found
          when: no payment account has the `id`
      x-required-roles: *ref_22
      responses:
        '200':
          description: >-
            A payment account, the record of who pays a customer's invoices: a
            name, a tax id, an optional phone and the e-mails that receive the
            invoices. A customer can have several, with one as the default.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: >-
                      The unique identifier of the payment account in our
                      system.
                    type: string
                    format: uuid
                  customerId:
                    description: >-
                      The unique identifier of the customer that owns the
                      payment account.
                    type: string
                    format: uuid
                  archivedAt:
                    description: Archive timestamp for payment accounts that were archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                  isDefault:
                    description: >-
                      Whether the payment account is the default payment account
                      of its customer.
                    type: boolean
                  legalEntity:
                    type: object
                    description: >-
                      The company or person who pays the invoices of the payment
                      account: its names, its tax id, its phone, its address and
                      its invoice recipients.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the legal entity.
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          The trade name (nome fantasia) of the legal entity, or
                          null when it has none.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          The registered business name (razão social) of the
                          legal entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        default: []
                        description: >-
                          The e-mails of the legal entity. When the legal entity
                          belongs to a payment account, its e-mails are the
                          invoice recipients of that account: they receive the
                          invoices billed to it.
                      taxId:
                        type: string
                        pattern: ^(^\d{14}$|^\d{11}$)$
                        description: >-
                          The tax id of the legal entity, digits only: the 14
                          digits of a CNPJ or the 11 digits of a CPF.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax id in `taxId`: `cnpj` for a company or
                          `cpf` for a person.
                      zipCode:
                        type: string
                        pattern: ^[0-9]{8}$
                        nullable: true
                        description: >-
                          The postal code (CEP) of the address of the legal
                          entity, as 8 digits with no mask, or null when it has
                          none.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: >-
                          The street of the address of the legal entity, or null
                          when it has none.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          The street number of the address of the legal entity,
                          or null when it has none.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          The neighborhood (bairro) of the address of the legal
                          entity, or null when it has none.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: >-
                          The city of the address of the legal entity, or null
                          when it has none.
                        example: São Paulo
                      state:
                        type:
                          - 'null'
                          - string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        description: >-
                          The state of the address of the legal entity, as its
                          two-letter code, or null when it has none.
                      country:
                        type:
                          - 'null'
                          - string
                        enum:
                          - Brasil
                          - null
                        description: >-
                          The country of the address of the legal entity, or
                          null when it has none.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          The complement of the address of the legal entity,
                          such as a suite or a floor, or null when it has none.
                        example: Sala 12
                      customFields:
                        type: object
                        description: >-
                          Custom fields that can be associated with the entity.
                          The fields must be previously created in the system
                          before they can be used.
                        additionalProperties:
                          anyOf:
                            - type: string
                            - type: array
                              items:
                                type: string
                        default: {}
                        example:
                          customField1: value1
                          customField2:
                            - value2
                            - value3
                      phone:
                        type: string
                        pattern: ^\d{10,11}$
                        nullable: true
                        description: >-
                          Phone of the payment account: the 10 or 11 digits of a
                          Brazilian landline or mobile number with its area
                          code, with no mask and no country code. Aira rejects a
                          number that does not exist in Brazil, such as one with
                          an area code that does not exist. Null when absent.
                        errorMessage:
                          pattern: >-
                            must hold only the 10 or 11 digits of a Brazilian
                            number with its area code, as in 11987654321
                        example: '11987654321'
                    required:
                      - id
                      - businessName
                      - taxId
                      - taxIdType
                      - customFields
                    additionalProperties: false
                required:
                  - id
                  - customerId
                  - archivedAt
                  - isDefault
                  - legalEntity
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `payment_account_is_already_archived`: the payment account is
            already archived.

            - `payment_account_being_used_by_contracts`: the payment account is
            in the contract allocation of a draft or active contract.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - payment_account_is_already_archived
                      - payment_account_being_used_by_contracts
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                payment_account_is_already_archived:
                  value:
                    message: payment account is already archived
                    code: payment_account_is_already_archived
                payment_account_being_used_by_contracts:
                  value:
                    message: payment account being used by contracts
                    code: payment_account_being_used_by_contracts
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role payment_accounts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `payment_account_not_found`: no payment account has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - payment_account_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                payment_account_not_found:
                  value:
                    message: payment account not found
                    code: payment_account_not_found
  /v1/payment-accounts/{id}/unarchive:
    post:
      summary: Unarchive payment account
      tags:
        - Payment Accounts
      description: >-
        Unarchives a payment account, so that `GET
        /v1/payment-accounts/by-customer` lists it again without
        `includeArchived`, and a contract allocation can name it again. The
        payment account does not become the default one of its customer, even
        when the customer has none.


        Requires the role `payment_accounts:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the payment account in our system.
        - schema:
            type: boolean
            default: false
          in: header
          name: override-tax-id-uniqueness
          required: false
          description: When true, accepts a tax ID that another payment account holds.
      x-public-api: true
      x-errors:
        - status: 400
          code: payment_account_is_not_archived
          when: the payment account is not archived
        - status: 400
          code: invalid_tax_id
          when: >-
            the tax id of the payment account is not a valid CNPJ or CPF for its
            tax id type
        - status: 400
          code: tax_id_belongs_to_payment_account_from_the_same_customer
          when: >-
            another payment account of the customer that is not archived holds
            the tax id of the payment account, and the
            `override-tax-id-uniqueness` header is not true
        - status: 400
          code: tax_id_belongs_to_another_payment_account
          when: >-
            a payment account of another customer holds the tax id of the
            payment account, with neither that payment account nor that customer
            archived, and the `override-tax-id-uniqueness` header is not true
        - status: 404
          code: payment_account_not_found
          when: no payment account has the `id`
      x-required-roles: *ref_22
      responses:
        '200':
          description: >-
            A payment account, the record of who pays a customer's invoices: a
            name, a tax id, an optional phone and the e-mails that receive the
            invoices. A customer can have several, with one as the default.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: >-
                      The unique identifier of the payment account in our
                      system.
                    type: string
                    format: uuid
                  customerId:
                    description: >-
                      The unique identifier of the customer that owns the
                      payment account.
                    type: string
                    format: uuid
                  archivedAt:
                    description: Archive timestamp for payment accounts that were archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                  isDefault:
                    description: >-
                      Whether the payment account is the default payment account
                      of its customer.
                    type: boolean
                  legalEntity:
                    type: object
                    description: >-
                      The company or person who pays the invoices of the payment
                      account: its names, its tax id, its phone, its address and
                      its invoice recipients.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the legal entity.
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          The trade name (nome fantasia) of the legal entity, or
                          null when it has none.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          The registered business name (razão social) of the
                          legal entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        default: []
                        description: >-
                          The e-mails of the legal entity. When the legal entity
                          belongs to a payment account, its e-mails are the
                          invoice recipients of that account: they receive the
                          invoices billed to it.
                      taxId:
                        type: string
                        pattern: ^(^\d{14}$|^\d{11}$)$
                        description: >-
                          The tax id of the legal entity, digits only: the 14
                          digits of a CNPJ or the 11 digits of a CPF.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax id in `taxId`: `cnpj` for a company or
                          `cpf` for a person.
                      zipCode:
                        type: string
                        pattern: ^[0-9]{8}$
                        nullable: true
                        description: >-
                          The postal code (CEP) of the address of the legal
                          entity, as 8 digits with no mask, or null when it has
                          none.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: >-
                          The street of the address of the legal entity, or null
                          when it has none.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          The street number of the address of the legal entity,
                          or null when it has none.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          The neighborhood (bairro) of the address of the legal
                          entity, or null when it has none.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: >-
                          The city of the address of the legal entity, or null
                          when it has none.
                        example: São Paulo
                      state:
                        type:
                          - 'null'
                          - string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        description: >-
                          The state of the address of the legal entity, as its
                          two-letter code, or null when it has none.
                      country:
                        type:
                          - 'null'
                          - string
                        enum:
                          - Brasil
                          - null
                        description: >-
                          The country of the address of the legal entity, or
                          null when it has none.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          The complement of the address of the legal entity,
                          such as a suite or a floor, or null when it has none.
                        example: Sala 12
                      customFields:
                        type: object
                        description: >-
                          Custom fields that can be associated with the entity.
                          The fields must be previously created in the system
                          before they can be used.
                        additionalProperties:
                          anyOf:
                            - type: string
                            - type: array
                              items:
                                type: string
                        default: {}
                        example:
                          customField1: value1
                          customField2:
                            - value2
                            - value3
                      phone:
                        type: string
                        pattern: ^\d{10,11}$
                        nullable: true
                        description: >-
                          Phone of the payment account: the 10 or 11 digits of a
                          Brazilian landline or mobile number with its area
                          code, with no mask and no country code. Aira rejects a
                          number that does not exist in Brazil, such as one with
                          an area code that does not exist. Null when absent.
                        errorMessage:
                          pattern: >-
                            must hold only the 10 or 11 digits of a Brazilian
                            number with its area code, as in 11987654321
                        example: '11987654321'
                    required:
                      - id
                      - businessName
                      - taxId
                      - taxIdType
                      - customFields
                    additionalProperties: false
                required:
                  - id
                  - customerId
                  - archivedAt
                  - isDefault
                  - legalEntity
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `payment_account_is_not_archived`: the payment account is not
            archived.

            - `invalid_tax_id`: the tax id of the payment account is not a valid
            CNPJ or CPF for its tax id type.

            - `tax_id_belongs_to_payment_account_from_the_same_customer`:
            another payment account of the customer that is not archived holds
            the tax id of the payment account, and the
            `override-tax-id-uniqueness` header is not true.

            - `tax_id_belongs_to_another_payment_account`: a payment account of
            another customer holds the tax id of the payment account, with
            neither that payment account nor that customer archived, and the
            `override-tax-id-uniqueness` header is not true.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - payment_account_is_not_archived
                      - invalid_tax_id
                      - tax_id_belongs_to_payment_account_from_the_same_customer
                      - tax_id_belongs_to_another_payment_account
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                payment_account_is_not_archived:
                  value:
                    message: payment account is not archived
                    code: payment_account_is_not_archived
                invalid_tax_id:
                  value:
                    message: Invalid tax id
                    code: invalid_tax_id
                tax_id_belongs_to_payment_account_from_the_same_customer:
                  value:
                    message: Tax id belongs to a payment account from the same customer
                    code: tax_id_belongs_to_payment_account_from_the_same_customer
                tax_id_belongs_to_another_payment_account:
                  value:
                    message: >-
                      Tax id belongs to a payment account from a different
                      customer
                    code: tax_id_belongs_to_another_payment_account
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role payment_accounts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `payment_account_not_found`: no payment account has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - payment_account_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                payment_account_not_found:
                  value:
                    message: payment account not found
                    code: payment_account_not_found
  /v1/payment-accounts/{id}/set-default:
    post:
      summary: Set default payment account
      tags:
        - Payment Accounts
      description: >-
        Makes a payment account the default one of its customer, in place of the
        previous default, so that `isDefault` is true only on it among the
        payment accounts of the customer.


        Requires the role `payment_accounts:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the payment account in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: payment_account_not_found
          when: no payment account that is not archived has the `id`
      x-required-roles: *ref_22
      responses:
        '200':
          description: >-
            A payment account, the record of who pays a customer's invoices: a
            name, a tax id, an optional phone and the e-mails that receive the
            invoices. A customer can have several, with one as the default.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: >-
                      The unique identifier of the payment account in our
                      system.
                    type: string
                    format: uuid
                  customerId:
                    description: >-
                      The unique identifier of the customer that owns the
                      payment account.
                    type: string
                    format: uuid
                  archivedAt:
                    description: Archive timestamp for payment accounts that were archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                  isDefault:
                    description: >-
                      Whether the payment account is the default payment account
                      of its customer.
                    type: boolean
                  legalEntity:
                    type: object
                    description: >-
                      The company or person who pays the invoices of the payment
                      account: its names, its tax id, its phone, its address and
                      its invoice recipients.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the legal entity.
                      tradeName:
                        type: string
                        nullable: true
                        description: >-
                          The trade name (nome fantasia) of the legal entity, or
                          null when it has none.
                        example: Padaria Central
                      businessName:
                        type: string
                        description: >-
                          The registered business name (razão social) of the
                          legal entity.
                        example: Padaria Central Ltda
                      emails:
                        type: array
                        items:
                          type: string
                          format: email
                        default: []
                        description: >-
                          The e-mails of the legal entity. When the legal entity
                          belongs to a payment account, its e-mails are the
                          invoice recipients of that account: they receive the
                          invoices billed to it.
                      taxId:
                        type: string
                        pattern: ^(^\d{14}$|^\d{11}$)$
                        description: >-
                          The tax id of the legal entity, digits only: the 14
                          digits of a CNPJ or the 11 digits of a CPF.
                        example: '01234567000195'
                      taxIdType:
                        type: string
                        enum:
                          - cnpj
                          - cpf
                        description: >-
                          The kind of tax id in `taxId`: `cnpj` for a company or
                          `cpf` for a person.
                      zipCode:
                        type: string
                        pattern: ^[0-9]{8}$
                        nullable: true
                        description: >-
                          The postal code (CEP) of the address of the legal
                          entity, as 8 digits with no mask, or null when it has
                          none.
                        example: '01310100'
                      street:
                        type: string
                        nullable: true
                        description: >-
                          The street of the address of the legal entity, or null
                          when it has none.
                        example: Avenida Paulista
                      number:
                        type: string
                        nullable: true
                        description: >-
                          The street number of the address of the legal entity,
                          or null when it has none.
                        example: '1000'
                      neighborhood:
                        type: string
                        nullable: true
                        description: >-
                          The neighborhood (bairro) of the address of the legal
                          entity, or null when it has none.
                        example: Bela Vista
                      city:
                        type: string
                        nullable: true
                        description: >-
                          The city of the address of the legal entity, or null
                          when it has none.
                        example: São Paulo
                      state:
                        type:
                          - 'null'
                          - string
                        enum:
                          - AC
                          - AL
                          - AP
                          - AM
                          - BA
                          - CE
                          - DF
                          - ES
                          - GO
                          - MA
                          - MT
                          - MS
                          - MG
                          - PA
                          - PB
                          - PR
                          - PE
                          - PI
                          - RJ
                          - RN
                          - RS
                          - RO
                          - RR
                          - SC
                          - SP
                          - SE
                          - TO
                          - null
                        description: >-
                          The state of the address of the legal entity, as its
                          two-letter code, or null when it has none.
                      country:
                        type:
                          - 'null'
                          - string
                        enum:
                          - Brasil
                          - null
                        description: >-
                          The country of the address of the legal entity, or
                          null when it has none.
                      complement:
                        type: string
                        nullable: true
                        description: >-
                          The complement of the address of the legal entity,
                          such as a suite or a floor, or null when it has none.
                        example: Sala 12
                      customFields:
                        type: object
                        description: >-
                          Custom fields that can be associated with the entity.
                          The fields must be previously created in the system
                          before they can be used.
                        additionalProperties:
                          anyOf:
                            - type: string
                            - type: array
                              items:
                                type: string
                        default: {}
                        example:
                          customField1: value1
                          customField2:
                            - value2
                            - value3
                      phone:
                        type: string
                        pattern: ^\d{10,11}$
                        nullable: true
                        description: >-
                          Phone of the payment account: the 10 or 11 digits of a
                          Brazilian landline or mobile number with its area
                          code, with no mask and no country code. Aira rejects a
                          number that does not exist in Brazil, such as one with
                          an area code that does not exist. Null when absent.
                        errorMessage:
                          pattern: >-
                            must hold only the 10 or 11 digits of a Brazilian
                            number with its area code, as in 11987654321
                        example: '11987654321'
                    required:
                      - id
                      - businessName
                      - taxId
                      - taxIdType
                      - customFields
                    additionalProperties: false
                required:
                  - id
                  - customerId
                  - archivedAt
                  - isDefault
                  - legalEntity
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role payment_accounts:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `payment_account_not_found`: no payment account that is not
            archived has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - payment_account_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                payment_account_not_found:
                  value:
                    message: payment account not found
                    code: payment_account_not_found
  /v1/payment-accounts/by-customer:
    get:
      summary: List customer payment accounts
      tags:
        - Payment Accounts
      description: >-
        Lists the payment accounts of a customer, newest first by creation time.
        The list adds the payment accounts of the subsidiaries of the customer
        when `includeSubsidiaries` is true, and the archived payment accounts
        and those of archived subsidiaries when `includeArchived` is true.


        Requires the role `payment_accounts:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: query
          name: customerId
          required: true
          description: The unique identifier of the customer.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeSubsidiaries
          required: false
          description: >-
            Whether the list adds the payment accounts of the subsidiaries of
            the customer.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeArchived
          required: false
          description: >-
            Whether the list adds the archived payment accounts and the payment
            accounts of archived subsidiaries.
      x-public-api: true
      x-errors:
        - status: 404
          code: customer_not_found
          when: no customer has the `customerId`
        - *ref_1
        - *ref_2
      x-required-roles:
        - payment_accounts:read
      responses:
        '200':
          description: >-
            The payment accounts that match the filters, newest first by
            creation time.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A payment account, the record of who pays a customer's
                        invoices: a name, a tax id, an optional phone and the
                        e-mails that receive the invoices. A customer can have
                        several, with one as the default.
                      properties:
                        id:
                          description: >-
                            The unique identifier of the payment account in our
                            system.
                          type: string
                          format: uuid
                        customerId:
                          description: >-
                            The unique identifier of the customer that owns the
                            payment account.
                          type: string
                          format: uuid
                        archivedAt:
                          description: >-
                            Archive timestamp for payment accounts that were
                            archived.
                          type:
                            - 'null'
                            - string
                          format: date-time
                        isDefault:
                          description: >-
                            Whether the payment account is the default payment
                            account of its customer.
                          type: boolean
                        legalEntity:
                          type: object
                          description: >-
                            The company or person who pays the invoices of the
                            payment account: its names, its tax id, its phone,
                            its address and its invoice recipients.
                          properties:
                            id:
                              type: string
                              format: uuid
                              description: The unique identifier of the legal entity.
                            tradeName:
                              type: string
                              nullable: true
                              description: >-
                                The trade name (nome fantasia) of the legal
                                entity, or null when it has none.
                              example: Padaria Central
                            businessName:
                              type: string
                              description: >-
                                The registered business name (razão social) of
                                the legal entity.
                              example: Padaria Central Ltda
                            emails:
                              type: array
                              items:
                                type: string
                                format: email
                              default: []
                              description: >-
                                The e-mails of the legal entity. When the legal
                                entity belongs to a payment account, its e-mails
                                are the invoice recipients of that account: they
                                receive the invoices billed to it.
                            taxId:
                              type: string
                              pattern: ^(^\d{14}$|^\d{11}$)$
                              description: >-
                                The tax id of the legal entity, digits only: the
                                14 digits of a CNPJ or the 11 digits of a CPF.
                              example: '01234567000195'
                            taxIdType:
                              type: string
                              enum:
                                - cnpj
                                - cpf
                              description: >-
                                The kind of tax id in `taxId`: `cnpj` for a
                                company or `cpf` for a person.
                            zipCode:
                              type: string
                              pattern: ^[0-9]{8}$
                              nullable: true
                              description: >-
                                The postal code (CEP) of the address of the
                                legal entity, as 8 digits with no mask, or null
                                when it has none.
                              example: '01310100'
                            street:
                              type: string
                              nullable: true
                              description: >-
                                The street of the address of the legal entity,
                                or null when it has none.
                              example: Avenida Paulista
                            number:
                              type: string
                              nullable: true
                              description: >-
                                The street number of the address of the legal
                                entity, or null when it has none.
                              example: '1000'
                            neighborhood:
                              type: string
                              nullable: true
                              description: >-
                                The neighborhood (bairro) of the address of the
                                legal entity, or null when it has none.
                              example: Bela Vista
                            city:
                              type: string
                              nullable: true
                              description: >-
                                The city of the address of the legal entity, or
                                null when it has none.
                              example: São Paulo
                            state:
                              type:
                                - 'null'
                                - string
                              enum:
                                - AC
                                - AL
                                - AP
                                - AM
                                - BA
                                - CE
                                - DF
                                - ES
                                - GO
                                - MA
                                - MT
                                - MS
                                - MG
                                - PA
                                - PB
                                - PR
                                - PE
                                - PI
                                - RJ
                                - RN
                                - RS
                                - RO
                                - RR
                                - SC
                                - SP
                                - SE
                                - TO
                                - null
                              description: >-
                                The state of the address of the legal entity, as
                                its two-letter code, or null when it has none.
                            country:
                              type:
                                - 'null'
                                - string
                              enum:
                                - Brasil
                                - null
                              description: >-
                                The country of the address of the legal entity,
                                or null when it has none.
                            complement:
                              type: string
                              nullable: true
                              description: >-
                                The complement of the address of the legal
                                entity, such as a suite or a floor, or null when
                                it has none.
                              example: Sala 12
                            customFields:
                              type: object
                              description: >-
                                Custom fields that can be associated with the
                                entity. The fields must be previously created in
                                the system before they can be used.
                              additionalProperties:
                                anyOf:
                                  - type: string
                                  - type: array
                                    items:
                                      type: string
                              default: {}
                              example:
                                customField1: value1
                                customField2:
                                  - value2
                                  - value3
                            phone:
                              type: string
                              pattern: ^\d{10,11}$
                              nullable: true
                              description: >-
                                Phone of the payment account: the 10 or 11
                                digits of a Brazilian landline or mobile number
                                with its area code, with no mask and no country
                                code. Aira rejects a number that does not exist
                                in Brazil, such as one with an area code that
                                does not exist. Null when absent.
                              errorMessage:
                                pattern: >-
                                  must hold only the 10 or 11 digits of a
                                  Brazilian number with its area code, as in
                                  11987654321
                              example: '11987654321'
                          required:
                            - id
                            - businessName
                            - taxId
                            - taxIdType
                            - customFields
                          additionalProperties: false
                      required:
                        - id
                        - customerId
                        - archivedAt
                        - isDefault
                        - legalEntity
                      additionalProperties: false
                    description: A list of items.
                required:
                  - items
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''customerId'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role payment_accounts:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `customer_not_found`: no customer has the `customerId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - customer_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                customer_not_found:
                  value:
                    message: customer not found
                    code: customer_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/products/:
    post:
      summary: Create product
      tags:
        - Products
      description: |-
        Creates a product with the values of its custom fields.

        Requires the role `products:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  description: The name of the product.
                  type: string
                  minLength: 1
                  example: Platform subscription
                customFields:
                  type: object
                  description: >-
                    The values of the custom fields of products on the product,
                    keyed by the key of each custom field.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
              required:
                - name
                - customFields
              additionalProperties: false
        required: true
        description: The name of the product and the values of its custom fields.
      x-public-api: true
      x-errors:
        - status: 400
          code: name_belongs_to_another_product
          when: >-
            another product, archived or not, has the `name`, ignoring case and
            accents
        - status: 400
          code: invalid_custom_fields
          when: >-
            the `customFields` leave out a required custom field of products,
            name a key that no custom field of products has, or give a custom
            field a value that it does not take
      x-required-roles: &ref_23
        - products:write
      responses:
        '201':
          description: >-
            A product: a good or service that you sell. Each plan, and each of
            its charges, belongs to one product.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the product in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the product.
                    type: string
                    minLength: 1
                    example: Platform subscription
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of products on the
                      product, keyed by the key of each custom field.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  archivedAt:
                    description: >-
                      The timestamp when the product was archived, or null if
                      not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - customFields
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `name_belongs_to_another_product`: another product, archived or
            not, has the `name`, ignoring case and accents.

            - `invalid_custom_fields`: the `customFields` leave out a required
            custom field of products, name a key that no custom field of
            products has, or give a custom field a value that it does not take.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - name_belongs_to_another_product
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                name_belongs_to_another_product:
                  value:
                    message: name belongs to another product
                    code: name_belongs_to_another_product
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role products:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
    get:
      summary: List products
      tags:
        - Products
      description: >-
        Lists the products, newest first by creation time. Archived products are
        listed only when `includeArchived` is true.


        Requires the role `products:read`.
      parameters:
        - schema:
            type: string
          example: subscription
          in: query
          name: search
          required: false
          description: Free-text search over the product name, ignoring case and accents.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeArchived
          required: false
          description: Whether archived products should be returned.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles:
        - products:read
      responses:
        '200':
          description: The products that match the filters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A product: a good or service that you sell. Each plan,
                        and each of its charges, belongs to one product.
                      properties:
                        id:
                          description: The unique identifier of the product in our system.
                          type: string
                          format: uuid
                        name:
                          description: The name of the product.
                          type: string
                          minLength: 1
                          example: Platform subscription
                        customFields:
                          type: object
                          description: >-
                            The values of the custom fields of products on the
                            product, keyed by the key of each custom field.
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          default: {}
                          example:
                            customField1: value1
                            customField2:
                              - value2
                              - value3
                        archivedAt:
                          description: >-
                            The timestamp when the product was archived, or null
                            if not archived.
                          type:
                            - 'null'
                            - string
                          format: date-time
                      required:
                        - id
                        - name
                        - customFields
                        - archivedAt
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''search'' must be string'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role products:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/products/{id}:
    put:
      summary: Update product
      tags:
        - Products
      description: >-
        Replaces the name and the custom fields of a product. A custom field
        that `customFields` leaves out loses its value.


        Requires the role `products:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  description: The name of the product.
                  type: string
                  minLength: 1
                  example: Platform subscription
                customFields:
                  type: object
                  description: >-
                    The values of the custom fields of products on the product,
                    keyed by the key of each custom field.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
              required:
                - name
                - customFields
              additionalProperties: false
        required: true
        description: >-
          The name and the values of the custom fields that replace those of the
          product.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the product in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: name_belongs_to_another_product
          when: >-
            another product, archived or not, has the `name`, ignoring case and
            accents
        - status: 400
          code: invalid_custom_fields
          when: >-
            the `customFields` leave out a required custom field of products,
            name a key that no custom field of products has, or give a custom
            field a value that it does not take
        - status: 404
          code: product_not_found
          when: no product has the `id`
      x-required-roles: *ref_23
      responses:
        '200':
          description: >-
            A product: a good or service that you sell. Each plan, and each of
            its charges, belongs to one product.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the product in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the product.
                    type: string
                    minLength: 1
                    example: Platform subscription
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of products on the
                      product, keyed by the key of each custom field.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  archivedAt:
                    description: >-
                      The timestamp when the product was archived, or null if
                      not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - customFields
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `name_belongs_to_another_product`: another product, archived or
            not, has the `name`, ignoring case and accents.

            - `invalid_custom_fields`: the `customFields` leave out a required
            custom field of products, name a key that no custom field of
            products has, or give a custom field a value that it does not take.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - name_belongs_to_another_product
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                name_belongs_to_another_product:
                  value:
                    message: name belongs to another product
                    code: name_belongs_to_another_product
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role products:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `product_not_found`: no product has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - product_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                product_not_found:
                  value:
                    message: default product not found
                    code: product_not_found
    delete:
      summary: Delete product
      tags:
        - Products
      description: >-
        Deletes a product, so that `GET /v1/products` leaves it out even when
        `includeArchived` is true.


        Requires the role `products:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the product in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: product_has_active_references
          when: >-
            a plan, the contract minimum of a contract, a line item or a line
            item group of an invoice, a revenue traceability record, or an Omie
            or Senior service mapping names the product, or a recurring discount
            applies to a plan of the product, and `details.references` lists
            those references
        - status: 404
          code: product_not_found
          when: no product has the `id`
      x-required-roles: *ref_23
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `product_has_active_references`: a plan, the contract minimum of a
            contract, a line item or a line item group of an invoice, a revenue
            traceability record, or an Omie or Senior service mapping names the
            product, or a recurring discount applies to a plan of the product,
            and `details.references` lists those references.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - product_has_active_references
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                product_has_active_references:
                  value:
                    message: product has active references and cannot be archived
                    code: product_has_active_references
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role products:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `product_not_found`: no product has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - product_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                product_not_found:
                  value:
                    message: default product not found
                    code: product_not_found
  /v1/products/{id}/archive:
    post:
      summary: Archive product
      tags:
        - Products
      description: >-
        Archives a product, so that `GET /v1/products` leaves it out unless
        `includeArchived` is true.


        Requires the role `products:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the product in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: product_is_already_archived
          when: the product is already archived
        - status: 400
          code: product_has_active_references
          when: >-
            an active or draft contract bills the product through an active plan
            instance or its contract minimum, a recurring discount of an active
            or draft contract applies to a plan of the product, or an Omie or
            Senior service mapping names the product, and `details.references`
            lists those references
        - status: 404
          code: product_not_found
          when: no product has the `id`
      x-required-roles: *ref_23
      responses:
        '200':
          description: >-
            A product: a good or service that you sell. Each plan, and each of
            its charges, belongs to one product.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the product in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the product.
                    type: string
                    minLength: 1
                    example: Platform subscription
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of products on the
                      product, keyed by the key of each custom field.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  archivedAt:
                    description: >-
                      The timestamp when the product was archived, or null if
                      not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - customFields
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `product_is_already_archived`: the product is already archived.

            - `product_has_active_references`: an active or draft contract bills
            the product through an active plan instance or its contract minimum,
            a recurring discount of an active or draft contract applies to a
            plan of the product, or an Omie or Senior service mapping names the
            product, and `details.references` lists those references.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - product_is_already_archived
                      - product_has_active_references
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                product_is_already_archived:
                  value:
                    message: product is already archived
                    code: product_is_already_archived
                product_has_active_references:
                  value:
                    message: product has active references and cannot be archived
                    code: product_has_active_references
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role products:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `product_not_found`: no product has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - product_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                product_not_found:
                  value:
                    message: default product not found
                    code: product_not_found
  /v1/products/{id}/unarchive:
    post:
      summary: Unarchive product
      tags:
        - Products
      description: >-
        Unarchives a product, so that `GET /v1/products` lists it again without
        `includeArchived`.


        Requires the role `products:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the product in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: product_is_not_archived
          when: the product is not archived
        - status: 404
          code: product_not_found
          when: no product has the `id`
      x-required-roles: *ref_23
      responses:
        '200':
          description: >-
            A product: a good or service that you sell. Each plan, and each of
            its charges, belongs to one product.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the product in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the product.
                    type: string
                    minLength: 1
                    example: Platform subscription
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of products on the
                      product, keyed by the key of each custom field.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  archivedAt:
                    description: >-
                      The timestamp when the product was archived, or null if
                      not archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - customFields
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `product_is_not_archived`: the product is not archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - product_is_not_archived
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                product_is_not_archived:
                  value:
                    message: product is not archived
                    code: product_is_not_archived
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role products:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `product_not_found`: no product has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - product_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                product_not_found:
                  value:
                    message: default product not found
                    code: product_not_found
  /v1/items/:
    post:
      summary: Create item
      tags:
        - Items
      description: |-
        Creates an item with the values of its custom fields.

        Requires the role `items:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  description: The name of the item.
                  type: string
                  minLength: 1
                  example: Monthly fee
                customFields:
                  type: object
                  description: >-
                    The values of the custom fields of items on the item, keyed
                    by the key of each custom field.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
              required:
                - name
                - customFields
              additionalProperties: false
        required: true
        description: The name of the item and the values of its custom fields.
      x-public-api: true
      x-errors:
        - status: 400
          code: name_belongs_to_another_item
          when: >-
            another item, archived or not, has the `name`, ignoring case and
            accents
        - status: 400
          code: invalid_custom_fields
          when: >-
            the `customFields` leave out a required custom field of items, name
            a key that no custom field of items has, or give a custom field a
            value that it does not take
      x-required-roles: &ref_24
        - items:write
      responses:
        '201':
          description: >-
            An item: the catalog record that names what a charge bills. Each
            resource, license and plan charge points to one item.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the item in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the item.
                    type: string
                    minLength: 1
                    example: Monthly fee
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of items on the item,
                      keyed by the key of each custom field.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  archivedAt:
                    description: >-
                      The timestamp when the item was archived, or null if not
                      archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - customFields
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `name_belongs_to_another_item`: another item, archived or not, has
            the `name`, ignoring case and accents.

            - `invalid_custom_fields`: the `customFields` leave out a required
            custom field of items, name a key that no custom field of items has,
            or give a custom field a value that it does not take.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - name_belongs_to_another_item
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                name_belongs_to_another_item:
                  value:
                    message: name belongs to another item
                    code: name_belongs_to_another_item
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role items:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
    get:
      summary: List items
      tags:
        - Items
      description: >-
        Lists the items, newest first by creation time. Archived items are
        listed only when `includeArchived` is true.


        Requires the role `items:read`.
      parameters:
        - schema:
            type: string
          example: fee
          in: query
          name: search
          required: false
          description: Free-text search over the item name, ignoring case and accents.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeArchived
          required: false
          description: Whether archived items should be returned.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles:
        - items:read
      responses:
        '200':
          description: The items that match the filters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        An item: the catalog record that names what a charge
                        bills. Each resource, license and plan charge points to
                        one item.
                      properties:
                        id:
                          description: The unique identifier of the item in our system.
                          type: string
                          format: uuid
                        name:
                          description: The name of the item.
                          type: string
                          minLength: 1
                          example: Monthly fee
                        customFields:
                          type: object
                          description: >-
                            The values of the custom fields of items on the
                            item, keyed by the key of each custom field.
                          additionalProperties:
                            anyOf:
                              - type: string
                              - type: array
                                items:
                                  type: string
                          default: {}
                          example:
                            customField1: value1
                            customField2:
                              - value2
                              - value3
                        archivedAt:
                          description: >-
                            The timestamp when the item was archived, or null if
                            not archived.
                          type:
                            - 'null'
                            - string
                          format: date-time
                      required:
                        - id
                        - name
                        - customFields
                        - archivedAt
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''search'' must be string'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role items:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/items/{id}:
    put:
      summary: Update item
      tags:
        - Items
      description: >-
        Replaces the name and the custom fields of an item. A custom field that
        `customFields` leaves out loses its value.


        Requires the role `items:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  description: The name of the item.
                  type: string
                  minLength: 1
                  example: Monthly fee
                customFields:
                  type: object
                  description: >-
                    The values of the custom fields of items on the item, keyed
                    by the key of each custom field.
                  additionalProperties:
                    anyOf:
                      - type: string
                      - type: array
                        items:
                          type: string
                  default: {}
                  example:
                    customField1: value1
                    customField2:
                      - value2
                      - value3
              required:
                - name
                - customFields
              additionalProperties: false
        required: true
        description: >-
          The name and the values of the custom fields that replace those of the
          item.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the item in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: name_belongs_to_another_item
          when: >-
            another item, archived or not, has the `name`, ignoring case and
            accents
        - status: 400
          code: invalid_custom_fields
          when: >-
            the `customFields` leave out a required custom field of items, name
            a key that no custom field of items has, or give a custom field a
            value that it does not take
        - status: 404
          code: item_not_found
          when: no item has the `id`
      x-required-roles: *ref_24
      responses:
        '200':
          description: >-
            An item: the catalog record that names what a charge bills. Each
            resource, license and plan charge points to one item.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the item in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the item.
                    type: string
                    minLength: 1
                    example: Monthly fee
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of items on the item,
                      keyed by the key of each custom field.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  archivedAt:
                    description: >-
                      The timestamp when the item was archived, or null if not
                      archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - customFields
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `name_belongs_to_another_item`: another item, archived or not, has
            the `name`, ignoring case and accents.

            - `invalid_custom_fields`: the `customFields` leave out a required
            custom field of items, name a key that no custom field of items has,
            or give a custom field a value that it does not take.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - name_belongs_to_another_item
                      - invalid_custom_fields
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                name_belongs_to_another_item:
                  value:
                    message: name belongs to another item
                    code: name_belongs_to_another_item
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role items:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `item_not_found`: no item has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - item_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                item_not_found:
                  value:
                    message: item not found
                    code: item_not_found
    delete:
      summary: Delete item
      tags:
        - Items
      description: >-
        Deletes an item, so that `GET /v1/items` leaves it out even when
        `includeArchived` is true.


        Requires the role `items:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the item in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: item_has_active_references
          when: >-
            a resource, a license, a plan charge or a line item of an invoice
            names the item, or a recurring discount applies to a plan charge
            that bills the item, and `details.references` lists those references
        - status: 404
          code: item_not_found
          when: no item has the `id`
      x-required-roles: *ref_24
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `item_has_active_references`: a resource, a license, a plan charge
            or a line item of an invoice names the item, or a recurring discount
            applies to a plan charge that bills the item, and
            `details.references` lists those references.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - item_has_active_references
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                item_has_active_references:
                  value:
                    message: item has active references and cannot be archived
                    code: item_has_active_references
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role items:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `item_not_found`: no item has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - item_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                item_not_found:
                  value:
                    message: item not found
                    code: item_not_found
  /v1/items/{id}/archive:
    post:
      summary: Archive item
      tags:
        - Items
      description: >-
        Archives an item, so that `GET /v1/items` leaves it out unless
        `includeArchived` is true.


        Requires the role `items:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the item in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: item_is_already_archived
          when: the item is already archived
        - status: 400
          code: item_has_active_references
          when: >-
            an active or draft contract bills the item through a plan charge of
            an active plan instance, or a recurring discount of an active or
            draft contract applies to a plan charge that bills the item, and
            `details.references` lists those references
        - status: 404
          code: item_not_found
          when: no item has the `id`
      x-required-roles: *ref_24
      responses:
        '200':
          description: >-
            An item: the catalog record that names what a charge bills. Each
            resource, license and plan charge points to one item.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the item in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the item.
                    type: string
                    minLength: 1
                    example: Monthly fee
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of items on the item,
                      keyed by the key of each custom field.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  archivedAt:
                    description: >-
                      The timestamp when the item was archived, or null if not
                      archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - customFields
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `item_is_already_archived`: the item is already archived.

            - `item_has_active_references`: an active or draft contract bills
            the item through a plan charge of an active plan instance, or a
            recurring discount of an active or draft contract applies to a plan
            charge that bills the item, and `details.references` lists those
            references.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - item_is_already_archived
                      - item_has_active_references
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                item_is_already_archived:
                  value:
                    message: item is already archived
                    code: item_is_already_archived
                item_has_active_references:
                  value:
                    message: item has active references and cannot be archived
                    code: item_has_active_references
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role items:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `item_not_found`: no item has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - item_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                item_not_found:
                  value:
                    message: item not found
                    code: item_not_found
  /v1/items/{id}/unarchive:
    post:
      summary: Unarchive item
      tags:
        - Items
      description: >-
        Unarchives an item, so that `GET /v1/items` includes it again without
        `includeArchived`.


        Requires the role `items:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the item in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: item_is_not_archived
          when: the item is not archived
        - status: 404
          code: item_not_found
          when: no item has the `id`
      x-required-roles: *ref_24
      responses:
        '200':
          description: >-
            An item: the catalog record that names what a charge bills. Each
            resource, license and plan charge points to one item.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    description: The unique identifier of the item in our system.
                    type: string
                    format: uuid
                  name:
                    description: The name of the item.
                    type: string
                    minLength: 1
                    example: Monthly fee
                  customFields:
                    type: object
                    description: >-
                      The values of the custom fields of items on the item,
                      keyed by the key of each custom field.
                    additionalProperties:
                      anyOf:
                        - type: string
                        - type: array
                          items:
                            type: string
                    default: {}
                    example:
                      customField1: value1
                      customField2:
                        - value2
                        - value3
                  archivedAt:
                    description: >-
                      The timestamp when the item was archived, or null if not
                      archived.
                    type:
                      - 'null'
                      - string
                    format: date-time
                required:
                  - id
                  - name
                  - customFields
                  - archivedAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `item_is_not_archived`: the item is not archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - item_is_not_archived
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                item_is_not_archived:
                  value:
                    message: item is not archived
                    code: item_is_not_archived
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role items:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `item_not_found`: no item has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - item_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                item_not_found:
                  value:
                    message: item not found
                    code: item_not_found
  /v1/emails/:
    get:
      summary: List emails
      tags:
        - Emails
      description: >-
        Lists the emails that Aira sent, such as the invoice deliveries, newest
        first by the time when the provider accepted each one, or by the time
        when Aira created it when the provider refused it. The list leaves out
        the emails that carry a login code of the customer hub or a password
        reset code.


        Requires the role `emails:read`.
      parameters:
        - schema:
            type: string
          example: Padaria Central
          in: query
          name: search
          required: false
          description: >-
            The list returns only the emails whose subject or recipients contain
            this text, ignoring case.
        - schema:
            type: array
            items:
              type: string
              enum:
                - sent
                - delivered
                - opened
                - bounced
                - failed
          in: query
          name: status[]
          required: false
          description: The list returns only the emails in these statuses.
        - schema:
            type: string
            format: date
          example: '2026-07-01'
          in: query
          name: date.gte
          required: false
          description: >-
            The list returns only the emails sent on or after this day in
            America/Sao_Paulo, or created on or after it when the provider
            refused them.
        - schema:
            type: string
            format: date
          example: '2026-07-31'
          in: query
          name: date.lte
          required: false
          description: >-
            The list returns only the emails sent on or before this day in
            America/Sao_Paulo, or created on or before it when the provider
            refused them.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: &ref_25
        - emails:read
      responses:
        '200':
          description: The emails that match the filters, newest first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing an email that Aira sent, such as an
                        invoice delivery.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: The unique identifier of the email in our system.
                        status:
                          type: string
                          enum:
                            - sent
                            - delivered
                            - opened
                            - bounced
                            - failed
                          description: >-
                            The status of the email: `sent` once the provider
                            accepted it, `delivered` once it reached the server
                            of a recipient, `opened` once a recipient opened it,
                            `bounced` once it came back, and `failed` when the
                            provider refused it.
                        subject:
                          type: string
                          description: The subject of the email.
                          example: Fatura 42 disponível
                        recipients:
                          type: array
                          items:
                            type: string
                          description: The email addresses that the email went to.
                        sentAt:
                          type:
                            - 'null'
                            - string
                          format: date-time
                          description: >-
                            ISO 8601 timestamp in UTC indicating when the
                            provider accepted the email, or null if the provider
                            refused it.
                        createdAt:
                          type: string
                          format: date-time
                          description: >-
                            ISO 8601 timestamp in UTC indicating when Aira
                            created the email.
                        bounceType:
                          type:
                            - 'null'
                            - string
                          enum:
                            - hard
                            - soft
                            - null
                          description: >-
                            The kind of bounce that the provider reported, or
                            null if the email did not bounce or the provider did
                            not classify the bounce.
                      required:
                        - id
                        - status
                        - subject
                        - recipients
                        - sentAt
                        - createdAt
                        - bounceType
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''search'' must be string'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role emails:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/emails/{id}:
    get:
      summary: Fetch email
      tags:
        - Emails
      description: >-
        Fetches one email that Aira sent, with its body in HTML, the file names
        of its attachments, the signals of the provider and the invoice that it
        delivered.


        Requires the role `emails:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the email in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: email_not_found
          when: no e-mail has the `id`, or the e-mail carries a one-time auth code
        - *ref_1
        - *ref_2
      x-required-roles: *ref_25
      responses:
        '200':
          description: >-
            Schema representing an email that Aira sent, with its body, its
            attachments, the signals of the provider and the invoice that it
            delivered.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the email in our system.
                  status:
                    type: string
                    enum:
                      - sent
                      - delivered
                      - opened
                      - bounced
                      - failed
                    description: >-
                      The status of the email: `sent` once the provider accepted
                      it, `delivered` once it reached the server of a recipient,
                      `opened` once a recipient opened it, `bounced` once it
                      came back, and `failed` when the provider refused it.
                  subject:
                    type: string
                    description: The subject of the email.
                    example: Fatura 42 disponível
                  recipients:
                    type: array
                    items:
                      type: string
                    description: The email addresses that the email went to.
                  sentAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when the provider
                      accepted the email, or null if the provider refused it.
                  createdAt:
                    type: string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when Aira created the
                      email.
                  bounceType:
                    type:
                      - 'null'
                      - string
                    enum:
                      - hard
                      - soft
                      - null
                    description: >-
                      The kind of bounce that the provider reported, or null if
                      the email did not bounce or the provider did not classify
                      the bounce.
                  fromEmail:
                    type: string
                    description: The sender of the email, as the recipients see it.
                    example: Acme <billing+acme@useaira.com>
                  deliveredAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when the provider
                      reported that the email reached the server of a recipient,
                      or null.
                  openedAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when the provider
                      reported that a recipient opened the email, or null.
                  bouncedAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      ISO 8601 timestamp in UTC indicating when the provider
                      reported that the email bounced, or null.
                  providerReason:
                    type:
                      - 'null'
                      - string
                    description: >-
                      The reason that the provider gave, verbatim, for a bounce
                      or for a refusal, or null.
                    example: >-
                      550 5.1.1 The email account that you tried to reach does
                      not exist.
                  attachments:
                    type: array
                    items:
                      type: string
                    description: >-
                      The file names of the attachments of the email, in order.
                      Download each one by its index in this list.
                  html:
                    type:
                      - 'null'
                      - string
                    description: >-
                      The body of the email in HTML, as Aira handed it to the
                      provider, or null if Aira cannot read the stored body.
                    example: >-
                      <html><body><p>A fatura PADAR-00042 da Padaria Central
                      está disponível.</p></body></html>
                  invoice:
                    type: object
                    nullable: true
                    description: >-
                      The invoice that the email delivered, or null for an email
                      of no invoice.
                    properties:
                      id:
                        type: string
                        format: uuid
                        description: The unique identifier of the invoice in our system.
                      customerId:
                        type: string
                        format: uuid
                        description: >-
                          The unique identifier of the customer of the invoice
                          in our system.
                    required:
                      - id
                      - customerId
                    additionalProperties: false
                required:
                  - id
                  - status
                  - subject
                  - recipients
                  - sentAt
                  - createdAt
                  - bounceType
                  - fromEmail
                  - deliveredAt
                  - openedAt
                  - bouncedAt
                  - providerReason
                  - attachments
                  - html
                  - invoice
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role emails:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `email_not_found`: no e-mail has the `id`, or the e-mail carries a
            one-time auth code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - email_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                email_not_found:
                  value:
                    message: email not found
                    code: email_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/emails/{id}/attachments/{attachmentIndex}/download:
    get:
      summary: Download email attachment
      tags:
        - Emails
      description: >-
        Downloads one of the files that Aira attached to an email, by its index
        in the `attachments` list of the email.


        Requires the role `emails:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the email in our system.
        - schema:
            type: integer
            minimum: 0
          in: path
          name: attachmentIndex
          required: true
          description: >-
            The index of the attachment in the `attachments` list of the email,
            from 0.
      x-public-api: true
      x-errors:
        - status: 404
          code: email_not_found
          when: no e-mail has the `id`, or the e-mail carries a one-time auth code
        - status: 404
          code: file_not_found
          when: >-
            the e-mail has no attachment at the `attachmentIndex`, or the
            storage of Aira holds no file for it
        - *ref_1
        - *ref_2
      x-required-roles: *ref_25
      responses:
        '200':
          description: The contents of the attachment file.
          content:
            application/json:
              schema:
                type: string
                format: binary
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role emails:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `email_not_found`: no e-mail has the `id`, or the e-mail carries a
            one-time auth code.

            - `file_not_found`: the e-mail has no attachment at the
            `attachmentIndex`, or the storage of Aira holds no file for it.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - email_not_found
                      - file_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                email_not_found:
                  value:
                    message: email not found
                    code: email_not_found
                file_not_found:
                  value:
                    message: email attachment file not found in storage
                    code: file_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/emails/{id}/attachments/{attachmentIndex}/download/link:
    get:
      summary: Fetch a download link of an email attachment
      tags:
        - Emails
      description: >-
        Answers a URL that downloads the file of `GET
        /v1/emails/:id/attachments/:attachmentIndex/download` with no API key
        for five minutes, after the same checks, for a client that cannot
        receive a file, such as a chat client.


        Requires the role `emails:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the email in our system.
        - schema:
            type: integer
            minimum: 0
          in: path
          name: attachmentIndex
          required: true
          description: >-
            The index of the attachment in the `attachments` list of the email,
            from 0.
      x-public-api: true
      x-errors:
        - status: 404
          code: email_not_found
          when: no e-mail has the `id`, or the e-mail carries a one-time auth code
        - status: 404
          code: file_not_found
          when: >-
            the e-mail has no attachment at the `attachmentIndex`, or the
            storage of Aira holds no file for it
        - *ref_1
        - *ref_2
      x-required-roles: *ref_25
      responses:
        '200':
          description: >-
            A link that downloads one file with no API key, for a client that
            cannot receive a file, such as a chat client.
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                    format: uri
                    description: >-
                      The URL that downloads the file with no API key until
                      `expiresAt`. Whoever holds the URL downloads the file, so
                      share it only with whoever may read the file.
                  fileName:
                    type: string
                    description: The name of the file that the URL downloads.
                    example: PADAR-00042.pdf
                  expiresAt:
                    type: string
                    format: date-time
                    description: >-
                      The instant, in UTC, when the URL stops working, five
                      minutes after Aira creates it.
                required:
                  - url
                  - fileName
                  - expiresAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role emails:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `email_not_found`: no e-mail has the `id`, or the e-mail carries a
            one-time auth code.

            - `file_not_found`: the e-mail has no attachment at the
            `attachmentIndex`, or the storage of Aira holds no file for it.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - email_not_found
                      - file_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                email_not_found:
                  value:
                    message: email not found
                    code: email_not_found
                file_not_found:
                  value:
                    message: email attachment file not found in storage
                    code: file_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/webhook-settings/:
    get:
      summary: List webhook settings
      tags:
        - Webhooks
      description: >-
        Lists the webhook settings, newest first: the URLs that receive the
        webhook events. It never returns a token.


        Requires the role `integrations:read`.
      parameters:
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: &ref_26
        - integrations:read
      responses:
        '200':
          description: The webhook settings, newest first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        Schema representing webhook settings: a URL that
                        receives the webhook events that it subscribes to.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the webhook settings in our
                            system.
                        url:
                          type: string
                          format: uri
                          maxLength: 2048
                          description: >-
                            The URL that receives the webhook events. It points
                            to a public address, and Aira follows no redirect.
                          example: https://erp.example.com/aira/webhooks
                        events:
                          type: array
                          minItems: 1
                          uniqueItems: true
                          items:
                            type: string
                            enum:
                              - invoice.status-updated
                              - invoice.recalculated
                              - integration.inbound-failed
                          description: The webhook events that Aira sends to the URL.
                      required:
                        - id
                        - url
                        - events
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''offset'' must be integer'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role integrations:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
    post:
      summary: Create webhook settings
      tags:
        - Webhooks
      description: >-
        Creates webhook settings: a URL that receives the webhook events that it
        subscribes to. Aira follows no redirect of the URL, stores the token
        encrypted and never returns it.


        Requires the role `integrations:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  format: uri
                  maxLength: 2048
                  description: >-
                    The URL that receives the webhook events. It points to a
                    public address, and Aira follows no redirect.
                  example: https://erp.example.com/aira/webhooks
                events:
                  type: array
                  minItems: 1
                  uniqueItems: true
                  items:
                    type: string
                    enum:
                      - invoice.status-updated
                      - invoice.recalculated
                      - integration.inbound-failed
                  description: The webhook events that Aira sends to the URL.
                token:
                  type: string
                  minLength: 1
                  maxLength: 512
                  description: >-
                    The token that Aira sends in the `X-Webhook-Token` header of
                    each webhook event, so that the receiver can check that the
                    event comes from Aira. Aira stores it encrypted and never
                    returns it.
                  example: example-webhook-token
              required:
                - url
                - events
                - token
              additionalProperties: false
        required: true
        description: >-
          The URL, the webhook events and the token of the webhook settings to
          create.
      x-public-api: true
      x-errors:
        - status: 400
          code: webhook_url_not_public
          when: >-
            the host of the `url` is an IP address that is not public, such as a
            private, loopback or link-local one
      x-required-roles: &ref_27
        - integrations:write
      responses:
        '201':
          description: >-
            Schema representing webhook settings: a URL that receives the
            webhook events that it subscribes to.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the webhook settings in our
                      system.
                  url:
                    type: string
                    format: uri
                    maxLength: 2048
                    description: >-
                      The URL that receives the webhook events. It points to a
                      public address, and Aira follows no redirect.
                    example: https://erp.example.com/aira/webhooks
                  events:
                    type: array
                    minItems: 1
                    uniqueItems: true
                    items:
                      type: string
                      enum:
                        - invoice.status-updated
                        - invoice.recalculated
                        - integration.inbound-failed
                    description: The webhook events that Aira sends to the URL.
                required:
                  - id
                  - url
                  - events
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `webhook_url_not_public`: the host of the `url` is an IP address
            that is not public, such as a private, loopback or link-local one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - webhook_url_not_public
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''url'' is required'
                    code: json_schema_validation_error
                webhook_url_not_public:
                  value:
                    message: >-
                      the host of the `url` is an IP address that is not public,
                      such as a private, loopback or link-local one
                    code: webhook_url_not_public
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role integrations:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
  /v1/webhook-settings/{id}:
    get:
      summary: Fetch webhook settings
      tags:
        - Webhooks
      description: |-
        Fetches webhook settings by their id. It never returns the token.

        Requires the role `integrations:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the webhook settings in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: webhook_settings_not_found
          when: no webhook settings have the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_26
      responses:
        '200':
          description: >-
            Schema representing webhook settings: a URL that receives the
            webhook events that it subscribes to.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the webhook settings in our
                      system.
                  url:
                    type: string
                    format: uri
                    maxLength: 2048
                    description: >-
                      The URL that receives the webhook events. It points to a
                      public address, and Aira follows no redirect.
                    example: https://erp.example.com/aira/webhooks
                  events:
                    type: array
                    minItems: 1
                    uniqueItems: true
                    items:
                      type: string
                      enum:
                        - invoice.status-updated
                        - invoice.recalculated
                        - integration.inbound-failed
                    description: The webhook events that Aira sends to the URL.
                required:
                  - id
                  - url
                  - events
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role integrations:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `webhook_settings_not_found`: no webhook settings have the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - webhook_settings_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                webhook_settings_not_found:
                  value:
                    message: webhook settings not found
                    code: webhook_settings_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
    patch:
      summary: Update webhook settings
      tags:
        - Webhooks
      description: >-
        Changes the URL, the events or the token of webhook settings, and keeps
        each one that the body leaves out.


        Requires the role `integrations:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  format: uri
                  maxLength: 2048
                  description: >-
                    The URL that receives the webhook events. It points to a
                    public address, and Aira follows no redirect.
                  example: https://erp.example.com/aira/webhooks
                events:
                  type: array
                  minItems: 1
                  uniqueItems: true
                  items:
                    type: string
                    enum:
                      - invoice.status-updated
                      - invoice.recalculated
                      - integration.inbound-failed
                  description: The webhook events that Aira sends to the URL.
                token:
                  type: string
                  minLength: 1
                  maxLength: 512
                  description: >-
                    The token that Aira sends in the `X-Webhook-Token` header of
                    each webhook event. Leave it out to keep the stored token.
                  example: example-webhook-token
              required: []
              additionalProperties: false
        description: >-
          The fields of the webhook settings to change. A field that the body
          leaves out keeps its value.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the webhook settings in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: webhook_url_not_public
          when: >-
            the host of the `url` is an IP address that is not public, such as a
            private, loopback or link-local one
        - status: 404
          code: webhook_settings_not_found
          when: no webhook settings have the `id`
      x-required-roles: *ref_27
      responses:
        '200':
          description: >-
            Schema representing webhook settings: a URL that receives the
            webhook events that it subscribes to.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the webhook settings in our
                      system.
                  url:
                    type: string
                    format: uri
                    maxLength: 2048
                    description: >-
                      The URL that receives the webhook events. It points to a
                      public address, and Aira follows no redirect.
                    example: https://erp.example.com/aira/webhooks
                  events:
                    type: array
                    minItems: 1
                    uniqueItems: true
                    items:
                      type: string
                      enum:
                        - invoice.status-updated
                        - invoice.recalculated
                        - integration.inbound-failed
                    description: The webhook events that Aira sends to the URL.
                required:
                  - id
                  - url
                  - events
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `webhook_url_not_public`: the host of the `url` is an IP address
            that is not public, such as a private, loopback or link-local one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - webhook_url_not_public
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                webhook_url_not_public:
                  value:
                    message: >-
                      the host of the `url` is an IP address that is not public,
                      such as a private, loopback or link-local one
                    code: webhook_url_not_public
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role integrations:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `webhook_settings_not_found`: no webhook settings have the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - webhook_settings_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                webhook_settings_not_found:
                  value:
                    message: webhook settings not found
                    code: webhook_settings_not_found
    delete:
      summary: Delete webhook settings
      tags:
        - Webhooks
      description: >-
        Deletes webhook settings, so their URL stops receiving webhook events at
        once.


        Requires the role `integrations:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the webhook settings in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: webhook_settings_not_found
          when: no webhook settings have the `id`
      x-required-roles: *ref_27
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role integrations:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `webhook_settings_not_found`: no webhook settings have the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - webhook_settings_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                webhook_settings_not_found:
                  value:
                    message: webhook settings not found
                    code: webhook_settings_not_found
  /v1/api-keys/:
    get:
      summary: List API keys
      tags:
        - Api Keys
      description: >-
        Lists the API keys, newest first, the calling API key among them,
        without the keys themselves.


        Requires the role `api_keys:admin`.
      parameters:
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: &ref_28
        - api_keys:admin
      responses:
        '200':
          description: The API keys, newest first.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        An API key: a key that a system sends in the `X-API-KEY`
                        header to call the public API, with the roles that set
                        what the system can do. Aira shows the key itself only
                        in the reply that creates the API key.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: The unique identifier of the API key.
                        friendlyName:
                          type: string
                          description: >-
                            The name that tells the API key apart from the other
                            API keys, such as the name of the system that uses
                            it.
                          example: ERP da Padaria Central
                        roles:
                          type: array
                          items:
                            type: string
                          description: >-
                            The roles of the API key, each a resource and a
                            permission, such as `invoices:read`, which set what
                            the API key can do. A `write` role does not cover
                            `read`.
                          example:
                            - invoices:read
                            - invoices:write
                        status:
                          type: string
                          enum:
                            - active
                            - deactivated
                            - revoked
                          description: >-
                            The status of the API key. Only an `active` API key
                            can call the public API.
                        expireAt:
                          type: string
                          format: date-time
                          description: The instant, in UTC, when the API key stops working.
                          example: '2027-01-01T00:00:00.000Z'
                      required:
                        - id
                        - friendlyName
                        - roles
                        - status
                        - expireAt
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''offset'' must be integer'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role api_keys:admin can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
    post:
      summary: Create API key
      tags:
        - Api Keys
      description: >-
        Creates an active API key, which `GET /v1/api-keys` lists from then on,
        and answers the key itself, which Aira shows only in this reply.


        Requires the role `api_keys:admin`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                friendlyName:
                  type: string
                  description: >-
                    The name that tells the API key apart from the other API
                    keys, such as the name of the system that uses it.
                  example: ERP da Padaria Central
                roles:
                  type: array
                  items:
                    type: string
                    enum:
                      - contracts:admin
                      - contracts:read
                      - contracts:write
                      - custom_fields:read
                      - custom_fields:write
                      - customers:read
                      - customers:write
                      - dunning:read
                      - dunning:write
                      - emails:read
                      - events:read
                      - events:write
                      - integrations:read
                      - integrations:write
                      - invoices:read
                      - invoices:write
                      - items:read
                      - items:write
                      - legal_entities:read
                      - licenses:read
                      - licenses:write
                      - payment_accounts:read
                      - payment_accounts:write
                      - payments:read
                      - plan_instance_versions:read
                      - plan_instance_versions:write
                      - plan_instances:read
                      - plan_instances:write
                      - plans:read
                      - plans:write
                      - products:read
                      - products:write
                      - resources:read
                      - resources:write
                      - watchtower:write
                  description: >-
                    The roles of the API key, each a resource and a permission,
                    such as `invoices:read`, which set what the API key can do.
                    A `write` role does not cover `read`.
                  example:
                    - invoices:read
                    - invoices:write
                expireAt:
                  type: string
                  format: date-time
                  description: The instant, in UTC, when the API key stops working.
                  example: '2027-01-01T00:00:00.000Z'
              required:
                - friendlyName
                - roles
                - expireAt
              additionalProperties: false
        required: true
        description: The API key to create.
      x-public-api: true
      x-errors: []
      x-required-roles: *ref_28
      responses:
        '201':
          description: >-
            An API key that Aira just created, with the key itself, which no
            other reply shows.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the API key.
                  friendlyName:
                    type: string
                    description: >-
                      The name that tells the API key apart from the other API
                      keys, such as the name of the system that uses it.
                    example: ERP da Padaria Central
                  roles:
                    type: array
                    items:
                      type: string
                    description: >-
                      The roles of the API key, each a resource and a
                      permission, such as `invoices:read`, which set what the
                      API key can do. A `write` role does not cover `read`.
                    example:
                      - invoices:read
                      - invoices:write
                  status:
                    type: string
                    enum:
                      - active
                      - deactivated
                      - revoked
                    description: >-
                      The status of the API key. Only an `active` API key can
                      call the public API.
                  expireAt:
                    type: string
                    format: date-time
                    description: The instant, in UTC, when the API key stops working.
                    example: '2027-01-01T00:00:00.000Z'
                  key:
                    type: string
                    description: >-
                      The key that a system sends in the `X-API-KEY` header to
                      call the public API. Aira stores only a hash of it, so no
                      later reply shows it.
                    example: example-api-key
                required:
                  - id
                  - friendlyName
                  - roles
                  - status
                  - expireAt
                  - key
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''friendlyName'' is required'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role api_keys:admin can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
  /v1/api-keys/{id}:
    patch:
      summary: Update API key
      tags:
        - Api Keys
      description: >-
        Changes the name, the roles, the status or the expiry date of another
        API key, and keeps each field that the body leaves out. The next request
        of the API key runs with the change, so a key that becomes `deactivated`
        or `revoked` stops working at once.


        Requires the role `api_keys:admin`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                friendlyName:
                  type: string
                  description: >-
                    The name that tells the API key apart from the other API
                    keys, such as the name of the system that uses it.
                  example: ERP da Padaria Central
                roles:
                  type: array
                  items:
                    type: string
                    enum:
                      - contracts:admin
                      - contracts:read
                      - contracts:write
                      - custom_fields:read
                      - custom_fields:write
                      - customers:read
                      - customers:write
                      - dunning:read
                      - dunning:write
                      - emails:read
                      - events:read
                      - events:write
                      - integrations:read
                      - integrations:write
                      - invoices:read
                      - invoices:write
                      - items:read
                      - items:write
                      - legal_entities:read
                      - licenses:read
                      - licenses:write
                      - payment_accounts:read
                      - payment_accounts:write
                      - payments:read
                      - plan_instance_versions:read
                      - plan_instance_versions:write
                      - plan_instances:read
                      - plan_instances:write
                      - plans:read
                      - plans:write
                      - products:read
                      - products:write
                      - resources:read
                      - resources:write
                      - watchtower:write
                  description: >-
                    The roles of the API key, each a resource and a permission,
                    such as `invoices:read`, which set what the API key can do.
                    A `write` role does not cover `read`.
                  example:
                    - invoices:read
                    - invoices:write
                expireAt:
                  type: string
                  format: date-time
                  description: The instant, in UTC, when the API key stops working.
                  example: '2027-01-01T00:00:00.000Z'
                status:
                  type: string
                  enum:
                    - active
                    - deactivated
                    - revoked
                  description: >-
                    The status of the API key. Only an `active` API key can call
                    the public API.
              required: []
              additionalProperties: false
        description: >-
          The fields of the API key to change. The API key keeps each field that
          the body leaves out.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the API key.
      x-public-api: true
      x-errors:
        - status: 403
          code: bad_auth
          when: >-
            the `id` names the calling API key, or the API key of the `id` holds
            a role that only Aira's team grants and the body does more than set
            `status` to `revoked`
        - status: 404
          code: api_key_not_found
          when: no API key has the `id`
      x-required-roles: *ref_28
      responses:
        '200':
          description: >-
            An API key: a key that a system sends in the `X-API-KEY` header to
            call the public API, with the roles that set what the system can do.
            Aira shows the key itself only in the reply that creates the API
            key.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the API key.
                  friendlyName:
                    type: string
                    description: >-
                      The name that tells the API key apart from the other API
                      keys, such as the name of the system that uses it.
                    example: ERP da Padaria Central
                  roles:
                    type: array
                    items:
                      type: string
                    description: >-
                      The roles of the API key, each a resource and a
                      permission, such as `invoices:read`, which set what the
                      API key can do. A `write` role does not cover `read`.
                    example:
                      - invoices:read
                      - invoices:write
                  status:
                    type: string
                    enum:
                      - active
                      - deactivated
                      - revoked
                    description: >-
                      The status of the API key. Only an `active` API key can
                      call the public API.
                  expireAt:
                    type: string
                    format: date-time
                    description: The instant, in UTC, when the API key stops working.
                    example: '2027-01-01T00:00:00.000Z'
                required:
                  - id
                  - friendlyName
                  - roles
                  - status
                  - expireAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires; or the `id` names the calling API key, or the API key of
            the `id` holds a role that only Aira's team grants and the body does
            more than set `status` to `revoked`.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role api_keys:admin can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `api_key_not_found`: no API key has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - api_key_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                api_key_not_found:
                  value:
                    message: api key not found
                    code: api_key_not_found
  /v1/payments/{id}:
    get:
      summary: Fetch payment
      tags:
        - Payments
      description: >-
        Fetches a payment by id, with the fields that `GET /invoices/{id}`
        returns for each payment of the invoice.


        Requires the role `payments:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          example: 3c90c3cc-0d44-4b50-8888-8dd25736052a
          in: path
          name: id
          required: true
          description: The unique identifier of the payment in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: payment_not_found
          when: no payment has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: &ref_29
        - payments:read
      responses:
        '200':
          description: >-
            A payment: one request to collect the amount of an invoice through a
            payment provider, with its method, due date and status. An invoice
            can have several. A payment that the ERP issues and holds is an
            external payment.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: The unique identifier of the payment in our system.
                    example: 3c90c3cc-0d44-4b50-8888-8dd25736052a
                  amount:
                    type: number
                    multipleOf: 1
                    description: Amount charged by the payment, in cents.
                  dueDate:
                    type: string
                    format: date
                    nullable: true
                    description: >-
                      Due date of the payment charge. Null when the payment has
                      no due date.
                  paymentMethod:
                    type: string
                    enum:
                      - bolepix
                      - bank_slip
                      - pix
                      - credit_card
                      - bank_transfer
                    description: >-
                      How the payment is collected: pix, bank_slip (boleto),
                      bolepix (boleto payable via Pix), credit_card, or
                      bank_transfer.
                  status:
                    type: string
                    enum:
                      - created
                      - pending
                      - paid
                      - failed
                      - canceled
                      - expired
                    description: >-
                      Current status of the payment: created (registered at the
                      provider), pending (awaiting settlement), paid, failed,
                      canceled, or expired.
                  provider:
                    type: string
                    enum:
                      - celcash
                      - omie
                      - asaas
                      - contaazul
                    description: The payment provider that collects the payment.
                  paymentLinkUrl:
                    type: string
                    nullable: true
                    description: >-
                      The payment link: the page at the payment provider where
                      the customer pays. Null when the payment provider gave
                      none.
                    example: https://www.asaas.com/i/abc123def456
                required:
                  - id
                  - amount
                  - dueDate
                  - paymentMethod
                  - status
                  - provider
                  - paymentLinkUrl
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role payments:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `payment_not_found`: no payment has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - payment_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                payment_not_found:
                  value:
                    message: payment not found
                    code: payment_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/payments/{id}/files/download:
    get:
      summary: Download the boleto or Pix file of a payment
      tags:
        - Payments
      description: >-
        Downloads the file of the boleto or of the Pix of a payment, as the
        billing app does, with the content type of the stored file: a boleto is
        a PDF, and a Pix is a PNG, a JPEG or a PDF, by the payment provider.


        Requires the role `payments:read`.
      parameters:
        - schema:
            type: string
            enum:
              - pix
              - bank_slip
          in: query
          name: paymentFileType
          required: true
          description: >-
            The file of the payment to download: `bank_slip` for the file of its
            boleto, or `pix` for the file of its Pix.
        - schema:
            type: string
            format: uuid
          example: 3c90c3cc-0d44-4b50-8888-8dd25736052a
          in: path
          name: id
          required: true
          description: The unique identifier of the payment in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: payment_integration_not_enabled
          when: the payments module is off
        - status: 400
          code: invalid_payment_status_for_download
          when: >-
            the status of the payment is `created`, `canceled` or `failed`,
            which has no file to download
        - status: 404
          code: payment_not_found
          when: no payment has the `id`
        - status: 404
          code: file_not_found
          when: the payment has no file of the `paymentFileType`
        - status: 404
          code: invoice_not_found
          when: the invoice of the payment was deleted with its customer
        - *ref_1
        - *ref_2
      x-required-roles: *ref_29
      responses:
        '200':
          description: >-
            The contents of the file of the boleto or of the Pix of the payment,
            with the content type of the stored file.
          content:
            application/pdf:
              schema:
                type: string
                format: binary
            image/png:
              schema:
                type: string
                format: binary
            image/jpeg:
              schema:
                type: string
                format: binary
            application/octet-stream:
              schema:
                type: string
                format: binary
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or a query
            parameter breaks the schema of the endpoint.

            - `payment_integration_not_enabled`: the payments module is off.

            - `invalid_payment_status_for_download`: the status of the payment
            is `created`, `canceled` or `failed`, which has no file to download.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - payment_integration_not_enabled
                      - invalid_payment_status_for_download
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                payment_integration_not_enabled:
                  value:
                    message: payment integration not enabled
                    code: payment_integration_not_enabled
                invalid_payment_status_for_download:
                  value:
                    message: cannot download files for payments with invalid status
                    code: invalid_payment_status_for_download
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role payments:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `payment_not_found`: no payment has the `id`.

            - `file_not_found`: the payment has no file of the
            `paymentFileType`.

            - `invoice_not_found`: the invoice of the payment was deleted with
            its customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - payment_not_found
                      - file_not_found
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                payment_not_found:
                  value:
                    message: payment not found
                    code: payment_not_found
                file_not_found:
                  value:
                    message: email attachment file not found in storage
                    code: file_not_found
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/payments/{id}/files/download/link:
    get:
      summary: Fetch a download link of the boleto or Pix of a payment
      tags:
        - Payments
      description: >-
        Answers a URL that downloads the file of `GET
        /v1/payments/:id/files/download` with no API key for five minutes, after
        the same checks, for a client that cannot receive a file, such as a chat
        client.


        Requires the role `payments:read`.
      parameters:
        - schema:
            type: string
            enum:
              - pix
              - bank_slip
          in: query
          name: paymentFileType
          required: true
          description: >-
            The file of the payment to download: `bank_slip` for the file of its
            boleto, or `pix` for the file of its Pix.
        - schema:
            type: string
            format: uuid
          example: 3c90c3cc-0d44-4b50-8888-8dd25736052a
          in: path
          name: id
          required: true
          description: The unique identifier of the payment in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: payment_integration_not_enabled
          when: the payments module is off
        - status: 400
          code: invalid_payment_status_for_download
          when: >-
            the status of the payment is `created`, `canceled` or `failed`,
            which has no file to download
        - status: 404
          code: payment_not_found
          when: no payment has the `id`
        - status: 404
          code: file_not_found
          when: the payment has no file of the `paymentFileType`
        - status: 404
          code: invoice_not_found
          when: the invoice of the payment was deleted with its customer
        - *ref_1
        - *ref_2
      x-required-roles: *ref_29
      responses:
        '200':
          description: >-
            A link that downloads one file with no API key, for a client that
            cannot receive a file, such as a chat client.
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                    format: uri
                    description: >-
                      The URL that downloads the file with no API key until
                      `expiresAt`. Whoever holds the URL downloads the file, so
                      share it only with whoever may read the file.
                  fileName:
                    type: string
                    description: The name of the file that the URL downloads.
                    example: PADAR-00042.pdf
                  expiresAt:
                    type: string
                    format: date-time
                    description: >-
                      The instant, in UTC, when the URL stops working, five
                      minutes after Aira creates it.
                required:
                  - url
                  - fileName
                  - expiresAt
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or a query
            parameter breaks the schema of the endpoint.

            - `payment_integration_not_enabled`: the payments module is off.

            - `invalid_payment_status_for_download`: the status of the payment
            is `created`, `canceled` or `failed`, which has no file to download.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - payment_integration_not_enabled
                      - invalid_payment_status_for_download
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                payment_integration_not_enabled:
                  value:
                    message: payment integration not enabled
                    code: payment_integration_not_enabled
                invalid_payment_status_for_download:
                  value:
                    message: cannot download files for payments with invalid status
                    code: invalid_payment_status_for_download
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role payments:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `payment_not_found`: no payment has the `id`.

            - `file_not_found`: the payment has no file of the
            `paymentFileType`.

            - `invoice_not_found`: the invoice of the payment was deleted with
            its customer.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - payment_not_found
                      - file_not_found
                      - invoice_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                payment_not_found:
                  value:
                    message: payment not found
                    code: payment_not_found
                file_not_found:
                  value:
                    message: email attachment file not found in storage
                    code: file_not_found
                invoice_not_found:
                  value:
                    message: invoice not found
                    code: invoice_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/dunning-schedules/:
    post:
      summary: Create dunning schedule
      tags:
        - Dunning
      description: >-
        Creates a dunning schedule with its dunning steps. When `isDefault` is
        true, the dunning schedule becomes the default one in place of the
        previous one.


        Requires the role `dunning:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  description: The name of the dunning schedule.
                  example: Régua padrão
                isDefault:
                  type: boolean
                  description: >-
                    Whether the dunning schedule is the default one, which a
                    customer follows when its creation leaves out the dunning
                    schedule. At most one dunning schedule is the default, and
                    an archived dunning schedule is never the default.
                steps:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    description: >-
                      A dunning step: one e-mail of a dunning schedule, sent on
                      the issue day, on the due date, a number of days before or
                      after the due date, or after the payment. A dunning step
                      goes out inside the `dispatchWindow` of the dunning
                      settings, so with `business_hours` a dunning step whose
                      day falls on a Saturday or a Sunday goes out at 09:00 of
                      the next Monday.
                    properties:
                      name:
                        type: string
                        minLength: 1
                        description: The name of the dunning step.
                        example: Lembrete de vencimento
                      anchor:
                        type: string
                        enum:
                          - issued
                          - on_due_date
                          - due_date
                          - on_payment_confirmation
                        description: >-
                          When the dunning step sends its e-mail: `issued` on
                          the issue day of the invoice, `on_due_date` on its due
                          date, `due_date` the number of days in `offsetDays`
                          from its due date, and `on_payment_confirmation` after
                          Aira records its payment.
                      offsetDays:
                        type:
                          - 'null'
                          - integer
                        description: >-
                          The number of days from the due date on which a
                          `due_date` step sends, after the due date when
                          positive and before it when negative. It is null for
                          every other anchor.
                        example: 5
                      channel:
                        type: string
                        enum:
                          - email
                        description: >-
                          The channel through which the dunning step reaches the
                          invoice recipients.
                      content:
                        type: object
                        description: >-
                          The e-mail that the dunning step sends. The subject,
                          the title and the body can hold variables in double
                          braces, such as `{{ invoiceNumber }}`, `{{ dueDate }}`
                          or `{{ paymentLink }}`, which Aira fills in for each
                          invoice.
                        properties:
                          subject:
                            type: string
                            minLength: 1
                            description: The subject of the e-mail.
                            example: Sua fatura {{ invoiceNumber }}
                          title:
                            type: string
                            minLength: 1
                            description: The title that the e-mail shows above its body.
                            example: Sua fatura está disponível!
                          body:
                            type: string
                            minLength: 1
                            description: The text of the e-mail.
                            example: >-
                              Olá {{ billingAccountBusinessName }}, sua fatura
                              vence em {{ dueDate }}.
                          attachments:
                            type: object
                            description: >-
                              The files that the e-mail of the dunning step
                              attaches. A dunning step can attach only the files
                              that the `attachmentOptions` of the dunning
                              settings list.
                            properties:
                              artifacts:
                                type: array
                                description: >-
                                  The invoice artifacts that the e-mail
                                  attaches.
                                items:
                                  type: object
                                  properties:
                                    type:
                                      anyOf:
                                        - enum:
                                            - default:invoice_pdf
                                        - type: string
                                          pattern: ^custom:.+$
                                      description: >-
                                        The type of the invoice artifact:
                                        `default:invoice_pdf` for the invoice
                                        PDF, or `custom:*` for an invoice
                                        artifact that Aira writes for you.
                                  required:
                                    - type
                                  additionalProperties: false
                              paymentFiles:
                                type: boolean
                                description: >-
                                  Whether the e-mail attaches the files of the
                                  payment of the invoice: the boleto, the Pix
                                  file or both, as the payment method of its
                                  contract produces. A dunning step that sends
                                  after the payment cannot attach them.
                              fiscalDocumentFiles:
                                type: boolean
                                description: >-
                                  Whether the e-mail attaches the PDF and the
                                  XML of the fiscal document of the invoice.
                              invoiceAttachmentFiles:
                                type: boolean
                                description: >-
                                  Whether the e-mail attaches the invoice
                                  attachments that a user or a system marked to
                                  go out with the invoice.
                            required:
                              - artifacts
                              - paymentFiles
                              - fiscalDocumentFiles
                              - invoiceAttachmentFiles
                            additionalProperties: false
                        required:
                          - subject
                          - title
                          - body
                          - attachments
                        additionalProperties: false
                    required:
                      - name
                      - anchor
                      - offsetDays
                      - channel
                      - content
                    additionalProperties: false
                  description: The dunning steps of the dunning schedule, at least one.
              required:
                - name
                - isDefault
                - steps
              additionalProperties: false
        required: true
        description: A dunning schedule with its dunning steps.
      x-public-api: true
      x-errors:
        - status: 400
          code: dunning_step_invalid
          when: >-
            a `due_date` dunning step has no `offsetDays`, a dunning step of
            another anchor has one, a dunning step attaches a file that the
            `attachmentOptions` of the dunning settings do not list, or an
            `on_payment_confirmation` dunning step attaches the files of the
            payment
      x-required-roles: &ref_30
        - dunning:write
      responses:
        '201':
          description: >-
            A dunning schedule: the sequence of e-mails about an invoice, from
            its issue to after its due date, and after its payment. Each
            customer follows at most one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the dunning schedule in our
                      system.
                  name:
                    type: string
                    minLength: 1
                    description: The name of the dunning schedule.
                    example: Régua padrão
                  isDefault:
                    type: boolean
                    description: >-
                      Whether the dunning schedule is the default one, which a
                      customer follows when its creation leaves out the dunning
                      schedule. At most one dunning schedule is the default, and
                      an archived dunning schedule is never the default.
                  archivedAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      The timestamp when the dunning schedule was archived, or
                      null if not archived. An archived dunning schedule cannot
                      be changed or assigned to a customer.
                  steps:
                    type: array
                    items:
                      type: object
                      description: >-
                        A dunning step: one e-mail of a dunning schedule, sent
                        on the issue day, on the due date, a number of days
                        before or after the due date, or after the payment. A
                        dunning step goes out inside the `dispatchWindow` of the
                        dunning settings, so with `business_hours` a dunning
                        step whose day falls on a Saturday or a Sunday goes out
                        at 09:00 of the next Monday.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the dunning step in our
                            system.
                        name:
                          type: string
                          minLength: 1
                          description: The name of the dunning step.
                          example: Lembrete de vencimento
                        anchor:
                          type: string
                          enum:
                            - issued
                            - on_due_date
                            - due_date
                            - on_payment_confirmation
                          description: >-
                            When the dunning step sends its e-mail: `issued` on
                            the issue day of the invoice, `on_due_date` on its
                            due date, `due_date` the number of days in
                            `offsetDays` from its due date, and
                            `on_payment_confirmation` after Aira records its
                            payment.
                        offsetDays:
                          type:
                            - 'null'
                            - integer
                          description: >-
                            The number of days from the due date on which a
                            `due_date` step sends, after the due date when
                            positive and before it when negative. It is null for
                            every other anchor.
                          example: 5
                        channel:
                          type: string
                          enum:
                            - email
                          description: >-
                            The channel through which the dunning step reaches
                            the invoice recipients.
                        content:
                          type: object
                          description: >-
                            The e-mail that the dunning step sends. The subject,
                            the title and the body can hold variables in double
                            braces, such as `{{ invoiceNumber }}`, `{{ dueDate
                            }}` or `{{ paymentLink }}`, which Aira fills in for
                            each invoice.
                          properties:
                            subject:
                              type: string
                              minLength: 1
                              description: The subject of the e-mail.
                              example: Sua fatura {{ invoiceNumber }}
                            title:
                              type: string
                              minLength: 1
                              description: The title that the e-mail shows above its body.
                              example: Sua fatura está disponível!
                            body:
                              type: string
                              minLength: 1
                              description: The text of the e-mail.
                              example: >-
                                Olá {{ billingAccountBusinessName }}, sua fatura
                                vence em {{ dueDate }}.
                            attachments:
                              type: object
                              description: >-
                                The files that the e-mail of the dunning step
                                attaches. A dunning step can attach only the
                                files that the `attachmentOptions` of the
                                dunning settings list.
                              properties:
                                artifacts:
                                  type: array
                                  description: >-
                                    The invoice artifacts that the e-mail
                                    attaches.
                                  items:
                                    type: object
                                    properties:
                                      type:
                                        anyOf:
                                          - enum:
                                              - default:invoice_pdf
                                          - type: string
                                            pattern: ^custom:.+$
                                        description: >-
                                          The type of the invoice artifact:
                                          `default:invoice_pdf` for the invoice
                                          PDF, or `custom:*` for an invoice
                                          artifact that Aira writes for you.
                                    required:
                                      - type
                                    additionalProperties: false
                                paymentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the files of the
                                    payment of the invoice: the boleto, the Pix
                                    file or both, as the payment method of its
                                    contract produces. A dunning step that sends
                                    after the payment cannot attach them.
                                fiscalDocumentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the PDF and the
                                    XML of the fiscal document of the invoice.
                                invoiceAttachmentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the invoice
                                    attachments that a user or a system marked
                                    to go out with the invoice.
                              required:
                                - artifacts
                                - paymentFiles
                                - fiscalDocumentFiles
                                - invoiceAttachmentFiles
                              additionalProperties: false
                          required:
                            - subject
                            - title
                            - body
                            - attachments
                          additionalProperties: false
                      required:
                        - id
                        - name
                        - anchor
                        - offsetDays
                        - channel
                        - content
                      additionalProperties: false
                    description: >-
                      The dunning steps of the dunning schedule, ordered by when
                      they send: the issue day first, then by the days from the
                      due date, and the payment last.
                required:
                  - id
                  - name
                  - isDefault
                  - archivedAt
                  - steps
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `dunning_step_invalid`: a `due_date` dunning step has no
            `offsetDays`, a dunning step of another anchor has one, a dunning
            step attaches a file that the `attachmentOptions` of the dunning
            settings do not list, or an `on_payment_confirmation` dunning step
            attaches the files of the payment.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - dunning_step_invalid
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                dunning_step_invalid:
                  value:
                    message: >-
                      step "{name}" asks for an attachment that Aira does not
                      produce for the invoices
                    code: dunning_step_invalid
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role dunning:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
    get:
      summary: List dunning schedules
      tags:
        - Dunning
      description: >-
        Lists the dunning schedules with their dunning steps, newest first by
        creation time. Archived dunning schedules are listed only when
        `includeArchived` is true.


        Requires the role `dunning:read`.
      parameters:
        - schema:
            type: string
          example: padrão
          in: query
          name: search
          required: false
          description: >-
            Free-text search over the dunning schedule name, ignoring case and
            accents.
        - schema:
            type: boolean
            default: false
          in: query
          name: includeArchived
          required: false
          description: Whether archived dunning schedules should be returned.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: &ref_31
        - dunning:read
      responses:
        '200':
          description: The dunning schedules that match the filters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A dunning schedule: the sequence of e-mails about an
                        invoice, from its issue to after its due date, and after
                        its payment. Each customer follows at most one.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the dunning schedule in our
                            system.
                        name:
                          type: string
                          minLength: 1
                          description: The name of the dunning schedule.
                          example: Régua padrão
                        isDefault:
                          type: boolean
                          description: >-
                            Whether the dunning schedule is the default one,
                            which a customer follows when its creation leaves
                            out the dunning schedule. At most one dunning
                            schedule is the default, and an archived dunning
                            schedule is never the default.
                        archivedAt:
                          type:
                            - 'null'
                            - string
                          format: date-time
                          description: >-
                            The timestamp when the dunning schedule was
                            archived, or null if not archived. An archived
                            dunning schedule cannot be changed or assigned to a
                            customer.
                        steps:
                          type: array
                          items:
                            type: object
                            description: >-
                              A dunning step: one e-mail of a dunning schedule,
                              sent on the issue day, on the due date, a number
                              of days before or after the due date, or after the
                              payment. A dunning step goes out inside the
                              `dispatchWindow` of the dunning settings, so with
                              `business_hours` a dunning step whose day falls on
                              a Saturday or a Sunday goes out at 09:00 of the
                              next Monday.
                            properties:
                              id:
                                type: string
                                format: uuid
                                description: >-
                                  The unique identifier of the dunning step in
                                  our system.
                              name:
                                type: string
                                minLength: 1
                                description: The name of the dunning step.
                                example: Lembrete de vencimento
                              anchor:
                                type: string
                                enum:
                                  - issued
                                  - on_due_date
                                  - due_date
                                  - on_payment_confirmation
                                description: >-
                                  When the dunning step sends its e-mail:
                                  `issued` on the issue day of the invoice,
                                  `on_due_date` on its due date, `due_date` the
                                  number of days in `offsetDays` from its due
                                  date, and `on_payment_confirmation` after Aira
                                  records its payment.
                              offsetDays:
                                type:
                                  - 'null'
                                  - integer
                                description: >-
                                  The number of days from the due date on which
                                  a `due_date` step sends, after the due date
                                  when positive and before it when negative. It
                                  is null for every other anchor.
                                example: 5
                              channel:
                                type: string
                                enum:
                                  - email
                                description: >-
                                  The channel through which the dunning step
                                  reaches the invoice recipients.
                              content:
                                type: object
                                description: >-
                                  The e-mail that the dunning step sends. The
                                  subject, the title and the body can hold
                                  variables in double braces, such as `{{
                                  invoiceNumber }}`, `{{ dueDate }}` or `{{
                                  paymentLink }}`, which Aira fills in for each
                                  invoice.
                                properties:
                                  subject:
                                    type: string
                                    minLength: 1
                                    description: The subject of the e-mail.
                                    example: Sua fatura {{ invoiceNumber }}
                                  title:
                                    type: string
                                    minLength: 1
                                    description: >-
                                      The title that the e-mail shows above its
                                      body.
                                    example: Sua fatura está disponível!
                                  body:
                                    type: string
                                    minLength: 1
                                    description: The text of the e-mail.
                                    example: >-
                                      Olá {{ billingAccountBusinessName }}, sua
                                      fatura vence em {{ dueDate }}.
                                  attachments:
                                    type: object
                                    description: >-
                                      The files that the e-mail of the dunning
                                      step attaches. A dunning step can attach
                                      only the files that the
                                      `attachmentOptions` of the dunning
                                      settings list.
                                    properties:
                                      artifacts:
                                        type: array
                                        description: >-
                                          The invoice artifacts that the e-mail
                                          attaches.
                                        items:
                                          type: object
                                          properties:
                                            type:
                                              anyOf:
                                                - enum:
                                                    - default:invoice_pdf
                                                - type: string
                                                  pattern: ^custom:.+$
                                              description: >-
                                                The type of the invoice artifact:
                                                `default:invoice_pdf` for the invoice
                                                PDF, or `custom:*` for an invoice
                                                artifact that Aira writes for you.
                                          required:
                                            - type
                                          additionalProperties: false
                                      paymentFiles:
                                        type: boolean
                                        description: >-
                                          Whether the e-mail attaches the files of
                                          the payment of the invoice: the boleto,
                                          the Pix file or both, as the payment
                                          method of its contract produces. A
                                          dunning step that sends after the
                                          payment cannot attach them.
                                      fiscalDocumentFiles:
                                        type: boolean
                                        description: >-
                                          Whether the e-mail attaches the PDF and
                                          the XML of the fiscal document of the
                                          invoice.
                                      invoiceAttachmentFiles:
                                        type: boolean
                                        description: >-
                                          Whether the e-mail attaches the invoice
                                          attachments that a user or a system
                                          marked to go out with the invoice.
                                    required:
                                      - artifacts
                                      - paymentFiles
                                      - fiscalDocumentFiles
                                      - invoiceAttachmentFiles
                                    additionalProperties: false
                                required:
                                  - subject
                                  - title
                                  - body
                                  - attachments
                                additionalProperties: false
                            required:
                              - id
                              - name
                              - anchor
                              - offsetDays
                              - channel
                              - content
                            additionalProperties: false
                          description: >-
                            The dunning steps of the dunning schedule, ordered
                            by when they send: the issue day first, then by the
                            days from the due date, and the payment last.
                      required:
                        - id
                        - name
                        - isDefault
                        - archivedAt
                        - steps
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''search'' must be string'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role dunning:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/dunning-schedules/settings:
    put:
      summary: Update dunning settings
      tags:
        - Dunning
      description: >-
        Replaces the dunning settings: the reply-to address, the default dunning
        schedule, the logo and the primary color of the dunning e-mails, and
        when they go out. Returns the dunning settings as the fetch of the
        dunning settings does, with the files that the e-mail of a dunning step
        can attach.


        Requires the role `dunning:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                replyTo:
                  type:
                    - 'null'
                    - string
                  format: email
                  description: >-
                    The address that receives the replies to the dunning
                    e-mails. When null, the replies go to the address of the
                    from e-mail, or to an address of Aira when there is no from
                    e-mail.
                  example: financeiro@acme.com
                defaultDunningScheduleId:
                  type:
                    - 'null'
                    - string
                  format: uuid
                  description: >-
                    The id of the default dunning schedule, which a customer
                    follows when its creation leaves out the dunning schedule,
                    or null for none. `PUT /v1/dunning-schedules/settings`
                    refuses an archived dunning schedule, and while the default
                    dunning schedule is archived, a customer whose creation
                    leaves out the dunning schedule follows none.
                logoUrl:
                  type:
                    - 'null'
                    - string
                  pattern: ^$|^https?://[^\s]+$
                  maxLength: 2048
                  description: >-
                    The http or https URL of the logo that the dunning e-mails
                    show, or null for the default logo. `POST
                    /v1/dunning-schedules/settings/logo` uploads a logo and
                    returns its URL.
                  example: https://acme.com/logo.png
                primaryColor:
                  type:
                    - 'null'
                    - string
                  pattern: ^$|^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
                  description: >-
                    The primary color of the dunning e-mails, as a hex code, or
                    null for the default color.
                  example: '#123ABC'
                dispatchWindow:
                  type: string
                  enum:
                    - business_hours
                    - any_time
                  description: >-
                    When the dunning e-mails go out: `business_hours` sends them
                    from Monday to Friday, from 09:00 to 18:00, Brasília time,
                    and `any_time` sends them on any day, Saturdays and Sundays
                    included.
              required:
                - replyTo
                - defaultDunningScheduleId
                - logoUrl
                - primaryColor
                - dispatchWindow
              additionalProperties: false
        required: true
        description: >-
          The dunning settings: the reply-to address, the default dunning
          schedule, the logo and the primary color of the dunning e-mails, and
          when they go out.
      x-public-api: true
      x-errors:
        - status: 400
          code: dunning_schedule_not_assignable
          when: the dunning schedule of the `defaultDunningScheduleId` is archived
        - status: 404
          code: dunning_schedule_not_found
          when: no dunning schedule has the `defaultDunningScheduleId`
      x-required-roles: *ref_30
      responses:
        '200':
          description: >-
            The dunning settings: the reply-to address, the default dunning
            schedule, the logo and the primary color of the dunning e-mails, and
            when they go out.
          content:
            application/json:
              schema:
                type: object
                properties:
                  replyTo:
                    type:
                      - 'null'
                      - string
                    format: email
                    description: >-
                      The address that receives the replies to the dunning
                      e-mails. When null, the replies go to the address of the
                      from e-mail, or to an address of Aira when there is no
                      from e-mail.
                    example: financeiro@acme.com
                  defaultDunningScheduleId:
                    type:
                      - 'null'
                      - string
                    format: uuid
                    description: >-
                      The id of the default dunning schedule, which a customer
                      follows when its creation leaves out the dunning schedule,
                      or null for none. `PUT /v1/dunning-schedules/settings`
                      refuses an archived dunning schedule, and while the
                      default dunning schedule is archived, a customer whose
                      creation leaves out the dunning schedule follows none.
                  logoUrl:
                    type:
                      - 'null'
                      - string
                    pattern: ^$|^https?://[^\s]+$
                    maxLength: 2048
                    description: >-
                      The http or https URL of the logo that the dunning e-mails
                      show, or null for the default logo. `POST
                      /v1/dunning-schedules/settings/logo` uploads a logo and
                      returns its URL.
                    example: https://acme.com/logo.png
                  primaryColor:
                    type:
                      - 'null'
                      - string
                    pattern: ^$|^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
                    description: >-
                      The primary color of the dunning e-mails, as a hex code,
                      or null for the default color.
                    example: '#123ABC'
                  dispatchWindow:
                    type: string
                    enum:
                      - business_hours
                      - any_time
                    description: >-
                      When the dunning e-mails go out: `business_hours` sends
                      them from Monday to Friday, from 09:00 to 18:00, Brasília
                      time, and `any_time` sends them on any day, Saturdays and
                      Sundays included.
                  attachmentOptions:
                    type: object
                    description: >-
                      The files that Aira produces for the invoices, which are
                      the only ones that the e-mail of a dunning step can
                      attach.
                    properties:
                      artifacts:
                        type: array
                        description: The invoice artifacts that Aira generates.
                        items:
                          type: object
                          properties:
                            type:
                              anyOf:
                                - enum:
                                    - default:invoice_pdf
                                - type: string
                                  pattern: ^custom:.+$
                              description: >-
                                The type of the invoice artifact:
                                `default:invoice_pdf` for the invoice PDF, or
                                `custom:*` for an invoice artifact that Aira
                                writes for you.
                            label:
                              type:
                                - 'null'
                                - string
                              description: >-
                                The name of the invoice artifact, or null when
                                it has none.
                              example: Demonstrativo de uso
                          required:
                            - type
                            - label
                          additionalProperties: false
                      paymentFiles:
                        type: boolean
                        description: >-
                          Whether a dunning step can attach the files of the
                          payment of the invoice, which needs the payments
                          module.
                      fiscalDocumentFiles:
                        type: boolean
                        description: >-
                          Whether a dunning step can attach the files of the
                          fiscal document of the invoice, which needs the fiscal
                          invoices module.
                      invoiceAttachmentFiles:
                        type: boolean
                        description: >-
                          Whether a dunning step can attach the invoice
                          attachments.
                    required:
                      - artifacts
                      - paymentFiles
                      - fiscalDocumentFiles
                      - invoiceAttachmentFiles
                    additionalProperties: false
                required:
                  - replyTo
                  - defaultDunningScheduleId
                  - logoUrl
                  - primaryColor
                  - dispatchWindow
                  - attachmentOptions
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `dunning_schedule_not_assignable`: the dunning schedule of the
            `defaultDunningScheduleId` is archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - dunning_schedule_not_assignable
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''replyTo'' is required'
                    code: json_schema_validation_error
                dunning_schedule_not_assignable:
                  value:
                    message: cannot assign an archived dunning schedule
                    code: dunning_schedule_not_assignable
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role dunning:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: >-
            A record that the request names does not exist.


            - `dunning_schedule_not_found`: no dunning schedule has the
            `defaultDunningScheduleId`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - dunning_schedule_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                dunning_schedule_not_found:
                  value:
                    message: dunning schedule not found
                    code: dunning_schedule_not_found
    get:
      summary: Fetch dunning settings
      tags:
        - Dunning
      description: >-
        Returns the dunning settings, with the files that Aira produces for the
        invoices, which are the only ones that the e-mail of a dunning step can
        attach.


        Requires the role `dunning:read`.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: *ref_31
      responses:
        '200':
          description: >-
            The dunning settings: the reply-to address, the default dunning
            schedule, the logo and the primary color of the dunning e-mails, and
            when they go out.
          content:
            application/json:
              schema:
                type: object
                properties:
                  replyTo:
                    type:
                      - 'null'
                      - string
                    format: email
                    description: >-
                      The address that receives the replies to the dunning
                      e-mails. When null, the replies go to the address of the
                      from e-mail, or to an address of Aira when there is no
                      from e-mail.
                    example: financeiro@acme.com
                  defaultDunningScheduleId:
                    type:
                      - 'null'
                      - string
                    format: uuid
                    description: >-
                      The id of the default dunning schedule, which a customer
                      follows when its creation leaves out the dunning schedule,
                      or null for none. `PUT /v1/dunning-schedules/settings`
                      refuses an archived dunning schedule, and while the
                      default dunning schedule is archived, a customer whose
                      creation leaves out the dunning schedule follows none.
                  logoUrl:
                    type:
                      - 'null'
                      - string
                    pattern: ^$|^https?://[^\s]+$
                    maxLength: 2048
                    description: >-
                      The http or https URL of the logo that the dunning e-mails
                      show, or null for the default logo. `POST
                      /v1/dunning-schedules/settings/logo` uploads a logo and
                      returns its URL.
                    example: https://acme.com/logo.png
                  primaryColor:
                    type:
                      - 'null'
                      - string
                    pattern: ^$|^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$
                    description: >-
                      The primary color of the dunning e-mails, as a hex code,
                      or null for the default color.
                    example: '#123ABC'
                  dispatchWindow:
                    type: string
                    enum:
                      - business_hours
                      - any_time
                    description: >-
                      When the dunning e-mails go out: `business_hours` sends
                      them from Monday to Friday, from 09:00 to 18:00, Brasília
                      time, and `any_time` sends them on any day, Saturdays and
                      Sundays included.
                  attachmentOptions:
                    type: object
                    description: >-
                      The files that Aira produces for the invoices, which are
                      the only ones that the e-mail of a dunning step can
                      attach.
                    properties:
                      artifacts:
                        type: array
                        description: The invoice artifacts that Aira generates.
                        items:
                          type: object
                          properties:
                            type:
                              anyOf:
                                - enum:
                                    - default:invoice_pdf
                                - type: string
                                  pattern: ^custom:.+$
                              description: >-
                                The type of the invoice artifact:
                                `default:invoice_pdf` for the invoice PDF, or
                                `custom:*` for an invoice artifact that Aira
                                writes for you.
                            label:
                              type:
                                - 'null'
                                - string
                              description: >-
                                The name of the invoice artifact, or null when
                                it has none.
                              example: Demonstrativo de uso
                          required:
                            - type
                            - label
                          additionalProperties: false
                      paymentFiles:
                        type: boolean
                        description: >-
                          Whether a dunning step can attach the files of the
                          payment of the invoice, which needs the payments
                          module.
                      fiscalDocumentFiles:
                        type: boolean
                        description: >-
                          Whether a dunning step can attach the files of the
                          fiscal document of the invoice, which needs the fiscal
                          invoices module.
                      invoiceAttachmentFiles:
                        type: boolean
                        description: >-
                          Whether a dunning step can attach the invoice
                          attachments.
                    required:
                      - artifacts
                      - paymentFiles
                      - fiscalDocumentFiles
                      - invoiceAttachmentFiles
                    additionalProperties: false
                required:
                  - replyTo
                  - defaultDunningScheduleId
                  - logoUrl
                  - primaryColor
                  - dispatchWindow
                  - attachmentOptions
                additionalProperties: false
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role dunning:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/dunning-schedules/settings/logo:
    post:
      summary: Upload dunning e-mail logo
      tags:
        - Dunning
      description: >-
        Uploads the logo of the dunning e-mails, a PNG or JPEG file of up to 512
        KB in the first file field of a multipart form, and returns its public
        URL. The URL is permanent, and the logo shows in the dunning e-mails
        once `PUT /v1/dunning-schedules/settings` saves it as the `logoUrl` of
        the dunning settings.


        Requires the role `dunning:write`.
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              nullable: true
              properties:
                file:
                  type: string
                  format: binary
                  description: >-
                    The logo of the dunning e-mails, a PNG or JPEG file of up to
                    512 KB.
              required:
                - file
              additionalProperties: false
        required: true
        description: A multipart form with the logo file.
      x-public-api: true
      x-errors:
        - status: 400
          code: file_not_provided
          when: the form carries no file, or an empty file
        - status: 400
          code: unsupported_file_type
          when: the file is neither a PNG nor a JPEG image
      x-required-roles: *ref_30
      responses:
        '201':
          description: The URL of the uploaded logo.
          content:
            application/json:
              schema:
                type: object
                properties:
                  logoUrl:
                    type: string
                    description: >-
                      The public and permanent URL of the uploaded logo. `PUT
                      /v1/dunning-schedules/settings` takes it as the `logoUrl`
                      of the dunning settings.
                    example: >-
                      https://assets.useaira.com/3c90c3cc-0d44-4b50-8888-8dd25736052a.png
                required:
                  - logoUrl
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `file_not_provided`: the form carries no file, or an empty file.

            - `unsupported_file_type`: the file is neither a PNG nor a JPEG
            image.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - file_not_provided
                      - unsupported_file_type
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''file'' is required'
                    code: json_schema_validation_error
                file_not_provided:
                  value:
                    message: file not provided
                    code: file_not_provided
                unsupported_file_type:
                  value:
                    message: logo must be a PNG or JPEG image
                    code: unsupported_file_type
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role dunning:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '413':
          description: >-
            A file or the body of the request is larger than its limit.


            - `file_too_large`: a file of the form is larger than the limit of
            the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - file_too_large
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                file_too_large:
                  value:
                    message: a file of the request is larger than the limit
                    code: file_too_large
  /v1/dunning-schedules/{id}:
    put:
      summary: Update dunning schedule
      tags:
        - Dunning
      description: >-
        Replaces the name and the dunning steps of a dunning schedule. When
        `isDefault` is true, the dunning schedule becomes the default one, and
        when it is false, the dunning schedule stops being the default. Each
        dunning step with the id of one of its dunning steps changes that
        dunning step, each dunning step without an id adds a dunning step, and
        the update removes each dunning step that the body leaves out. The
        dunning runs of the dunning schedule then follow the changed dunning
        steps.


        Requires the role `dunning:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  minLength: 1
                  description: The name of the dunning schedule.
                  example: Régua padrão
                isDefault:
                  type: boolean
                  description: >-
                    Whether the dunning schedule is the default one, which a
                    customer follows when its creation leaves out the dunning
                    schedule. At most one dunning schedule is the default, and
                    an archived dunning schedule is never the default.
                steps:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    description: >-
                      A dunning step: one e-mail of a dunning schedule, sent on
                      the issue day, on the due date, a number of days before or
                      after the due date, or after the payment. A dunning step
                      goes out inside the `dispatchWindow` of the dunning
                      settings, so with `business_hours` a dunning step whose
                      day falls on a Saturday or a Sunday goes out at 09:00 of
                      the next Monday.
                    properties:
                      name:
                        type: string
                        minLength: 1
                        description: The name of the dunning step.
                        example: Lembrete de vencimento
                      anchor:
                        type: string
                        enum:
                          - issued
                          - on_due_date
                          - due_date
                          - on_payment_confirmation
                        description: >-
                          When the dunning step sends its e-mail: `issued` on
                          the issue day of the invoice, `on_due_date` on its due
                          date, `due_date` the number of days in `offsetDays`
                          from its due date, and `on_payment_confirmation` after
                          Aira records its payment.
                      offsetDays:
                        type:
                          - 'null'
                          - integer
                        description: >-
                          The number of days from the due date on which a
                          `due_date` step sends, after the due date when
                          positive and before it when negative. It is null for
                          every other anchor.
                        example: 5
                      channel:
                        type: string
                        enum:
                          - email
                        description: >-
                          The channel through which the dunning step reaches the
                          invoice recipients.
                      content:
                        type: object
                        description: >-
                          The e-mail that the dunning step sends. The subject,
                          the title and the body can hold variables in double
                          braces, such as `{{ invoiceNumber }}`, `{{ dueDate }}`
                          or `{{ paymentLink }}`, which Aira fills in for each
                          invoice.
                        properties:
                          subject:
                            type: string
                            minLength: 1
                            description: The subject of the e-mail.
                            example: Sua fatura {{ invoiceNumber }}
                          title:
                            type: string
                            minLength: 1
                            description: The title that the e-mail shows above its body.
                            example: Sua fatura está disponível!
                          body:
                            type: string
                            minLength: 1
                            description: The text of the e-mail.
                            example: >-
                              Olá {{ billingAccountBusinessName }}, sua fatura
                              vence em {{ dueDate }}.
                          attachments:
                            type: object
                            description: >-
                              The files that the e-mail of the dunning step
                              attaches. A dunning step can attach only the files
                              that the `attachmentOptions` of the dunning
                              settings list.
                            properties:
                              artifacts:
                                type: array
                                description: >-
                                  The invoice artifacts that the e-mail
                                  attaches.
                                items:
                                  type: object
                                  properties:
                                    type:
                                      anyOf:
                                        - enum:
                                            - default:invoice_pdf
                                        - type: string
                                          pattern: ^custom:.+$
                                      description: >-
                                        The type of the invoice artifact:
                                        `default:invoice_pdf` for the invoice
                                        PDF, or `custom:*` for an invoice
                                        artifact that Aira writes for you.
                                  required:
                                    - type
                                  additionalProperties: false
                              paymentFiles:
                                type: boolean
                                description: >-
                                  Whether the e-mail attaches the files of the
                                  payment of the invoice: the boleto, the Pix
                                  file or both, as the payment method of its
                                  contract produces. A dunning step that sends
                                  after the payment cannot attach them.
                              fiscalDocumentFiles:
                                type: boolean
                                description: >-
                                  Whether the e-mail attaches the PDF and the
                                  XML of the fiscal document of the invoice.
                              invoiceAttachmentFiles:
                                type: boolean
                                description: >-
                                  Whether the e-mail attaches the invoice
                                  attachments that a user or a system marked to
                                  go out with the invoice.
                            required:
                              - artifacts
                              - paymentFiles
                              - fiscalDocumentFiles
                              - invoiceAttachmentFiles
                            additionalProperties: false
                        required:
                          - subject
                          - title
                          - body
                          - attachments
                        additionalProperties: false
                      id:
                        type: string
                        format: uuid
                        description: >-
                          The id of a dunning step of this dunning schedule, to
                          keep and change that dunning step. Leave it out to add
                          a dunning step.
                    required:
                      - name
                      - anchor
                      - offsetDays
                      - channel
                      - content
                    additionalProperties: false
                  description: >-
                    All the dunning steps of the dunning schedule, at least one.
                    Each dunning step of the dunning schedule that the list
                    leaves out is removed.
              required:
                - name
                - isDefault
                - steps
              additionalProperties: false
        required: true
        description: The dunning schedule with all its dunning steps.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the dunning schedule in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: dunning_step_invalid
          when: >-
            a `due_date` dunning step has no `offsetDays`, a dunning step of
            another anchor has one, a dunning step attaches a file that the
            `attachmentOptions` of the dunning settings do not list, an
            `on_payment_confirmation` dunning step attaches the files of the
            payment, or a dunning step has an `id` that is not the id of a
            dunning step of the dunning schedule
        - status: 400
          code: dunning_schedule_archived
          when: the dunning schedule is archived
        - status: 404
          code: dunning_schedule_not_found
          when: no dunning schedule has the `id`
      x-required-roles: *ref_30
      responses:
        '200':
          description: >-
            A dunning schedule: the sequence of e-mails about an invoice, from
            its issue to after its due date, and after its payment. Each
            customer follows at most one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the dunning schedule in our
                      system.
                  name:
                    type: string
                    minLength: 1
                    description: The name of the dunning schedule.
                    example: Régua padrão
                  isDefault:
                    type: boolean
                    description: >-
                      Whether the dunning schedule is the default one, which a
                      customer follows when its creation leaves out the dunning
                      schedule. At most one dunning schedule is the default, and
                      an archived dunning schedule is never the default.
                  archivedAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      The timestamp when the dunning schedule was archived, or
                      null if not archived. An archived dunning schedule cannot
                      be changed or assigned to a customer.
                  steps:
                    type: array
                    items:
                      type: object
                      description: >-
                        A dunning step: one e-mail of a dunning schedule, sent
                        on the issue day, on the due date, a number of days
                        before or after the due date, or after the payment. A
                        dunning step goes out inside the `dispatchWindow` of the
                        dunning settings, so with `business_hours` a dunning
                        step whose day falls on a Saturday or a Sunday goes out
                        at 09:00 of the next Monday.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the dunning step in our
                            system.
                        name:
                          type: string
                          minLength: 1
                          description: The name of the dunning step.
                          example: Lembrete de vencimento
                        anchor:
                          type: string
                          enum:
                            - issued
                            - on_due_date
                            - due_date
                            - on_payment_confirmation
                          description: >-
                            When the dunning step sends its e-mail: `issued` on
                            the issue day of the invoice, `on_due_date` on its
                            due date, `due_date` the number of days in
                            `offsetDays` from its due date, and
                            `on_payment_confirmation` after Aira records its
                            payment.
                        offsetDays:
                          type:
                            - 'null'
                            - integer
                          description: >-
                            The number of days from the due date on which a
                            `due_date` step sends, after the due date when
                            positive and before it when negative. It is null for
                            every other anchor.
                          example: 5
                        channel:
                          type: string
                          enum:
                            - email
                          description: >-
                            The channel through which the dunning step reaches
                            the invoice recipients.
                        content:
                          type: object
                          description: >-
                            The e-mail that the dunning step sends. The subject,
                            the title and the body can hold variables in double
                            braces, such as `{{ invoiceNumber }}`, `{{ dueDate
                            }}` or `{{ paymentLink }}`, which Aira fills in for
                            each invoice.
                          properties:
                            subject:
                              type: string
                              minLength: 1
                              description: The subject of the e-mail.
                              example: Sua fatura {{ invoiceNumber }}
                            title:
                              type: string
                              minLength: 1
                              description: The title that the e-mail shows above its body.
                              example: Sua fatura está disponível!
                            body:
                              type: string
                              minLength: 1
                              description: The text of the e-mail.
                              example: >-
                                Olá {{ billingAccountBusinessName }}, sua fatura
                                vence em {{ dueDate }}.
                            attachments:
                              type: object
                              description: >-
                                The files that the e-mail of the dunning step
                                attaches. A dunning step can attach only the
                                files that the `attachmentOptions` of the
                                dunning settings list.
                              properties:
                                artifacts:
                                  type: array
                                  description: >-
                                    The invoice artifacts that the e-mail
                                    attaches.
                                  items:
                                    type: object
                                    properties:
                                      type:
                                        anyOf:
                                          - enum:
                                              - default:invoice_pdf
                                          - type: string
                                            pattern: ^custom:.+$
                                        description: >-
                                          The type of the invoice artifact:
                                          `default:invoice_pdf` for the invoice
                                          PDF, or `custom:*` for an invoice
                                          artifact that Aira writes for you.
                                    required:
                                      - type
                                    additionalProperties: false
                                paymentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the files of the
                                    payment of the invoice: the boleto, the Pix
                                    file or both, as the payment method of its
                                    contract produces. A dunning step that sends
                                    after the payment cannot attach them.
                                fiscalDocumentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the PDF and the
                                    XML of the fiscal document of the invoice.
                                invoiceAttachmentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the invoice
                                    attachments that a user or a system marked
                                    to go out with the invoice.
                              required:
                                - artifacts
                                - paymentFiles
                                - fiscalDocumentFiles
                                - invoiceAttachmentFiles
                              additionalProperties: false
                          required:
                            - subject
                            - title
                            - body
                            - attachments
                          additionalProperties: false
                      required:
                        - id
                        - name
                        - anchor
                        - offsetDays
                        - channel
                        - content
                      additionalProperties: false
                    description: >-
                      The dunning steps of the dunning schedule, ordered by when
                      they send: the issue day first, then by the days from the
                      due date, and the payment last.
                required:
                  - id
                  - name
                  - isDefault
                  - archivedAt
                  - steps
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `dunning_step_invalid`: a `due_date` dunning step has no
            `offsetDays`, a dunning step of another anchor has one, a dunning
            step attaches a file that the `attachmentOptions` of the dunning
            settings do not list, an `on_payment_confirmation` dunning step
            attaches the files of the payment, or a dunning step has an `id`
            that is not the id of a dunning step of the dunning schedule.

            - `dunning_schedule_archived`: the dunning schedule is archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - dunning_step_invalid
                      - dunning_schedule_archived
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''name'' is required'
                    code: json_schema_validation_error
                dunning_step_invalid:
                  value:
                    message: >-
                      step "{name}" asks for an attachment that Aira does not
                      produce for the invoices
                    code: dunning_step_invalid
                dunning_schedule_archived:
                  value:
                    message: cannot update an archived schedule
                    code: dunning_schedule_archived
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role dunning:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `dunning_schedule_not_found`: no dunning schedule has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - dunning_schedule_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                dunning_schedule_not_found:
                  value:
                    message: dunning schedule not found
                    code: dunning_schedule_not_found
    delete:
      summary: Delete dunning schedule
      tags:
        - Dunning
      description: |-
        Deletes a dunning schedule that was never used, with its dunning steps.

        Requires the role `dunning:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the dunning schedule in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: dunning_schedule_not_found
          when: no dunning schedule has the `id`
        - status: 409
          code: dunning_schedule_used
          when: >-
            a customer follows the dunning schedule, or one of its dunning steps
            already sent an e-mail
      x-required-roles: *ref_30
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role dunning:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `dunning_schedule_not_found`: no dunning schedule has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - dunning_schedule_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                dunning_schedule_not_found:
                  value:
                    message: dunning schedule not found
                    code: dunning_schedule_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `dunning_schedule_used`: a customer follows the dunning schedule,
            or one of its dunning steps already sent an e-mail.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - dunning_schedule_used
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                dunning_schedule_used:
                  value:
                    message: >-
                      dunning schedule has been used and can only be archived,
                      not deleted
                    code: dunning_schedule_used
    get:
      summary: Fetch dunning schedule
      tags:
        - Dunning
      description: >-
        Returns a dunning schedule by id, archived or not, with its dunning
        steps.


        Requires the role `dunning:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the dunning schedule in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: dunning_schedule_not_found
          when: no dunning schedule has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_31
      responses:
        '200':
          description: >-
            A dunning schedule: the sequence of e-mails about an invoice, from
            its issue to after its due date, and after its payment. Each
            customer follows at most one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the dunning schedule in our
                      system.
                  name:
                    type: string
                    minLength: 1
                    description: The name of the dunning schedule.
                    example: Régua padrão
                  isDefault:
                    type: boolean
                    description: >-
                      Whether the dunning schedule is the default one, which a
                      customer follows when its creation leaves out the dunning
                      schedule. At most one dunning schedule is the default, and
                      an archived dunning schedule is never the default.
                  archivedAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      The timestamp when the dunning schedule was archived, or
                      null if not archived. An archived dunning schedule cannot
                      be changed or assigned to a customer.
                  steps:
                    type: array
                    items:
                      type: object
                      description: >-
                        A dunning step: one e-mail of a dunning schedule, sent
                        on the issue day, on the due date, a number of days
                        before or after the due date, or after the payment. A
                        dunning step goes out inside the `dispatchWindow` of the
                        dunning settings, so with `business_hours` a dunning
                        step whose day falls on a Saturday or a Sunday goes out
                        at 09:00 of the next Monday.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the dunning step in our
                            system.
                        name:
                          type: string
                          minLength: 1
                          description: The name of the dunning step.
                          example: Lembrete de vencimento
                        anchor:
                          type: string
                          enum:
                            - issued
                            - on_due_date
                            - due_date
                            - on_payment_confirmation
                          description: >-
                            When the dunning step sends its e-mail: `issued` on
                            the issue day of the invoice, `on_due_date` on its
                            due date, `due_date` the number of days in
                            `offsetDays` from its due date, and
                            `on_payment_confirmation` after Aira records its
                            payment.
                        offsetDays:
                          type:
                            - 'null'
                            - integer
                          description: >-
                            The number of days from the due date on which a
                            `due_date` step sends, after the due date when
                            positive and before it when negative. It is null for
                            every other anchor.
                          example: 5
                        channel:
                          type: string
                          enum:
                            - email
                          description: >-
                            The channel through which the dunning step reaches
                            the invoice recipients.
                        content:
                          type: object
                          description: >-
                            The e-mail that the dunning step sends. The subject,
                            the title and the body can hold variables in double
                            braces, such as `{{ invoiceNumber }}`, `{{ dueDate
                            }}` or `{{ paymentLink }}`, which Aira fills in for
                            each invoice.
                          properties:
                            subject:
                              type: string
                              minLength: 1
                              description: The subject of the e-mail.
                              example: Sua fatura {{ invoiceNumber }}
                            title:
                              type: string
                              minLength: 1
                              description: The title that the e-mail shows above its body.
                              example: Sua fatura está disponível!
                            body:
                              type: string
                              minLength: 1
                              description: The text of the e-mail.
                              example: >-
                                Olá {{ billingAccountBusinessName }}, sua fatura
                                vence em {{ dueDate }}.
                            attachments:
                              type: object
                              description: >-
                                The files that the e-mail of the dunning step
                                attaches. A dunning step can attach only the
                                files that the `attachmentOptions` of the
                                dunning settings list.
                              properties:
                                artifacts:
                                  type: array
                                  description: >-
                                    The invoice artifacts that the e-mail
                                    attaches.
                                  items:
                                    type: object
                                    properties:
                                      type:
                                        anyOf:
                                          - enum:
                                              - default:invoice_pdf
                                          - type: string
                                            pattern: ^custom:.+$
                                        description: >-
                                          The type of the invoice artifact:
                                          `default:invoice_pdf` for the invoice
                                          PDF, or `custom:*` for an invoice
                                          artifact that Aira writes for you.
                                    required:
                                      - type
                                    additionalProperties: false
                                paymentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the files of the
                                    payment of the invoice: the boleto, the Pix
                                    file or both, as the payment method of its
                                    contract produces. A dunning step that sends
                                    after the payment cannot attach them.
                                fiscalDocumentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the PDF and the
                                    XML of the fiscal document of the invoice.
                                invoiceAttachmentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the invoice
                                    attachments that a user or a system marked
                                    to go out with the invoice.
                              required:
                                - artifacts
                                - paymentFiles
                                - fiscalDocumentFiles
                                - invoiceAttachmentFiles
                              additionalProperties: false
                          required:
                            - subject
                            - title
                            - body
                            - attachments
                          additionalProperties: false
                      required:
                        - id
                        - name
                        - anchor
                        - offsetDays
                        - channel
                        - content
                      additionalProperties: false
                    description: >-
                      The dunning steps of the dunning schedule, ordered by when
                      they send: the issue day first, then by the days from the
                      due date, and the payment last.
                required:
                  - id
                  - name
                  - isDefault
                  - archivedAt
                  - steps
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role dunning:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `dunning_schedule_not_found`: no dunning schedule has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - dunning_schedule_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                dunning_schedule_not_found:
                  value:
                    message: dunning schedule not found
                    code: dunning_schedule_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/dunning-schedules/{id}/archive:
    post:
      summary: Archive dunning schedule
      tags:
        - Dunning
      description: >-
        Archives a dunning schedule, so that `GET /v1/dunning-schedules` lists
        it only when `includeArchived` is true, and it cannot be changed or
        assigned to a customer.


        Requires the role `dunning:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the dunning schedule in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: dunning_schedule_already_archived
          when: the dunning schedule is already archived
        - status: 404
          code: dunning_schedule_not_found
          when: no dunning schedule has the `id`
        - status: 409
          code: dunning_schedule_in_use
          when: >-
            a customer follows the dunning schedule, or a dunning run of it
            still has an e-mail to send
      x-required-roles: *ref_30
      responses:
        '200':
          description: >-
            A dunning schedule: the sequence of e-mails about an invoice, from
            its issue to after its due date, and after its payment. Each
            customer follows at most one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the dunning schedule in our
                      system.
                  name:
                    type: string
                    minLength: 1
                    description: The name of the dunning schedule.
                    example: Régua padrão
                  isDefault:
                    type: boolean
                    description: >-
                      Whether the dunning schedule is the default one, which a
                      customer follows when its creation leaves out the dunning
                      schedule. At most one dunning schedule is the default, and
                      an archived dunning schedule is never the default.
                  archivedAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      The timestamp when the dunning schedule was archived, or
                      null if not archived. An archived dunning schedule cannot
                      be changed or assigned to a customer.
                  steps:
                    type: array
                    items:
                      type: object
                      description: >-
                        A dunning step: one e-mail of a dunning schedule, sent
                        on the issue day, on the due date, a number of days
                        before or after the due date, or after the payment. A
                        dunning step goes out inside the `dispatchWindow` of the
                        dunning settings, so with `business_hours` a dunning
                        step whose day falls on a Saturday or a Sunday goes out
                        at 09:00 of the next Monday.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the dunning step in our
                            system.
                        name:
                          type: string
                          minLength: 1
                          description: The name of the dunning step.
                          example: Lembrete de vencimento
                        anchor:
                          type: string
                          enum:
                            - issued
                            - on_due_date
                            - due_date
                            - on_payment_confirmation
                          description: >-
                            When the dunning step sends its e-mail: `issued` on
                            the issue day of the invoice, `on_due_date` on its
                            due date, `due_date` the number of days in
                            `offsetDays` from its due date, and
                            `on_payment_confirmation` after Aira records its
                            payment.
                        offsetDays:
                          type:
                            - 'null'
                            - integer
                          description: >-
                            The number of days from the due date on which a
                            `due_date` step sends, after the due date when
                            positive and before it when negative. It is null for
                            every other anchor.
                          example: 5
                        channel:
                          type: string
                          enum:
                            - email
                          description: >-
                            The channel through which the dunning step reaches
                            the invoice recipients.
                        content:
                          type: object
                          description: >-
                            The e-mail that the dunning step sends. The subject,
                            the title and the body can hold variables in double
                            braces, such as `{{ invoiceNumber }}`, `{{ dueDate
                            }}` or `{{ paymentLink }}`, which Aira fills in for
                            each invoice.
                          properties:
                            subject:
                              type: string
                              minLength: 1
                              description: The subject of the e-mail.
                              example: Sua fatura {{ invoiceNumber }}
                            title:
                              type: string
                              minLength: 1
                              description: The title that the e-mail shows above its body.
                              example: Sua fatura está disponível!
                            body:
                              type: string
                              minLength: 1
                              description: The text of the e-mail.
                              example: >-
                                Olá {{ billingAccountBusinessName }}, sua fatura
                                vence em {{ dueDate }}.
                            attachments:
                              type: object
                              description: >-
                                The files that the e-mail of the dunning step
                                attaches. A dunning step can attach only the
                                files that the `attachmentOptions` of the
                                dunning settings list.
                              properties:
                                artifacts:
                                  type: array
                                  description: >-
                                    The invoice artifacts that the e-mail
                                    attaches.
                                  items:
                                    type: object
                                    properties:
                                      type:
                                        anyOf:
                                          - enum:
                                              - default:invoice_pdf
                                          - type: string
                                            pattern: ^custom:.+$
                                        description: >-
                                          The type of the invoice artifact:
                                          `default:invoice_pdf` for the invoice
                                          PDF, or `custom:*` for an invoice
                                          artifact that Aira writes for you.
                                    required:
                                      - type
                                    additionalProperties: false
                                paymentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the files of the
                                    payment of the invoice: the boleto, the Pix
                                    file or both, as the payment method of its
                                    contract produces. A dunning step that sends
                                    after the payment cannot attach them.
                                fiscalDocumentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the PDF and the
                                    XML of the fiscal document of the invoice.
                                invoiceAttachmentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the invoice
                                    attachments that a user or a system marked
                                    to go out with the invoice.
                              required:
                                - artifacts
                                - paymentFiles
                                - fiscalDocumentFiles
                                - invoiceAttachmentFiles
                              additionalProperties: false
                          required:
                            - subject
                            - title
                            - body
                            - attachments
                          additionalProperties: false
                      required:
                        - id
                        - name
                        - anchor
                        - offsetDays
                        - channel
                        - content
                      additionalProperties: false
                    description: >-
                      The dunning steps of the dunning schedule, ordered by when
                      they send: the issue day first, then by the days from the
                      due date, and the payment last.
                required:
                  - id
                  - name
                  - isDefault
                  - archivedAt
                  - steps
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `dunning_schedule_already_archived`: the dunning schedule is
            already archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - dunning_schedule_already_archived
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                dunning_schedule_already_archived:
                  value:
                    message: dunning schedule already archived
                    code: dunning_schedule_already_archived
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role dunning:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `dunning_schedule_not_found`: no dunning schedule has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - dunning_schedule_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                dunning_schedule_not_found:
                  value:
                    message: dunning schedule not found
                    code: dunning_schedule_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `dunning_schedule_in_use`: a customer follows the dunning
            schedule, or a dunning run of it still has an e-mail to send.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - dunning_schedule_in_use
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                dunning_schedule_in_use:
                  value:
                    message: >-
                      dunning schedule is assigned to a customer or has
                      in-flight runs
                    code: dunning_schedule_in_use
  /v1/dunning-schedules/{id}/unarchive:
    post:
      summary: Unarchive dunning schedule
      tags:
        - Dunning
      description: >-
        Unarchives a dunning schedule, so that it can be changed and assigned to
        a customer again.


        Requires the role `dunning:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the dunning schedule in our system.
      x-public-api: true
      x-errors:
        - status: 400
          code: dunning_schedule_not_archived
          when: the dunning schedule is not archived
        - status: 404
          code: dunning_schedule_not_found
          when: no dunning schedule has the `id`
      x-required-roles: *ref_30
      responses:
        '200':
          description: >-
            A dunning schedule: the sequence of e-mails about an invoice, from
            its issue to after its due date, and after its payment. Each
            customer follows at most one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the dunning schedule in our
                      system.
                  name:
                    type: string
                    minLength: 1
                    description: The name of the dunning schedule.
                    example: Régua padrão
                  isDefault:
                    type: boolean
                    description: >-
                      Whether the dunning schedule is the default one, which a
                      customer follows when its creation leaves out the dunning
                      schedule. At most one dunning schedule is the default, and
                      an archived dunning schedule is never the default.
                  archivedAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      The timestamp when the dunning schedule was archived, or
                      null if not archived. An archived dunning schedule cannot
                      be changed or assigned to a customer.
                  steps:
                    type: array
                    items:
                      type: object
                      description: >-
                        A dunning step: one e-mail of a dunning schedule, sent
                        on the issue day, on the due date, a number of days
                        before or after the due date, or after the payment. A
                        dunning step goes out inside the `dispatchWindow` of the
                        dunning settings, so with `business_hours` a dunning
                        step whose day falls on a Saturday or a Sunday goes out
                        at 09:00 of the next Monday.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the dunning step in our
                            system.
                        name:
                          type: string
                          minLength: 1
                          description: The name of the dunning step.
                          example: Lembrete de vencimento
                        anchor:
                          type: string
                          enum:
                            - issued
                            - on_due_date
                            - due_date
                            - on_payment_confirmation
                          description: >-
                            When the dunning step sends its e-mail: `issued` on
                            the issue day of the invoice, `on_due_date` on its
                            due date, `due_date` the number of days in
                            `offsetDays` from its due date, and
                            `on_payment_confirmation` after Aira records its
                            payment.
                        offsetDays:
                          type:
                            - 'null'
                            - integer
                          description: >-
                            The number of days from the due date on which a
                            `due_date` step sends, after the due date when
                            positive and before it when negative. It is null for
                            every other anchor.
                          example: 5
                        channel:
                          type: string
                          enum:
                            - email
                          description: >-
                            The channel through which the dunning step reaches
                            the invoice recipients.
                        content:
                          type: object
                          description: >-
                            The e-mail that the dunning step sends. The subject,
                            the title and the body can hold variables in double
                            braces, such as `{{ invoiceNumber }}`, `{{ dueDate
                            }}` or `{{ paymentLink }}`, which Aira fills in for
                            each invoice.
                          properties:
                            subject:
                              type: string
                              minLength: 1
                              description: The subject of the e-mail.
                              example: Sua fatura {{ invoiceNumber }}
                            title:
                              type: string
                              minLength: 1
                              description: The title that the e-mail shows above its body.
                              example: Sua fatura está disponível!
                            body:
                              type: string
                              minLength: 1
                              description: The text of the e-mail.
                              example: >-
                                Olá {{ billingAccountBusinessName }}, sua fatura
                                vence em {{ dueDate }}.
                            attachments:
                              type: object
                              description: >-
                                The files that the e-mail of the dunning step
                                attaches. A dunning step can attach only the
                                files that the `attachmentOptions` of the
                                dunning settings list.
                              properties:
                                artifacts:
                                  type: array
                                  description: >-
                                    The invoice artifacts that the e-mail
                                    attaches.
                                  items:
                                    type: object
                                    properties:
                                      type:
                                        anyOf:
                                          - enum:
                                              - default:invoice_pdf
                                          - type: string
                                            pattern: ^custom:.+$
                                        description: >-
                                          The type of the invoice artifact:
                                          `default:invoice_pdf` for the invoice
                                          PDF, or `custom:*` for an invoice
                                          artifact that Aira writes for you.
                                    required:
                                      - type
                                    additionalProperties: false
                                paymentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the files of the
                                    payment of the invoice: the boleto, the Pix
                                    file or both, as the payment method of its
                                    contract produces. A dunning step that sends
                                    after the payment cannot attach them.
                                fiscalDocumentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the PDF and the
                                    XML of the fiscal document of the invoice.
                                invoiceAttachmentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the invoice
                                    attachments that a user or a system marked
                                    to go out with the invoice.
                              required:
                                - artifacts
                                - paymentFiles
                                - fiscalDocumentFiles
                                - invoiceAttachmentFiles
                              additionalProperties: false
                          required:
                            - subject
                            - title
                            - body
                            - attachments
                          additionalProperties: false
                      required:
                        - id
                        - name
                        - anchor
                        - offsetDays
                        - channel
                        - content
                      additionalProperties: false
                    description: >-
                      The dunning steps of the dunning schedule, ordered by when
                      they send: the issue day first, then by the days from the
                      due date, and the payment last.
                required:
                  - id
                  - name
                  - isDefault
                  - archivedAt
                  - steps
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `dunning_schedule_not_archived`: the dunning schedule is not
            archived.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - dunning_schedule_not_archived
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                dunning_schedule_not_archived:
                  value:
                    message: dunning schedule is not archived
                    code: dunning_schedule_not_archived
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role dunning:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `dunning_schedule_not_found`: no dunning schedule has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - dunning_schedule_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                dunning_schedule_not_found:
                  value:
                    message: dunning schedule not found
                    code: dunning_schedule_not_found
  /v1/dunning-schedules/{id}/duplicate:
    post:
      summary: Duplicate dunning schedule
      tags:
        - Dunning
      description: >-
        Creates a copy of a dunning schedule, archived or not, with its dunning
        steps, named "Copy of" and the name of the dunning schedule. The copy is
        not the default dunning schedule, and its dunning steps leave out the
        files that the `attachmentOptions` of the dunning settings no longer
        list.


        Requires the role `dunning:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the dunning schedule in our system.
      x-public-api: true
      x-errors:
        - status: 404
          code: dunning_schedule_not_found
          when: no dunning schedule has the `id`
      x-required-roles: *ref_30
      responses:
        '201':
          description: >-
            A dunning schedule: the sequence of e-mails about an invoice, from
            its issue to after its due date, and after its payment. Each
            customer follows at most one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: >-
                      The unique identifier of the dunning schedule in our
                      system.
                  name:
                    type: string
                    minLength: 1
                    description: The name of the dunning schedule.
                    example: Régua padrão
                  isDefault:
                    type: boolean
                    description: >-
                      Whether the dunning schedule is the default one, which a
                      customer follows when its creation leaves out the dunning
                      schedule. At most one dunning schedule is the default, and
                      an archived dunning schedule is never the default.
                  archivedAt:
                    type:
                      - 'null'
                      - string
                    format: date-time
                    description: >-
                      The timestamp when the dunning schedule was archived, or
                      null if not archived. An archived dunning schedule cannot
                      be changed or assigned to a customer.
                  steps:
                    type: array
                    items:
                      type: object
                      description: >-
                        A dunning step: one e-mail of a dunning schedule, sent
                        on the issue day, on the due date, a number of days
                        before or after the due date, or after the payment. A
                        dunning step goes out inside the `dispatchWindow` of the
                        dunning settings, so with `business_hours` a dunning
                        step whose day falls on a Saturday or a Sunday goes out
                        at 09:00 of the next Monday.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: >-
                            The unique identifier of the dunning step in our
                            system.
                        name:
                          type: string
                          minLength: 1
                          description: The name of the dunning step.
                          example: Lembrete de vencimento
                        anchor:
                          type: string
                          enum:
                            - issued
                            - on_due_date
                            - due_date
                            - on_payment_confirmation
                          description: >-
                            When the dunning step sends its e-mail: `issued` on
                            the issue day of the invoice, `on_due_date` on its
                            due date, `due_date` the number of days in
                            `offsetDays` from its due date, and
                            `on_payment_confirmation` after Aira records its
                            payment.
                        offsetDays:
                          type:
                            - 'null'
                            - integer
                          description: >-
                            The number of days from the due date on which a
                            `due_date` step sends, after the due date when
                            positive and before it when negative. It is null for
                            every other anchor.
                          example: 5
                        channel:
                          type: string
                          enum:
                            - email
                          description: >-
                            The channel through which the dunning step reaches
                            the invoice recipients.
                        content:
                          type: object
                          description: >-
                            The e-mail that the dunning step sends. The subject,
                            the title and the body can hold variables in double
                            braces, such as `{{ invoiceNumber }}`, `{{ dueDate
                            }}` or `{{ paymentLink }}`, which Aira fills in for
                            each invoice.
                          properties:
                            subject:
                              type: string
                              minLength: 1
                              description: The subject of the e-mail.
                              example: Sua fatura {{ invoiceNumber }}
                            title:
                              type: string
                              minLength: 1
                              description: The title that the e-mail shows above its body.
                              example: Sua fatura está disponível!
                            body:
                              type: string
                              minLength: 1
                              description: The text of the e-mail.
                              example: >-
                                Olá {{ billingAccountBusinessName }}, sua fatura
                                vence em {{ dueDate }}.
                            attachments:
                              type: object
                              description: >-
                                The files that the e-mail of the dunning step
                                attaches. A dunning step can attach only the
                                files that the `attachmentOptions` of the
                                dunning settings list.
                              properties:
                                artifacts:
                                  type: array
                                  description: >-
                                    The invoice artifacts that the e-mail
                                    attaches.
                                  items:
                                    type: object
                                    properties:
                                      type:
                                        anyOf:
                                          - enum:
                                              - default:invoice_pdf
                                          - type: string
                                            pattern: ^custom:.+$
                                        description: >-
                                          The type of the invoice artifact:
                                          `default:invoice_pdf` for the invoice
                                          PDF, or `custom:*` for an invoice
                                          artifact that Aira writes for you.
                                    required:
                                      - type
                                    additionalProperties: false
                                paymentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the files of the
                                    payment of the invoice: the boleto, the Pix
                                    file or both, as the payment method of its
                                    contract produces. A dunning step that sends
                                    after the payment cannot attach them.
                                fiscalDocumentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the PDF and the
                                    XML of the fiscal document of the invoice.
                                invoiceAttachmentFiles:
                                  type: boolean
                                  description: >-
                                    Whether the e-mail attaches the invoice
                                    attachments that a user or a system marked
                                    to go out with the invoice.
                              required:
                                - artifacts
                                - paymentFiles
                                - fiscalDocumentFiles
                                - invoiceAttachmentFiles
                              additionalProperties: false
                          required:
                            - subject
                            - title
                            - body
                            - attachments
                          additionalProperties: false
                      required:
                        - id
                        - name
                        - anchor
                        - offsetDays
                        - channel
                        - content
                      additionalProperties: false
                    description: >-
                      The dunning steps of the dunning schedule, ordered by when
                      they send: the issue day first, then by the days from the
                      due date, and the payment last.
                required:
                  - id
                  - name
                  - isDefault
                  - archivedAt
                  - steps
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role dunning:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `dunning_schedule_not_found`: no dunning schedule has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - dunning_schedule_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                dunning_schedule_not_found:
                  value:
                    message: dunning schedule not found
                    code: dunning_schedule_not_found
  /v1/custom-fields/:
    post:
      summary: Create custom field
      tags:
        - Custom Fields
      description: >-
        Creates a custom field that no module of Aira owns, so each record of
        the `entity` takes a value of it in its `customFields`, and the list of
        custom fields shows it. The billing app shows it after the other custom
        fields of the `entity`, with a toggle for a `boolean`, a select for a
        custom field with `options` or a `dataSource`, a text area for a
        `multiline` one, and a text input for the others.


        Requires the role `custom_fields:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                entity:
                  type: string
                  enum:
                    - contract
                    - product
                    - item
                    - customer
                    - importable_template
                    - legal_entity
                    - revenue_traceability
                    - revenue_attribution
                    - invoice_discount
                    - invoice
                    - plan_instance_version
                  description: >-
                    The kind of record that the custom field belongs to, such as
                    `customer` or `contract`.
                fieldKey:
                  type: string
                  description: >-
                    The key, in camelCase, under which each record of the
                    `entity` holds the value of the custom field in its
                    `customFields`. No other custom field of the same `entity`
                    has it.
                  pattern: ^[a-z][a-zA-Z0-9]*$
                  errorMessage:
                    pattern: fieldKey must be in camelCase format
                  example: canalDeVenda
                dataType:
                  type: string
                  enum:
                    - string
                    - string_array
                    - boolean
                  description: >-
                    The type of the value of the custom field: `string` holds
                    one text, `string_array` holds a list of texts, and
                    `boolean` holds the text `true` or `false`.
                label:
                  type: string
                  minLength: 1
                  description: The name of the custom field that the billing app shows.
                  example: Canal de venda
                description:
                  type:
                    - 'null'
                    - string
                  description: >-
                    The help text that the billing app shows with the input of
                    the custom field, or null for none.
                  example: Canal pelo qual o cliente compra.
                required:
                  type: boolean
                  description: >-
                    Whether each record of the `entity` must hold a value of the
                    custom field.
                  default: false
                defaultValue:
                  type:
                    - 'null'
                    - string
                  description: >-
                    The value that the billing app fills in on a new record, or
                    null for none.
                  example: varejo
                options:
                  type:
                    - 'null'
                    - array
                  items:
                    type: object
                    description: A value that a record can hold in the custom field.
                    properties:
                      label:
                        type: string
                        minLength: 1
                        description: The text that the billing app shows for the option.
                        examples:
                          - Varejo
                      value:
                        type: string
                        minLength: 1
                        description: >-
                          The value that a record holds in its `customFields`
                          when a user picks the option.
                        examples:
                          - varejo
                    required:
                      - label
                      - value
                    additionalProperties: false
                  description: >-
                    The values that a record can hold in the custom field, in
                    the order that the billing app shows them, or null when the
                    custom field takes any value.
                  minItems: 1
                dataSource:
                  type:
                    - 'null'
                    - string
                  enum:
                    - customers
                    - omie_categories
                    - omie_bank_accounts
                    - null
                  description: >-
                    The records whose ids a record holds in the custom field, in
                    place of `options`: `customers` for the customers, and
                    `omie_categories` or `omie_bank_accounts` for the categories
                    or the bank accounts of Omie. Null when the custom field
                    takes no records.
                multiline:
                  type: boolean
                  description: >-
                    Whether the billing app shows the input of the custom field
                    as a text area of several lines, in place of a text input of
                    one line. Only a custom field of `string` with no `options`
                    and no `dataSource` is multiline.
                  default: false
              required:
                - entity
                - fieldKey
                - dataType
                - label
              additionalProperties: false
        required: true
        description: The custom field to create.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_custom_fields
          when: >-
            the body has both `options` and a `dataSource`, gives a custom field
            of `boolean` options, a `dataSource` or a `defaultValue` other than
            `true` and `false`, makes `multiline` a custom field that is not a
            `string` with no `options` and no `dataSource`, names
            `omie_categories` or `omie_bank_accounts` as the `dataSource` while
            the integration of Omie is not enabled, or has an option with the
            value `__aira_empty__`, which Aira keeps for the filter of the
            records without a value
        - status: 400
          code: custom_field_already_exists
          when: another custom field of the `entity` has the `fieldKey`
      x-required-roles: &ref_32
        - custom_fields:write
      responses:
        '201':
          description: >-
            A custom field: a field that you add to one kind of record, such as
            customers or contracts, whose value users fill in on each record.
            Each record of that kind holds the value in its `customFields`,
            under the `fieldKey`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the custom field.
                  entity:
                    type: string
                    enum:
                      - contract
                      - product
                      - item
                      - customer
                      - importable_template
                      - legal_entity
                      - revenue_traceability
                      - revenue_attribution
                      - invoice_discount
                      - invoice
                      - plan_instance_version
                    description: >-
                      The kind of record that the custom field belongs to, such
                      as `customer` or `contract`.
                  fieldKey:
                    type: string
                    description: >-
                      The key under which each record of the `entity` holds the
                      value of the custom field in its `customFields`. No other
                      custom field of the same `entity` has it.
                    example: canalDeVenda
                  dataType:
                    type: string
                    enum:
                      - string
                      - string_array
                      - boolean
                    description: >-
                      The type of the value of the custom field: `string` holds
                      one text, `string_array` holds a list of texts, and
                      `boolean` holds the text `true` or `false`.
                  label:
                    type: string
                    minLength: 1
                    description: The name of the custom field that the billing app shows.
                    example: Canal de venda
                  description:
                    type:
                      - 'null'
                      - string
                    description: >-
                      The help text that the billing app shows with the input of
                      the custom field, or null for none.
                    example: Canal pelo qual o cliente compra.
                  required:
                    type: boolean
                    description: >-
                      Whether each record of the `entity` must hold a value of
                      the custom field.
                  defaultValue:
                    type:
                      - 'null'
                      - string
                    description: >-
                      The value that the billing app fills in on a new record,
                      or null for none.
                    example: varejo
                  options:
                    type:
                      - 'null'
                      - array
                    items:
                      type: object
                      description: A value that a record can hold in the custom field.
                      properties:
                        label:
                          type: string
                          minLength: 1
                          description: The text that the billing app shows for the option.
                          examples:
                            - Varejo
                        value:
                          type: string
                          minLength: 1
                          description: >-
                            The value that a record holds in its `customFields`
                            when a user picks the option.
                          examples:
                            - varejo
                      required:
                        - label
                        - value
                      additionalProperties: false
                    description: >-
                      The values that a record can hold in the custom field, in
                      the order that the billing app shows them, or null when
                      the custom field takes any value.
                  dataSource:
                    type:
                      - 'null'
                      - string
                    enum:
                      - customers
                      - omie_categories
                      - omie_bank_accounts
                      - null
                    description: >-
                      The records whose ids a record holds in the custom field,
                      in place of `options`: `customers` for the customers, and
                      `omie_categories` or `omie_bank_accounts` for the
                      categories or the bank accounts of Omie. Null when the
                      custom field takes no records.
                  multiline:
                    type: boolean
                    description: >-
                      Whether the billing app shows the input of the custom
                      field as a text area of several lines, in place of a text
                      input of one line. Only a custom field of `string` with no
                      `options` and no `dataSource` is multiline.
                  module:
                    type:
                      - 'null'
                      - string
                    enum:
                      - omie
                      - senior
                      - celcash
                      - asaas
                      - enotas
                      - hubspot
                      - contaazul
                      - null
                    description: >-
                      The module of Aira that owns the custom field, such as the
                      integration `omie`, which reads its value by the
                      `fieldKey`, or null when no module owns it. You cannot
                      update or delete a custom field that a module owns.
                required:
                  - id
                  - entity
                  - fieldKey
                  - dataType
                  - label
                  - description
                  - required
                  - defaultValue
                  - options
                  - dataSource
                  - multiline
                  - module
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: the body breaks the schema of the
            endpoint.

            - `invalid_custom_fields`: the body has both `options` and a
            `dataSource`, gives a custom field of `boolean` options, a
            `dataSource` or a `defaultValue` other than `true` and `false`,
            makes `multiline` a custom field that is not a `string` with no
            `options` and no `dataSource`, names `omie_categories` or
            `omie_bank_accounts` as the `dataSource` while the integration of
            Omie is not enabled, or has an option with the value
            `__aira_empty__`, which Aira keeps for the filter of the records
            without a value.

            - `custom_field_already_exists`: another custom field of the
            `entity` has the `fieldKey`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_custom_fields
                      - custom_field_already_exists
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''entity'' is required'
                    code: json_schema_validation_error
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
                custom_field_already_exists:
                  value:
                    message: >-
                      custom field with fieldKey "{fieldKey}" already exists for
                      entity "{entity}"
                    code: custom_field_already_exists
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role custom_fields:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
    get:
      summary: List custom fields
      tags:
        - Custom Fields
      description: >-
        Lists the custom fields, of every kind of record or of the `entity`
        only, newest first by creation time.


        Requires the role `custom_fields:read`.
      parameters:
        - schema:
            type: string
            enum:
              - contract
              - product
              - item
              - customer
              - importable_template
              - legal_entity
              - revenue_traceability
              - revenue_attribution
              - invoice_discount
              - invoice
              - plan_instance_version
          in: query
          name: entity
          required: false
          description: >-
            The kind of record whose custom fields to list. Leave it out to list
            the custom fields of every kind of record.
        - schema:
            type: integer
            default: 0
            minimum: 0
            maximum: 2147483647
          in: query
          name: offset
          required: false
          description: Number of items to skip before collecting the page.
        - schema:
            type: integer
            minimum: 1
            default: 100
            maximum: 100
          in: query
          name: limit
          required: false
          description: Maximum number of items to return per page.
      x-public-api: true
      x-errors:
        - *ref_1
        - *ref_2
      x-required-roles: &ref_33
        - custom_fields:read
      responses:
        '200':
          description: The custom fields that match the filters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  items:
                    type: array
                    items:
                      type: object
                      description: >-
                        A custom field: a field that you add to one kind of
                        record, such as customers or contracts, whose value
                        users fill in on each record. Each record of that kind
                        holds the value in its `customFields`, under the
                        `fieldKey`.
                      properties:
                        id:
                          type: string
                          format: uuid
                          description: The unique identifier of the custom field.
                        entity:
                          type: string
                          enum:
                            - contract
                            - product
                            - item
                            - customer
                            - importable_template
                            - legal_entity
                            - revenue_traceability
                            - revenue_attribution
                            - invoice_discount
                            - invoice
                            - plan_instance_version
                          description: >-
                            The kind of record that the custom field belongs to,
                            such as `customer` or `contract`.
                        fieldKey:
                          type: string
                          description: >-
                            The key under which each record of the `entity`
                            holds the value of the custom field in its
                            `customFields`. No other custom field of the same
                            `entity` has it.
                          example: canalDeVenda
                        dataType:
                          type: string
                          enum:
                            - string
                            - string_array
                            - boolean
                          description: >-
                            The type of the value of the custom field: `string`
                            holds one text, `string_array` holds a list of
                            texts, and `boolean` holds the text `true` or
                            `false`.
                        label:
                          type: string
                          minLength: 1
                          description: >-
                            The name of the custom field that the billing app
                            shows.
                          example: Canal de venda
                        description:
                          type:
                            - 'null'
                            - string
                          description: >-
                            The help text that the billing app shows with the
                            input of the custom field, or null for none.
                          example: Canal pelo qual o cliente compra.
                        required:
                          type: boolean
                          description: >-
                            Whether each record of the `entity` must hold a
                            value of the custom field.
                        defaultValue:
                          type:
                            - 'null'
                            - string
                          description: >-
                            The value that the billing app fills in on a new
                            record, or null for none.
                          example: varejo
                        options:
                          type:
                            - 'null'
                            - array
                          items:
                            type: object
                            description: >-
                              A value that a record can hold in the custom
                              field.
                            properties:
                              label:
                                type: string
                                minLength: 1
                                description: >-
                                  The text that the billing app shows for the
                                  option.
                                examples:
                                  - Varejo
                              value:
                                type: string
                                minLength: 1
                                description: >-
                                  The value that a record holds in its
                                  `customFields` when a user picks the option.
                                examples:
                                  - varejo
                            required:
                              - label
                              - value
                            additionalProperties: false
                          description: >-
                            The values that a record can hold in the custom
                            field, in the order that the billing app shows them,
                            or null when the custom field takes any value.
                        dataSource:
                          type:
                            - 'null'
                            - string
                          enum:
                            - customers
                            - omie_categories
                            - omie_bank_accounts
                            - null
                          description: >-
                            The records whose ids a record holds in the custom
                            field, in place of `options`: `customers` for the
                            customers, and `omie_categories` or
                            `omie_bank_accounts` for the categories or the bank
                            accounts of Omie. Null when the custom field takes
                            no records.
                        multiline:
                          type: boolean
                          description: >-
                            Whether the billing app shows the input of the
                            custom field as a text area of several lines, in
                            place of a text input of one line. Only a custom
                            field of `string` with no `options` and no
                            `dataSource` is multiline.
                        module:
                          type:
                            - 'null'
                            - string
                          enum:
                            - omie
                            - senior
                            - celcash
                            - asaas
                            - enotas
                            - hubspot
                            - contaazul
                            - null
                          description: >-
                            The module of Aira that owns the custom field, such
                            as the integration `omie`, which reads its value by
                            the `fieldKey`, or null when no module owns it. You
                            cannot update or delete a custom field that a module
                            owns.
                      required:
                        - id
                        - entity
                        - fieldKey
                        - dataType
                        - label
                        - description
                        - required
                        - defaultValue
                        - options
                        - dataSource
                        - multiline
                        - module
                      additionalProperties: false
                    description: A list of items.
                  hasMore:
                    description: Indicates if there are more items to fetch.
                    type: boolean
                required:
                  - items
                  - hasMore
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a query parameter breaks the
            schema of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''entity'' must be string'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role custom_fields:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
  /v1/custom-fields/{id}:
    patch:
      summary: Update custom field
      tags:
        - Custom Fields
      description: >-
        Updates the attributes that the body names of a custom field that no
        module of Aira owns, and keeps the others. When the body names the
        `options` or the `dataSource`, the two replace the values that a record
        can hold, and the billing app shows the custom field with a select while
        it has either, and with a text input, or a text area while it is
        `multiline`, when it has neither.


        Requires the role `custom_fields:write`.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                label:
                  type: string
                  minLength: 1
                  description: The name of the custom field that the billing app shows.
                  example: Canal de venda
                description:
                  type:
                    - 'null'
                    - string
                  description: >-
                    The help text that the billing app shows with the input of
                    the custom field, or null for none.
                  example: Canal pelo qual o cliente compra.
                required:
                  type: boolean
                  description: >-
                    Whether each record of the `entity` must hold a value of the
                    custom field.
                defaultValue:
                  type:
                    - 'null'
                    - string
                  description: >-
                    The value that the billing app fills in on a new record, or
                    null for none.
                  example: varejo
                options:
                  type:
                    - 'null'
                    - array
                  items:
                    type: object
                    description: A value that a record can hold in the custom field.
                    properties:
                      label:
                        type: string
                        minLength: 1
                        description: The text that the billing app shows for the option.
                        examples:
                          - Varejo
                      value:
                        type: string
                        minLength: 1
                        description: >-
                          The value that a record holds in its `customFields`
                          when a user picks the option.
                        examples:
                          - varejo
                    required:
                      - label
                      - value
                    additionalProperties: false
                  description: >-
                    The values that a record can hold in the custom field, in
                    the order that the billing app shows them, or null when the
                    custom field takes any value. When the body names `options`
                    or `dataSource`, the two replace the values that the custom
                    field takes, so the one that the body leaves out becomes
                    null.
                  minItems: 1
                dataSource:
                  type:
                    - 'null'
                    - string
                  enum:
                    - customers
                    - omie_categories
                    - omie_bank_accounts
                    - null
                  description: >-
                    The records whose ids a record holds in the custom field, in
                    place of `options`: `customers` for the customers, and
                    `omie_categories` or `omie_bank_accounts` for the categories
                    or the bank accounts of Omie, or null for none. When the
                    body names `options` or `dataSource`, the two replace the
                    values that the custom field takes, so the one that the body
                    leaves out becomes null.
                multiline:
                  type: boolean
                  description: >-
                    Whether the billing app shows the input of the custom field
                    as a text area of several lines, in place of a text input of
                    one line. Only a custom field of `string` with no `options`
                    and no `dataSource` is multiline.
              required: []
              additionalProperties: false
              minProperties: 1
        description: >-
          The attributes of the custom field to change, at least one. The
          attributes that the body leaves out keep their values.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the custom field.
      x-public-api: true
      x-errors:
        - status: 400
          code: invalid_custom_fields
          when: >-
            the body has both `options` and a `dataSource`, gives a custom field
            of `boolean` options, a `dataSource` or a `defaultValue` other than
            `true` and `false`, makes `multiline` a custom field that is not a
            `string` with no `options` and no `dataSource`, names
            `omie_categories` or `omie_bank_accounts` as the `dataSource` while
            the integration of Omie is not enabled, or has an option with the
            value `__aira_empty__`, which Aira keeps for the filter of the
            records without a value
        - status: 400
          code: custom_field_owned_by_module
          when: >-
            a module of Aira owns the custom field, such as an integration that
            reads its value by the `fieldKey`
        - status: 404
          code: custom_field_not_found
          when: no custom field has the `id`
      x-required-roles: *ref_32
      responses:
        '200':
          description: >-
            A custom field: a field that you add to one kind of record, such as
            customers or contracts, whose value users fill in on each record.
            Each record of that kind holds the value in its `customFields`,
            under the `fieldKey`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the custom field.
                  entity:
                    type: string
                    enum:
                      - contract
                      - product
                      - item
                      - customer
                      - importable_template
                      - legal_entity
                      - revenue_traceability
                      - revenue_attribution
                      - invoice_discount
                      - invoice
                      - plan_instance_version
                    description: >-
                      The kind of record that the custom field belongs to, such
                      as `customer` or `contract`.
                  fieldKey:
                    type: string
                    description: >-
                      The key under which each record of the `entity` holds the
                      value of the custom field in its `customFields`. No other
                      custom field of the same `entity` has it.
                    example: canalDeVenda
                  dataType:
                    type: string
                    enum:
                      - string
                      - string_array
                      - boolean
                    description: >-
                      The type of the value of the custom field: `string` holds
                      one text, `string_array` holds a list of texts, and
                      `boolean` holds the text `true` or `false`.
                  label:
                    type: string
                    minLength: 1
                    description: The name of the custom field that the billing app shows.
                    example: Canal de venda
                  description:
                    type:
                      - 'null'
                      - string
                    description: >-
                      The help text that the billing app shows with the input of
                      the custom field, or null for none.
                    example: Canal pelo qual o cliente compra.
                  required:
                    type: boolean
                    description: >-
                      Whether each record of the `entity` must hold a value of
                      the custom field.
                  defaultValue:
                    type:
                      - 'null'
                      - string
                    description: >-
                      The value that the billing app fills in on a new record,
                      or null for none.
                    example: varejo
                  options:
                    type:
                      - 'null'
                      - array
                    items:
                      type: object
                      description: A value that a record can hold in the custom field.
                      properties:
                        label:
                          type: string
                          minLength: 1
                          description: The text that the billing app shows for the option.
                          examples:
                            - Varejo
                        value:
                          type: string
                          minLength: 1
                          description: >-
                            The value that a record holds in its `customFields`
                            when a user picks the option.
                          examples:
                            - varejo
                      required:
                        - label
                        - value
                      additionalProperties: false
                    description: >-
                      The values that a record can hold in the custom field, in
                      the order that the billing app shows them, or null when
                      the custom field takes any value.
                  dataSource:
                    type:
                      - 'null'
                      - string
                    enum:
                      - customers
                      - omie_categories
                      - omie_bank_accounts
                      - null
                    description: >-
                      The records whose ids a record holds in the custom field,
                      in place of `options`: `customers` for the customers, and
                      `omie_categories` or `omie_bank_accounts` for the
                      categories or the bank accounts of Omie. Null when the
                      custom field takes no records.
                  multiline:
                    type: boolean
                    description: >-
                      Whether the billing app shows the input of the custom
                      field as a text area of several lines, in place of a text
                      input of one line. Only a custom field of `string` with no
                      `options` and no `dataSource` is multiline.
                  module:
                    type:
                      - 'null'
                      - string
                    enum:
                      - omie
                      - senior
                      - celcash
                      - asaas
                      - enotas
                      - hubspot
                      - contaazul
                      - null
                    description: >-
                      The module of Aira that owns the custom field, such as the
                      integration `omie`, which reads its value by the
                      `fieldKey`, or null when no module owns it. You cannot
                      update or delete a custom field that a module owns.
                required:
                  - id
                  - entity
                  - fieldKey
                  - dataType
                  - label
                  - description
                  - required
                  - defaultValue
                  - options
                  - dataSource
                  - multiline
                  - module
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter or the body
            breaks the schema of the endpoint.

            - `invalid_custom_fields`: the body has both `options` and a
            `dataSource`, gives a custom field of `boolean` options, a
            `dataSource` or a `defaultValue` other than `true` and `false`,
            makes `multiline` a custom field that is not a `string` with no
            `options` and no `dataSource`, names `omie_categories` or
            `omie_bank_accounts` as the `dataSource` while the integration of
            Omie is not enabled, or has an option with the value
            `__aira_empty__`, which Aira keeps for the filter of the records
            without a value.

            - `custom_field_owned_by_module`: a module of Aira owns the custom
            field, such as an integration that reads its value by the
            `fieldKey`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - invalid_custom_fields
                      - custom_field_owned_by_module
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                invalid_custom_fields:
                  value:
                    message: 'Unknown custom field(s) for {entity}: {value}'
                    code: invalid_custom_fields
                custom_field_owned_by_module:
                  value:
                    message: >-
                      custom field "{fieldKey}" belongs to the module {module},
                      which reads it by its key
                    code: custom_field_owned_by_module
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role custom_fields:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `custom_field_not_found`: no custom field has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - custom_field_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                custom_field_not_found:
                  value:
                    message: custom field "{id}" not found
                    code: custom_field_not_found
    delete:
      summary: Delete custom field
      tags:
        - Custom Fields
      description: >-
        Deletes a custom field that no module of Aira owns, no record holds a
        value of and no importable template names, so the list of custom fields
        no longer shows it.


        Requires the role `custom_fields:write`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the custom field.
      x-public-api: true
      x-errors:
        - status: 400
          code: custom_field_owned_by_module
          when: >-
            a module of Aira owns the custom field, such as an integration that
            reads its value by the `fieldKey`
        - status: 404
          code: custom_field_not_found
          when: no custom field has the `id`
        - status: 409
          code: custom_field_in_use
          when: >-
            a record holds a value of the custom field, or an importable
            template names it, and `details` counts them in `valueRows` and
            `importableTemplates`
      x-required-roles: *ref_32
      responses:
        '204':
          description: The request was successfully processed.
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.

            - `custom_field_owned_by_module`: a module of Aira owns the custom
            field, such as an integration that reads its value by the
            `fieldKey`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                      - custom_field_owned_by_module
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
                custom_field_owned_by_module:
                  value:
                    message: >-
                      custom field "{fieldKey}" belongs to the module {module},
                      which reads it by its key
                    code: custom_field_owned_by_module
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role custom_fields:write can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `custom_field_not_found`: no custom field has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - custom_field_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                custom_field_not_found:
                  value:
                    message: custom field "{id}" not found
                    code: custom_field_not_found
        '409':
          description: >-
            Other data blocks the action.


            - `custom_field_in_use`: a record holds a value of the custom field,
            or an importable template names it, and `details` counts them in
            `valueRows` and `importableTemplates`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - custom_field_in_use
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                custom_field_in_use:
                  value:
                    message: >-
                      custom field "{fieldKey}" is in use: {valueRows} records
                      hold a value of it, and {importableTemplates} importable
                      templates name it
                    code: custom_field_in_use
    get:
      summary: Fetch custom field
      tags:
        - Custom Fields
      description: |-
        Fetches a custom field, with the module of Aira that owns it.

        Requires the role `custom_fields:read`.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: id
          required: true
          description: The unique identifier of the custom field.
      x-public-api: true
      x-errors:
        - status: 404
          code: custom_field_not_found
          when: no custom field has the `id`
        - *ref_1
        - *ref_2
      x-required-roles: *ref_33
      responses:
        '200':
          description: >-
            A custom field: a field that you add to one kind of record, such as
            customers or contracts, whose value users fill in on each record.
            Each record of that kind holds the value in its `customFields`,
            under the `fieldKey`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the custom field.
                  entity:
                    type: string
                    enum:
                      - contract
                      - product
                      - item
                      - customer
                      - importable_template
                      - legal_entity
                      - revenue_traceability
                      - revenue_attribution
                      - invoice_discount
                      - invoice
                      - plan_instance_version
                    description: >-
                      The kind of record that the custom field belongs to, such
                      as `customer` or `contract`.
                  fieldKey:
                    type: string
                    description: >-
                      The key under which each record of the `entity` holds the
                      value of the custom field in its `customFields`. No other
                      custom field of the same `entity` has it.
                    example: canalDeVenda
                  dataType:
                    type: string
                    enum:
                      - string
                      - string_array
                      - boolean
                    description: >-
                      The type of the value of the custom field: `string` holds
                      one text, `string_array` holds a list of texts, and
                      `boolean` holds the text `true` or `false`.
                  label:
                    type: string
                    minLength: 1
                    description: The name of the custom field that the billing app shows.
                    example: Canal de venda
                  description:
                    type:
                      - 'null'
                      - string
                    description: >-
                      The help text that the billing app shows with the input of
                      the custom field, or null for none.
                    example: Canal pelo qual o cliente compra.
                  required:
                    type: boolean
                    description: >-
                      Whether each record of the `entity` must hold a value of
                      the custom field.
                  defaultValue:
                    type:
                      - 'null'
                      - string
                    description: >-
                      The value that the billing app fills in on a new record,
                      or null for none.
                    example: varejo
                  options:
                    type:
                      - 'null'
                      - array
                    items:
                      type: object
                      description: A value that a record can hold in the custom field.
                      properties:
                        label:
                          type: string
                          minLength: 1
                          description: The text that the billing app shows for the option.
                          examples:
                            - Varejo
                        value:
                          type: string
                          minLength: 1
                          description: >-
                            The value that a record holds in its `customFields`
                            when a user picks the option.
                          examples:
                            - varejo
                      required:
                        - label
                        - value
                      additionalProperties: false
                    description: >-
                      The values that a record can hold in the custom field, in
                      the order that the billing app shows them, or null when
                      the custom field takes any value.
                  dataSource:
                    type:
                      - 'null'
                      - string
                    enum:
                      - customers
                      - omie_categories
                      - omie_bank_accounts
                      - null
                    description: >-
                      The records whose ids a record holds in the custom field,
                      in place of `options`: `customers` for the customers, and
                      `omie_categories` or `omie_bank_accounts` for the
                      categories or the bank accounts of Omie. Null when the
                      custom field takes no records.
                  multiline:
                    type: boolean
                    description: >-
                      Whether the billing app shows the input of the custom
                      field as a text area of several lines, in place of a text
                      input of one line. Only a custom field of `string` with no
                      `options` and no `dataSource` is multiline.
                  module:
                    type:
                      - 'null'
                      - string
                    enum:
                      - omie
                      - senior
                      - celcash
                      - asaas
                      - enotas
                      - hubspot
                      - contaazul
                      - null
                    description: >-
                      The module of Aira that owns the custom field, such as the
                      integration `omie`, which reads its value by the
                      `fieldKey`, or null when no module owns it. You cannot
                      update or delete a custom field that a module owns.
                required:
                  - id
                  - entity
                  - fieldKey
                  - dataType
                  - label
                  - description
                  - required
                  - defaultValue
                  - options
                  - dataSource
                  - multiline
                  - module
                additionalProperties: false
        '400':
          description: >-
            The request cannot succeed as sent.


            - `json_schema_validation_error`: a path parameter breaks the schema
            of the endpoint.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - json_schema_validation_error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                json_schema_validation_error:
                  value:
                    message: '''id'' must match format "uuid"'
                    code: json_schema_validation_error
        '401':
          description: >-
            The request carries no API key.


            - `no_authorization`: the request carries no API key in the
            `X-API-KEY` header.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - no_authorization
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                no_authorization:
                  value:
                    message: No authorization provided
                    code: no_authorization
        '403':
          description: >-
            The API key cannot call the endpoint.


            - `bad_auth`: the API key does not hold the role that the endpoint
            requires.

            - `invalid_api_key`: the API key does not exist.

            - `deactivated_api_key`: the API key is deactivated.

            - `revoked_api_key`: the API key is revoked.

            - `expired_api_key`: the API key is past its expiry date.

            - `ip_not_allowed`: the IP of the request is not among the IPs that
            your API keys accept.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - bad_auth
                      - invalid_api_key
                      - deactivated_api_key
                      - revoked_api_key
                      - expired_api_key
                      - ip_not_allowed
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                bad_auth:
                  value:
                    message: role custom_fields:read can not be satisfied
                    code: bad_auth
                invalid_api_key:
                  value:
                    message: Invalid API key
                    code: invalid_api_key
                deactivated_api_key:
                  value:
                    message: Deactivated API key
                    code: deactivated_api_key
                revoked_api_key:
                  value:
                    message: Revoked API key
                    code: revoked_api_key
                expired_api_key:
                  value:
                    message: Expired API key
                    code: expired_api_key
                ip_not_allowed:
                  value:
                    message: IP not allowed
                    code: ip_not_allowed
        '404':
          description: |-
            A record that the request names does not exist.

            - `custom_field_not_found`: no custom field has the `id`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - custom_field_not_found
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                custom_field_not_found:
                  value:
                    message: custom field "{id}" not found
                    code: custom_field_not_found
        '429':
          description: >-
            You reached one of the limits of reads, which count the reads of all
            your API keys together.


            - `too_many_reads_per_second`: you already made 50 reads in this
            second across all your API keys.

            - `too_many_reads_in_flight`: you already have 20 reads in flight
            across all your API keys.
          headers:
            Retry-After:
              schema:
                type: integer
              description: The seconds to wait before the next read.
            RateLimit-Limit:
              schema:
                type: integer
              description: >-
                The limit that the read hit: 20 for the reads in flight, 50 for
                the reads per second.
            RateLimit-Remaining:
              schema:
                type: integer
              description: The reads left under that limit, which is 0.
            RateLimit-Reset:
              schema:
                type: integer
              description: >-
                The seconds to wait before the next read, as in Retry-After. The
                limit of reads per second takes new reads in the next second,
                but the limit of reads in flight takes a new read only once one
                of the reads in flight ends.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: >-
                      A sentence for a person that says what failed. It can
                      change, so a system compares the code instead.
                  code:
                    type: string
                    description: >-
                      The identifier of the error, which a system compares to
                      decide what to do. It never changes.
                    enum:
                      - too_many_reads_per_second
                      - too_many_reads_in_flight
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      The data of the error, when it has any, such as the fields
                      that failed the validation.
                  causations:
                    type: array
                    description: >-
                      The errors that caused this one, when several did, each
                      with its own message, code and details.
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: A sentence for a person that says what failed.
                        code:
                          type: string
                          description: The identifier of the error.
                        details:
                          type: object
                          additionalProperties: true
                          description: The data of the error, when it has any.
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - message
                  - code
                additionalProperties: false
              examples:
                too_many_reads_per_second:
                  value:
                    message: >-
                      Too many reads: you can make at most 50 reads per second
                      across all your API keys. Retry after 1 second.
                    code: too_many_reads_per_second
                too_many_reads_in_flight:
                  value:
                    message: >-
                      Too many reads in flight: you can have at most 20 reads in
                      flight across all your API keys. Retry after 1 second.
                    code: too_many_reads_in_flight
servers:
  - url: https://api.useaira.com
    description: API base URL
security:
  - ApiKey: []
