> ## 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.

# Estimate Transaction Fees

> Use this endpoint to estimate the fees for a transaction. It helps validate expected charges before processing.



## OpenAPI

````yaml /en/openapi/v3-current/fees-engine.yaml post /v1/estimates
openapi: 3.1.0
info:
  title: Fees Engine
  description: ''
  version: 3.2.0
servers:
  - url: https://fees.sandbox.lerian.net
security: []
tags:
  - name: Fees Engine
paths:
  /v1/estimates:
    post:
      tags:
        - Estimation API
      summary: Estimate Transaction Fees
      description: >-
        Use this endpoint to estimate the fees for a transaction. It helps
        validate expected charges before processing.
      parameters:
        - $ref: '#/components/parameters/Authorization'
        - $ref: '#/components/parameters/ContentType'
        - $ref: '#/components/parameters/XOrganizationId'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EstimateRequest'
            example:
              packageId: 0196251d-a93a-7c42-9eef-c9f463470e21
              ledgerId: 019c96a0-0ac0-7de9-9f53-9cf842a2ee5a
              transaction:
                chartOfAccountsGroupName: pix
                description: Test FEE
                route: pix
                pending: false
                send:
                  asset: BRL
                  value: '4000.00'
                  source:
                    from:
                      - amount:
                          asset: BRL
                          value: '4000.00'
                        accountAlias: customer-brl-1
                        description: New Transaction
                  distribute:
                    to:
                      - amount:
                          asset: BRL
                          value: '4000.00'
                        accountAlias: business-brl-5
                        description: New Transaction
      responses:
        '200':
          description: >-
            Indicates that the resource was successfully created and the
            operation was completed as expected.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EstimateResponse'
              examples:
                withFees:
                  summary: Estimated transaction with fees applied
                  value:
                    message: Successfully estimated fee.
                    feesApplied:
                      segmentId: 019c96a0-0b4e-7079-8be0-ab6bdccf975f
                      ledgerId: 019c96a0-0ac0-7de9-9f53-9cf842a2ee5a
                      transaction:
                        route: 019c96a0-10a0-72d2-9fb0-2b7de8093182
                        description: Fee Example
                        pending: false
                        metadata:
                          packageAppliedID: 01962565-8d57-737b-abfa-84c3a15eeb15
                        send:
                          asset: BRL
                          value: '4175.00'
                          source:
                            from:
                              - accountAlias: customer-brl-1
                                amount:
                                  asset: BRL
                                  value: '1000.00'
                                route: pixdebit
                                metadata: null
                              - accountAlias: customer-brl-2
                                amount:
                                  asset: BRL
                                  value: '1000.00'
                                route: pixdebit
                                metadata: null
                              - accountAlias: customer-brl-3
                                amount:
                                  asset: BRL
                                  value: '1000.00'
                                route: pixdebit
                                metadata: null
                              - accountAlias: customer-brl-4
                                amount:
                                  asset: BRL
                                  value: '1175.00'
                                route: pixdebit
                                metadata: null
                          distribute:
                            to:
                              - accountAlias: business-brl-1
                                amount:
                                  asset: BRL
                                  value: '4175.00'
                                route: pixcredit
                                metadata: null
                noMatch:
                  summary: No fee or gratuity rule matched
                  value:
                    message: >-
                      No fee or gratuity rules were found for the given
                      parameters.
                    feesApplied: null
          headers: {}
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Error0001:
                  $ref: '#/components/examples/Error0001'
                Error0002:
                  $ref: '#/components/examples/Error0002'
                Error0003:
                  $ref: '#/components/examples/Error0003'
                Error0012:
                  $ref: '#/components/examples/Error0012'
                Error0020:
                  $ref: '#/components/examples/Error0020'
                Error0022:
                  $ref: '#/components/examples/Error0022'
                Error0037:
                  $ref: '#/components/examples/Error0037'
                Error0049:
                  $ref: '#/components/examples/Error0049'
          headers: {}
        '500':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Error0004:
                  $ref: '#/components/examples/Error0004'
          headers: {}
        '503':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Error0021:
                  $ref: '#/components/examples/Error0021'
          headers: {}
      security: []
components:
  parameters:
    Authorization:
      name: Authorization
      in: header
      description: >-
        The authorization token in the 'Bearer <token>' format.  


        **Important:** This header is required if your environment has Access
        Manager enabled. For more information, refer to the [Access
        Manager](/en/access-manager) documentation.
      required: false
      schema:
        type: string
    ContentType:
      name: Content-Type
      in: header
      description: The type of media of the resource. Must be `application/json`.
      required: true
      schema:
        type: string
        example: application/json
    XOrganizationId:
      name: X-Organization-Id
      in: header
      description: The unique identifier of the Organization associated with the request.
      required: true
      schema:
        type: string
        example: 019c96a0-0a98-7287-9a31-786e0809c769
  schemas:
    EstimateRequest:
      type: object
      properties:
        packageId:
          type: string
          description: Unique identifier of the package that you want to use.
        ledgerId:
          type: string
          description: >-
            Unique identifier of the Ledger the package is linked to in the
            Midaz Ledger.
        transaction:
          $ref: '#/components/schemas/Transactions'
      required:
        - packageId
        - ledgerId
        - transaction
    EstimateResponse:
      type: object
      description: >
        Result of the fee estimation. `message` is always returned with the
        result of the evaluation.

        `feesApplied` is `null` when no fee or gratuity rule matches the request
        (for example, on gratuity or when no rules apply); otherwise it contains
        the estimated transaction enriched with fees.
      properties:
        message:
          type: string
          description: >-
            Result of the fee evaluation. If no matching rules are found, it
            provides an informational message.
        feesApplied:
          type: object
          nullable: true
          description: >-
            Estimated transaction with the fees applied, or `null` when no fee
            or gratuity rule matches.
          properties:
            segmentId:
              type: string
              description: >-
                Unique identifier of the Segment linked to the package in the
                Midaz Ledger.
            ledgerId:
              type: string
              description: >-
                Unique identifier of the Ledger linked to the package in the
                Midaz Ledger.
            transaction:
              $ref: '#/components/schemas/Transactions'
      required:
        - message
    Error:
      type: object
      properties:
        code:
          type: string
          description: A unique, stable identifier for the error.
        title:
          type: string
          description: A brief summary of the issue.
        message:
          type: string
          description: Detailed guidance for resolving the error.
      required:
        - code
        - title
        - message
      description: The response message error.
    Transactions:
      type: object
      description: Information about the transaction to which the fee applies.
      properties:
        chartOfAccountsGroupName:
          type: string
          description: >-
            The chart of accounts group name which categorizes this transaction
            under a specific group.
        route:
          type: string
          description: >-
            The main accounting route of the transaction, representing the
            nature and general purpose of the transactional event. Used to
            categorize and group related operations in the general ledger. Same
            information as the `transactionRoute` field in the package.
        transactionRoute:
          type: string
          description: >-
            Alternative field for `route`. The main accounting route of the
            transaction. Either `route` or `transactionRoute` can be used.
        pending:
          type: boolean
          description: Indicates if the transaction is pending.
        description:
          type: string
          description: A description for the transaction.
        metadata:
          type: object
          description: >-
            An object containing key-value pairs to add as metadata, where the
            field `name` is the key and the field `value` is the value. For
            example, to add a Cost Center, use `costCenter: BR_11101997`.
          additionalProperties:
            type: string
        send:
          type: object
          description: Information about the transaction that will be sent.
          properties:
            asset:
              type: string
              description: The code that identifies the asset that will be sent.
            value:
              type: string
              description: >-
                The amount that will be sent. **Important:** Use a dot (`.`) as
                the decimal separator — commas are not accepted.
            source:
              type: object
              properties:
                from:
                  type: array
                  items:
                    $ref: '#/components/schemas/Operations'
                remaining:
                  type: string
                  description: >-
                    The remaining amount or percentage that will be distributed
                    among the source accounts. **Important:** Use a dot (`.`) as
                    the decimal separator — commas are not accepted.
              description: >-
                The list of accounts that will be used as source (DEBIT
                operations).
              required:
                - from
            distribute:
              type: object
              properties:
                to:
                  type: array
                  items:
                    $ref: '#/components/schemas/Operations'
                remaining:
                  type: string
                  description: >-
                    The remaining amount or percentage that will be distributed
                    among the destination accounts. **Important:** Use a dot
                    (`.`) as the decimal separator — commas are not accepted.
              description: A list of the accounts to which the amount will be transferred.
              required:
                - to
          required:
            - asset
            - value
            - source
            - distribute
      required:
        - route
        - send
    Operations:
      type: object
      properties:
        accountAlias:
          type: string
          description: The alias of the account used in the operation.
        amount:
          type: object
          properties:
            asset:
              type: string
              description: The name of the asset used in the operation.
            value:
              type: string
              description: >-
                The amount that will be sent. **Important:** Use a dot (`.`) as
                the decimal separator — commas are not accepted.
          required:
            - asset
            - value
          description: Information about the amount that will be used in the operation.
        share:
          type: object
          properties:
            percentage:
              type: string
              description: The percentage that will be shared.
            percentageOfPercentage:
              type: string
              description: The percentage of the percentage that will be shared.
            route:
              type: string
              description: >-
                The main accounting route that defines the nature of the
                transaction. Helps group related operations in the ledger.
            metadata:
              type: object
              description: >-
                An object containing key-value pairs to add as metadata, where
                the field `name` is the key and the field `value` is the value.
                For example, to add a Cost Center, use `costCenter:
                BR_11101997`.
              additionalProperties:
                type: string
          description: >-
            If different accounts are part of the operation, this object will
            contain the information about the percentage used for each account.
          required: null
        remaining:
          type: string
          description: >-
            The remaining amount or percentage that will be sent to an account.
            **Important:** Use a dot (`.`) as the decimal separator — commas are
            not accepted.
        rate:
          type: object
          description: >-
            Rate information for the operation (used for currency conversions or
            rate-based operations).
        description:
          type: string
          description: A description for the operation.
        route:
          type: string
          description: >-
            The main accounting route that defines the nature of the
            transaction. Helps group related operations in the ledger.
        metadata:
          type: object
          description: >-
            An object containing key-value pairs to add as metadata, where the
            field `name` is the key and the field `value` is the value. For
            example, to add a Cost Center, use `costCenter: BR_11101997`.
          additionalProperties:
            type: string
      required:
        - accountAlias
  examples:
    Error0001:
      summary: Unexpected fields in the request
      value:
        code: FEE-0001
        title: Unexpected fields in the request
        message: >-
          The request body contains more fields than expected. Please send only
          the allowed fields as per the documentation. The unexpected fields are
          listed in the fields object.
    Error0002:
      summary: Missing fields in request
      value:
        code: FEE-0002
        title: Missing fields in request
        message: >-
          Your request is missing one or more required fields. Please refer to
          the documentation to ensure all necessary fields are included in your
          request.
    Error0003:
      summary: Bad request
      value:
        code: FEE-0003
        title: Bad request
        message: >-
          The server could not understand the request due to malformed syntax.
          Please check the listed fields and try again.
    Error0012:
      summary: Entity not found
      value:
        code: FEE-0012
        title: Entity not found
        message: >-
          No entity was found for the given ID. Please make sure to use the
          correct ID for the entity you are trying to manage.
    Error0020:
      summary: Missing header
      value:
        code: FEE-0020
        title: Missing header
        message: >-
          Headers parameters is required. Please check the following header
          parameters %v and ensure they are passing the values correctly.
    Error0022:
      summary: Failed to calculate fee
      value:
        code: FEE-0022
        title: Failed to calculate fee
        message: Error to make the calculation of a fee about a transaction.
    Error0037:
      summary: Error to distribute values
      value:
        code: FEE-0037
        title: Error to distribute values
        message: >-
          Error to try distribute the values of send object. Please check the
          data passed.
    Error0049:
      summary: deductible value forbidden
      value:
        code: FEE-0049
        title: deductible value forbidden
        message: >-
          Can not update deductible value to true. The calculation value is
          bigger than 100%% for Fee %v.
    Error0004:
      summary: Internal Server Error
      value:
        code: FEE-0004
        title: Internal Server Error
        message: >-
          The server encountered an unexpected error. Please try again later or
          contact support.
    Error0021:
      summary: Invalid transaction type
      value:
        code: FEE-0021
        title: Invalid transaction type
        message: >-
          Only one transaction type ('amount', 'share', or 'remaining') must be
          specified in the '%v' field for each entry. Please review your input
          and try again.

````