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

# Update a package

> A package switched off (enable: false) may keep applying, a package whose rounding changed may keep charging the previous one, and a fee whose deferrable changed to false may still open fee debt when unfunded, for up to 60 seconds when a transaction read the packages concurrently with the update. Closing an account is permanent. To retire a fee account, point the fee package at the new fee account and leave the old account open: reverts of earlier transactions and collections of fee debt already owed to it still post there.



## OpenAPI

````yaml /pt/openapi/v3-current/ledger.yaml patch /v2/organizations/{organization_id}/ledgers/{ledger_id}/packages/{package_id}
openapi: 3.1.0
info:
  title: Midaz Ledger API
  version: 4.0.0
servers:
  - url: https://ledger.sandbox.lerian.net
security: []
tags:
  - name: Account Block Exceptions (v2)
  - name: Account Plan Assignments (v2)
  - name: Account Plans (v2)
  - name: Account Types (v1)
  - name: Account Types (v2)
  - name: Accounts (v1)
  - name: Accounts (v2)
  - name: Asset Rates (v1)
  - name: Assets (v1)
  - name: Assets (v2)
  - name: Balances (v1)
  - name: Balances (v2)
  - name: Billing Calculate (v2)
  - name: Billing Packages (v2)
  - name: Composition (v2)
  - name: Dashboard (v1)
  - name: Dashboard (v2)
  - name: Encryption (v2)
  - name: Fee Charges (v2)
  - name: Fee Debts (v2)
  - name: Fees (v2)
  - name: Holders (v2)
  - name: Instruments (v2)
  - name: Ledgers (v1)
  - name: Ledgers (v2)
  - name: Metadata Indexes (v1)
  - name: Metadata Indexes (v2)
  - name: Operation Routes (v1)
  - name: Operation Routes (v2)
  - name: Operations (v1)
  - name: Operations (v2)
  - name: Organizations (v1)
  - name: Organizations (v2)
  - name: Packages (v2)
  - name: Portfolios (v1)
  - name: Portfolios (v2)
  - name: Protection (v2)
  - name: Segments (v1)
  - name: Segments (v2)
  - name: Transaction Routes (v1)
  - name: Transaction Routes (v2)
  - name: Transactions (v1)
  - name: Transactions (v2)
paths:
  /v2/organizations/{organization_id}/ledgers/{ledger_id}/packages/{package_id}:
    patch:
      tags:
        - Packages (v2)
      summary: Update a package
      description: >-
        A package switched off (enable: false) may keep applying, a package
        whose rounding changed may keep charging the previous one, and a fee
        whose deferrable changed to false may still open fee debt when unfunded,
        for up to 60 seconds when a transaction read the packages concurrently
        with the update. Closing an account is permanent. To retire a fee
        account, point the fee package at the new fee account and leave the old
        account open: reverts of earlier transactions and collections of fee
        debt already owed to it still post there.
      operationId: updatePackageV2
      parameters:
        - description: Organization ID (UUID)
          in: path
          name: organization_id
          required: true
          schema:
            description: Organization ID (UUID)
            type: string
        - description: Ledger ID (UUID)
          in: path
          name: ledger_id
          required: true
          schema:
            description: Ledger ID (UUID)
            type: string
        - description: Package ID (UUID)
          in: path
          name: package_id
          required: true
          schema:
            description: Package ID (UUID)
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeeUpdatePackageInput'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeePackage'
          description: OK
        '422':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Unprocessable Entity
        '500':
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Internal Server Error
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Error
      security:
        - BearerAuth: []
components:
  schemas:
    FeeUpdatePackageInput:
      additionalProperties: false
      properties:
        description:
          examples:
            - Pacote de taxas administrativas padrão
          type: string
        enable:
          examples:
            - true
          type: boolean
        feeGroupLabel:
          examples:
            - Pacote Padrão
          type: string
        fees:
          additionalProperties:
            $ref: '#/components/schemas/Fee'
          description: >-
            Fee patches keyed by fee key. An entry naming a stored key verbatim
            edits that fee, or removes it when the entry sets no field. Any
            other key adds a fee and must match ^[a-z][a-zA-Z0-9]*$ (a lowercase
            ASCII letter, then ASCII letters and digits), or the update is
            refused with 400; a key equal to a stored key except for letter case
            is also refused with 400, and the stored key must be used, unless
            the same patch removes that stored key, which renames the fee (the
            new key must still match the grammar).
          type: object
        maximumAmount:
          examples:
            - '1000'
          minimum: 0
          type:
            - string
            - 'null'
        minimumAmount:
          examples:
            - '100'
          minimum: 0
          type:
            - string
            - 'null'
        rounding:
          $ref: '#/components/schemas/FeeRounding'
          description: >-
            Replaces the stored rounding whole. An update cannot remove a stored
            rounding.
        waivedAccounts:
          examples:
            - - acc001
              - acc002
          items:
            type: string
          type:
            - array
            - 'null'
      type: object
    FeePackage:
      additionalProperties: false
      properties:
        createdAt:
          examples:
            - '2021-01-01T00:00:00Z'
          format: date-time
          type: string
        deletedAt:
          examples:
            - '2021-01-01T00:00:00Z'
          format: date-time
          type:
            - string
            - 'null'
        description:
          examples:
            - Pacote de taxas administrativas padrão
          type:
            - string
            - 'null'
        enable:
          type:
            - boolean
            - 'null'
        feeGroupLabel:
          examples:
            - Pacote Padrão
          type: string
        fees:
          additionalProperties:
            $ref: '#/components/schemas/Fee'
          type: object
        id:
          examples:
            - 00000000-0000-0000-0000-000000000000
          type: string
        ledgerId:
          examples:
            - 00000000-0000-0000-0000-000000000000
          type: string
        maximumAmount:
          examples:
            - '2'
          minimum: 0
          type: string
        metadataSelector:
          additionalProperties:
            type: string
          description: >-
            Metadata pairs a transaction must all carry for this package to
            apply, each matching only a string metadata value equal to it. Each
            pair counts one toward package specificity. Absent or empty applies
            the package whatever the metadata.
          examples:
            - fee_context: ted_salario
          type: object
        minimumAmount:
          examples:
            - '100'
          minimum: 0
          type: string
        rounding:
          $ref: '#/components/schemas/FeeRounding'
        segmentId:
          examples:
            - 00000000-0000-0000-0000-000000000000
          type: string
        transactionRoute:
          description: >-
            Transaction route identifier this package is scoped to. It must
            equal the routeId the payment carries, so it is a route UUID and not
            a free-form name. An absent or empty value applies the package to
            every payment.
          examples:
            - 00000000-0000-0000-0000-000000000000
          type:
            - string
            - 'null'
        updatedAt:
          examples:
            - '2021-01-01T00:00:00Z'
          format: date-time
          type: string
        waivedAccounts:
          examples:
            - - acc001
              - acc002
          items:
            type: string
          type:
            - array
            - 'null'
      required:
        - id
        - feeGroupLabel
        - description
        - segmentId
        - ledgerId
        - transactionRoute
        - minimumAmount
        - maximumAmount
        - waivedAccounts
        - fees
        - enable
        - createdAt
        - updatedAt
        - deletedAt
      type: object
    Error:
      additionalProperties: true
      properties:
        code:
          description: >-
            Stable, machine-readable domain error code scoped to the emitting
            service (format: <SERVICE>-NNNN).
          type: string
        detail:
          description: >-
            A human-readable explanation specific to this occurrence of the
            problem.
          examples:
            - Property foo is required but is missing.
          type: string
        errors:
          description: Optional list of individual error details
          items:
            $ref: '#/components/schemas/ErrorDetail'
          type:
            - array
            - 'null'
        instance:
          description: >-
            A URI reference that identifies the specific occurrence of the
            problem.
          examples:
            - https://example.com/error-log/abc123
          format: uri
          type: string
        status:
          description: HTTP status code
          examples:
            - 400
          format: int64
          type: integer
        title:
          description: >-
            A short, human-readable summary of the problem type. This value
            should not change between occurrences of the error.
          examples:
            - Bad Request
          type: string
        type:
          default: about:blank
          description: A URI reference to human-readable documentation for the error.
          examples:
            - https://example.com/errors/example
          format: uri
          type: string
        upstream:
          $ref: '#/components/schemas/Upstream'
          description: >-
            RFC 9457 extension member: the error a proxied third-party provider
            reported. Absent unless the emitting service explicitly surfaced
            one.
      type: object
    Fee:
      additionalProperties: false
      properties:
        calculationModel:
          $ref: '#/components/schemas/FeeCalculationModel'
        creditAccount:
          examples:
            - conta_receita_taxas_adm
          type: string
        deferrable:
          description: >-
            Whether the share of this fee the payer cannot fund becomes a fee
            debt, settled by the payer's next credits, instead of refusing the
            transaction. It applies only to /v2 direct transactions; /v1 and /v2
            hold/commit still refuse. Only a fee whose isDeductibleFrom is false
            can be deferrable. Defaults to false.
          examples:
            - false
          type: boolean
        feeLabel:
          examples:
            - Taxa Administrativa
          type: string
        isDeductibleFrom:
          examples:
            - true
          type:
            - boolean
            - 'null'
        priority:
          examples:
            - 1
          format: int64
          type: integer
        referenceAmount:
          examples:
            - originalAmount
          type: string
        routeFrom:
          examples:
            - taxa_débito
          type: string
        routeTo:
          examples:
            - taxa_crédito
          type: string
      required:
        - feeLabel
        - calculationModel
        - referenceAmount
        - isDeductibleFrom
        - creditAccount
      type: object
    FeeRounding:
      additionalProperties: false
      properties:
        mode:
          description: >-
            How each fee total is rounded: floor rounds down, halfUp rounds half
            away from zero. Each payer's share rounds toward zero and the
            largest payer takes the remainder, so the shares sum to the total.
          enum:
            - floor
            - halfUp
          examples:
            - floor
          type: string
        scale:
          description: Decimal places each fee total and each payer's share is rounded to.
          examples:
            - 2
          format: int32
          maximum: 18
          minimum: 0
          type: integer
      required:
        - scale
        - mode
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        location:
          description: >-
            Where the error occurred, e.g. 'body.items[3].tags' or
            'path.thing-id'
          type: string
        message:
          description: Error message text
          type: string
        value:
          description: The value at the given location
      type: object
    Upstream:
      additionalProperties: false
      properties:
        code:
          description: The upstream provider's own error code, verbatim.
          examples:
            - E4001
          type: string
        message:
          description: >-
            The upstream provider's own error message, verbatim (bounded, never
            its raw response body).
          examples:
            - account not found at provider
          type: string
      type: object
    FeeCalculationModel:
      additionalProperties: false
      properties:
        applicationRule:
          examples:
            - maxBetweenTypes
          type: string
        calculations:
          items:
            $ref: '#/components/schemas/FeeCalculation'
          type:
            - array
            - 'null'
      required:
        - applicationRule
        - calculations
      type: object
    FeeCalculation:
      additionalProperties: false
      properties:
        type:
          examples:
            - percentage
          type: string
        value:
          examples:
            - '100.00'
          type: string
      required:
        - type
        - value
      type: object
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      description: JWT bearer token issued by the identity provider.
      scheme: bearer
      type: http

````

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