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

# Credit a received Pix refund whose ledger credit is parked

> Credits a received Pix refund (a devolução that your institution received) that BACEN settled and whose ledger credit to the account of the original sender Pix Lerian parked. The refund is `PROCESSING`, and the `refund.credit_parked` event named it with its reason: the `id` of the event is `{id}`, and its `accountId` is `X-Account-Id`, which finds the refund and does not authorize the call. On success the refund is `COMPLETED`, and Pix Lerian sends `refund.completed`. The request has no body.

The call never credits twice, whoever calls it and however often. When the ledger already lists the credit, the call completes the refund without posting a second credit (`200`). Otherwise it posts the credit only while the ledger still answers the idempotency key of every earlier attempt, or after the ledger refused every earlier attempt. In any other case it answers `409` (`PIX-0474`): the ledger cannot confirm the credit, the refund stays parked, and the credit is reconciled by hand. Never credit by hand in the ledger outside that reconciliation.

The reason of the event decides who calls it. `LEDGER_OUTCOME_UNKNOWN` and `SETTLE_INTERRUPTED`: call it right away, by a person or by automation. A credit whose outcome is unknown can be completed for 45 minutes after the park: call at once, and retry a `502` until then. `ACCOUNT_BLOCKED` and `LEDGER_REFUSED`: do not call it automatically. Fix the cause first (unblock the account, or fix the account, alias, balance, credentials or ledger configuration). The first call then parks the refund again as `LEDGER_OUTCOME_UNKNOWN` and starts a one-way 45-minute clock.

A ledger without `overrides.allowFeeSkip` refuses the fee skip that the credit requires (`502`, `PIX-0652`; the detail names the setting) and posts nothing. Call again within 45 minutes of the first refused call, once the setting is on: after that, the refund falls to the `PIX-0474` reconciliation. The caller needs the refunds permission with the post action, the same permission that creates a refund.



## OpenAPI

````yaml /pt/openapi/v3-current/pix-lerian-spi.yaml post /refunds/{id}/credit
openapi: 3.1.0
info:
  contact:
    name: Lerian Studio
    url: https://lerian.studio
  description: Public API for outbound Pix transfers, refunds, and scheduled payments.
  license:
    name: Lerian Studio General License
  title: Pix Lerian — Payments
  version: 1.2.0
servers:
  - url: https://api.example.com/spi/v1
    description: >-
      Replace the example host with the URL provided during environment
      onboarding.
security:
  - BearerAuth: []
tags:
  - description: Create, list, and retrieve Pix refunds.
    name: Refunds
  - name: Scheduled Payments
    description: Register, list, retrieve, and cancel scheduled Pix payments.
  - description: Initiate, process, list, and retrieve outbound Pix transfers.
    name: Transfers
  - description: >-
      Register, list, retrieve, and cancel recurring series of scheduled Pix
      payments.
    name: Scheduled Payment Recurrences
  - description: >-
      Hold the funds of a received Pix in a cautionary block (MED 2.0), return
      them to the payer, or give them back to the account holder.
    name: Balance Locks
paths:
  /refunds/{id}/credit:
    post:
      tags:
        - Refunds
      summary: Credit a received Pix refund whose ledger credit is parked
      description: >-
        Credits a received Pix refund (a devolução that your institution
        received) that BACEN settled and whose ledger credit to the account of
        the original sender Pix Lerian parked. The refund is `PROCESSING`, and
        the `refund.credit_parked` event named it with its reason: the `id` of
        the event is `{id}`, and its `accountId` is `X-Account-Id`, which finds
        the refund and does not authorize the call. On success the refund is
        `COMPLETED`, and Pix Lerian sends `refund.completed`. The request has no
        body.


        The call never credits twice, whoever calls it and however often. When
        the ledger already lists the credit, the call completes the refund
        without posting a second credit (`200`). Otherwise it posts the credit
        only while the ledger still answers the idempotency key of every earlier
        attempt, or after the ledger refused every earlier attempt. In any other
        case it answers `409` (`PIX-0474`): the ledger cannot confirm the
        credit, the refund stays parked, and the credit is reconciled by hand.
        Never credit by hand in the ledger outside that reconciliation.


        The reason of the event decides who calls it. `LEDGER_OUTCOME_UNKNOWN`
        and `SETTLE_INTERRUPTED`: call it right away, by a person or by
        automation. A credit whose outcome is unknown can be completed for 45
        minutes after the park: call at once, and retry a `502` until then.
        `ACCOUNT_BLOCKED` and `LEDGER_REFUSED`: do not call it automatically.
        Fix the cause first (unblock the account, or fix the account, alias,
        balance, credentials or ledger configuration). The first call then parks
        the refund again as `LEDGER_OUTCOME_UNKNOWN` and starts a one-way
        45-minute clock.


        A ledger without `overrides.allowFeeSkip` refuses the fee skip that the
        credit requires (`502`, `PIX-0652`; the detail names the setting) and
        posts nothing. Call again within 45 minutes of the first refused call,
        once the setting is on: after that, the refund falls to the `PIX-0474`
        reconciliation. The caller needs the refunds permission with the post
        action, the same permission that creates a refund.
      operationId: creditParkedRefund
      parameters:
        - description: >-
            REQUIRED. Client-supplied replay key, at most 64 bytes. A request
            without it is refused with PIX-0030 @ 400 before the handler runs.
            An identical resend within 1 hour returns the original response,
            status included, with X-Idempotency-Replayed: true. Reusing the key
            with a divergent method, URL or body is PIX-0031 @ 412.
          in: header
          name: X-Idempotency
          required: true
          schema:
            maxLength: 64
            minLength: 1
            type: string
        - description: 'Refund UUID: the id of the refund.credit_parked event'
          in: path
          name: id
          required: true
          schema:
            description: 'Refund UUID: the id of the refund.credit_parked event'
            examples:
              - 019a3c41-7e2b-7d10-9c4a-5b6e7f805678
            type: string
        - description: >-
            The credited account UUID: the accountId of the refund.credit_parked
            event (the original payment's source account). It finds the refund;
            it does not authorize the call
          in: header
          name: X-Account-Id
          required: true
          schema:
            description: >-
              The credited account UUID: the accountId of the
              refund.credit_parked event (the original payment's source
              account). It finds the refund; it does not authorize the call
            examples:
              - 019cadd4-5620-7c2d-8e3f-4a5b6c7d8e9f
            type: string
        - description: >-
            Who is acting. Declared by the caller; not verified against the
            access token
          in: header
          name: X-Actor-Id
          schema:
            description: >-
              Who is acting. Declared by the caller; not verified against the
              access token
            examples:
              - backoffice.ops@example.com
            type: string
        - description: Why the caller is acting
          in: header
          name: X-Override-Reason
          schema:
            description: Why the caller is acting
            examples:
              - manual devolution paid by Pix
            type: string
        - description: Ticket reference
          in: header
          name: X-Override-Ticket
          schema:
            description: Ticket reference
            examples:
              - MED-4821
            type: string
        - description: Correlation id
          in: header
          name: X-Correlation-Id
          schema:
            description: Correlation id
            examples:
              - med-2026-000123
            type: string
        - description: Request id
          in: header
          name: X-Request-Id
          schema:
            description: Request id
            examples:
              - 01a17e29-5302-7c0a-b5e1-94d2f6a83c17
            type: string
      responses:
        '200':
          content:
            application/json:
              example:
                id: 019a3c41-7e2b-7d10-9c4a-5b6e7f805678
                accountId: 019cadd4-5620-7c2d-8e3f-4a5b6c7d8e9f
                originalEndToEndId: E12345678202610281015AbCdEf12345
                returnEndToEndId: D87654321202610291430FeDcBa54321
                status: COMPLETED
                type: INBOUND
                amount: '40.00'
                reasonCode: MD06
                description: Valor enviado em duplicidade
                ledger:
                  transactionId: 019a3c52-1aff-7d11-a2b3-c4d5e6f70819
                  sourceOperationId: 019a3c52-1aff-7d12-a2b3-c4d5e6f7081a
                  destinationOperationId: 019a3c52-1aff-7d13-a2b3-c4d5e6f7081b
                createdAt: '2026-10-29T14:30:05.412Z'
                updatedAt: '2026-10-29T14:52:41.087Z'
              schema:
                $ref: '#/components/schemas/RefundCashoutOutput'
          description: OK
        '400':
          content:
            application/json:
              example:
                code: PIX-0030
                title: Idempotency Key Required
                message: >-
                  The X-Idempotency header is required for this operation and
                  must be within the accepted length.
              schema:
                $ref: '#/components/schemas/LegacyErrorEnvelope'
            application/problem+json:
              example:
                type: https://errors.lerian.studio/v1/PIX-0001
                title: Bad Request
                status: 400
                detail: Your request is missing one or more required header params.
                code: PIX-0001
              schema:
                $ref: '#/components/schemas/Detail'
          description: >-
            A missing (PIX-0001) or malformed (PIX-0017) X-Account-Id, a refund
            id that is not a UUID (PIX-0015), or an attribution header over its
            length limit (PIX-0003). A duplicated or padded X-Account-Id or
            attribution header (PIX-0001). X-Idempotency absent or longer than
            64 bytes (PIX-0030). Legacy {code,title,message} envelope, NOT
            problem+json. Route-guard refusals (PIX-0001) answer in the legacy
            {code,title,message} envelope too.
        '404':
          content:
            application/problem+json:
              example:
                type: https://errors.lerian.studio/v1/PIX-0420
                title: Not Found
                status: 404
                detail: Refund ID does not exist for this organization.
                code: PIX-0420
              schema:
                $ref: '#/components/schemas/Detail'
          description: No refund with this id credits the X-Account-Id account (PIX-0420).
        '409':
          content:
            application/problem+json:
              example:
                type: https://errors.lerian.studio/v1/PIX-0474
                title: Conflict
                status: 409
                detail: The ledger cannot confirm this credit; reconcile it by hand.
                code: PIX-0474
              schema:
                $ref: '#/components/schemas/Detail'
          description: >-
            `PIX-0523`: not a parked inbound refund. `PIX-0474`: the ledger
            cannot confirm the credit, so the refund stays parked and the credit
            is reconciled by hand.
        '412':
          content:
            application/json:
              example:
                code: PIX-0031
                title: Idempotency Key Conflict
                message: >-
                  The X-Idempotency header is held by a request still running or
                  whose receipt could not be stored, or was already used with a
                  different request.
              schema:
                $ref: '#/components/schemas/LegacyErrorEnvelope'
          description: >-
            Refused under this X-Idempotency (PIX-0031): the first request under
            it is still running (with Retry-After: 1), its receipt could not be
            stored and the key is held for the hour, or the request differs from
            the first (method, URL, body or identity header). An earlier request
            under this key may already have executed. Legacy
            {code,title,message} envelope, NOT problem+json.
        '422':
          content:
            application/problem+json:
              example:
                type: https://errors.lerian.studio/v1/PIX-0328
                title: Unprocessable Entity
                status: 422
                detail: >-
                  The ledger account is blocked and cannot be used for the
                  requested operation.
                code: PIX-0328
              schema:
                $ref: '#/components/schemas/Detail'
          description: >-
            `PIX-0328`: the credited ledger account is blocked, and the refund
            stays parked as `LEDGER_OUTCOME_UNKNOWN`: unblock it and retry
            within 45 minutes. `PIX-0475`: the ledger refused the credit for a
            cause that a retry does not clear (an account status that forbids
            receiving, a closed account, a usage limit, a missing alias,
            balance, asset, ledger or organization, or more than one ledger fee
            package matching the credit), and the refund stays parked: fix the
            cause, then retry within 45 minutes. A closed account, or one
            without an alias, is final: no call credits it.
        '500':
          content:
            application/json:
              example:
                code: PIX-0000
                title: Internal Server Error
                message: >-
                  The server encountered an unexpected error. Please try again
                  later.
              schema:
                $ref: '#/components/schemas/LegacyErrorEnvelope'
            application/problem+json:
              example:
                type: https://errors.lerian.studio/v1/PIX-0000
                title: Internal Server Error
                status: 500
                detail: >-
                  The server could not complete the request. Please try again
                  later.
                code: PIX-0000
              schema:
                $ref: '#/components/schemas/Detail'
          description: >-
            Unexpected server error (PIX-0000). The refund is parked or already
            COMPLETED: call again.
        '502':
          content:
            application/problem+json:
              example:
                type: https://errors.lerian.studio/v1/PIX-0522
                title: Bad Gateway
                status: 502
                detail: >-
                  The server could not complete the request. Please try again
                  later.
                code: PIX-0522
              schema:
                $ref: '#/components/schemas/Detail'
          description: >-
            `PIX-0522`: the ledger was unreachable, refused the credentials,
            failed the search or the post, or refused the post on a balance that
            another write moved; the refund stays parked: retry within the
            45-minute window, after you fix the credentials when the ledger
            refused them. `PIX-0652`: a ledger without `overrides.allowFeeSkip`
            refuses the fee skip that the credit requires and posts nothing:
            call again within 45 minutes of the first refused call, once the
            setting is on.
        default:
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/Detail'
          description: Error
components:
  schemas:
    RefundCashoutOutput:
      additionalProperties: false
      properties:
        accountId:
          examples:
            - 019606a0-1a2b-7c3d-8e4f-567890123abc
          type: string
        amount:
          examples:
            - '100.00'
          type: string
        createdAt:
          examples:
            - '2026-05-06T10:45:00Z'
          format: date-time
          type: string
        deletedAt:
          format: date-time
          type: string
        description:
          examples:
            - Estorno solicitado pelo pagador
          type: string
        id:
          examples:
            - 019606b1-3b4c-7d8e-9f01-234567890dee
          type: string
        ledger:
          $ref: '#/components/schemas/LedgerInfo'
        metadata:
          additionalProperties: {}
          type: object
        originalEndToEndId:
          examples:
            - E12345678202605061030abcdef12345
          type: string
        reasonCode:
          examples:
            - MD06
          type: string
        returnEndToEndId:
          examples:
            - D12345678202605061045fedcba54321
          type: string
        status:
          examples:
            - COMPLETED
          type: string
        type:
          examples:
            - OUTBOUND
          type: string
        updatedAt:
          examples:
            - '2026-05-06T10:45:30Z'
          format: date-time
          type: string
        feeCharge:
          $ref: '#/components/schemas/FeeChargeResponse'
          description: >-
            Fee the ledger reported on the create that moved the refund's money.
            Absent when no fee answer was recorded for this refund (its ledger
            create never landed, an error was logged at the time, or the refund
            was created before fees were read back); {"applied": false} when the
            ledger reported that no fee was charged; the full object when it
            charged one. A refund carries no ledger.revert field and needs none
            here: a FAILED refund that carries feeCharge was reverted first --
            every path that writes a refund FAILED after its ledger create
            landed reverts the debit before marking it (a revert that does not
            complete leaves the refund PROCESSING), and every other path fails
            before any create -- so the fee was returned with the amount;
            applied reports what the create did and the object records the
            create.
      required:
        - id
        - originalEndToEndId
        - status
        - type
        - amount
        - reasonCode
        - createdAt
        - updatedAt
      type: object
    LegacyErrorEnvelope:
      additionalProperties: false
      properties:
        code:
          description: PIX-XXXX error code
          type: string
        message:
          description: Human-readable error message
          type: string
        title:
          description: Short error title
          type: string
        fields:
          additionalProperties:
            type: string
          description: Per-field detail, keyed by the field or header the refusal names
          type: object
        headers:
          additionalProperties:
            type: string
          description: Per-header detail, keyed by the request header the refusal names
          type: object
      required:
        - code
        - title
        - message
      type: object
    Detail:
      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
    LedgerInfo:
      additionalProperties: false
      properties:
        destinationOperationId:
          examples:
            - 019606a5-7f80-7182-3c4d-56789012cdf1
          type: string
        revert:
          $ref: '#/components/schemas/LedgerRevertInfo'
        sourceOperationId:
          examples:
            - 019606a5-7f80-7182-3c4d-56789012cdf0
          type: string
        transactionId:
          examples:
            - 019606a5-7f80-7182-3c4d-56789012cdef
          type: string
      type: object
    FeeChargeResponse:
      additionalProperties: false
      properties:
        applied:
          examples:
            - true
          type: boolean
          description: >-
            Whether the ledger charged a fee on the create that moved the
            operation's money. When false, no other field is present. applied
            reports what the create did and the object is kept as its record.
            Where the operation carries ledger.revert (transfers only: REJECTED,
            or FAILED after the debit was reverted), the revert inverted the fee
            legs with the amount, so the fee was returned; on a transfer without
            ledger.revert, feeCharge says nothing about the fee's final
            position.
        calculationType:
          examples:
            - LEDGER
          type: string
          description: >-
            How the total fee was calculated. LEDGER when the ledger's fee
            package computed it.
        fees:
          items:
            $ref: '#/components/schemas/FeeEntryResponse'
          type:
            - array
            - 'null'
          description: >-
            Individual fee entries that make up the total, one per ledger fee
            leg.
        netAmount:
          examples:
            - '100.00'
          type: string
          description: >-
            Amount that reached the destination: on an outbound operation what
            the ledger moved to the rail, on an inbound one what it credited to
            the receiving account (the operation's amount when the ledger
            reported no such leg; on an outbound operation a deductible fee
            package, a misconfiguration on a Pix ledger, makes it lower than the
            amount).
        totalAmount:
          examples:
            - '1.50'
          type: string
          description: Sum of every fee entry the ledger charged on the operation.
      required:
        - applied
      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
    LedgerRevertInfo:
      additionalProperties: false
      properties:
        destinationOperationId:
          examples:
            - 019606a5-7f80-7182-3c4d-56789012cdf1
          type: string
        sourceOperationId:
          examples:
            - 019606a5-7f80-7182-3c4d-56789012cdf0
          type: string
        transactionId:
          examples:
            - 019606a5-7f80-7182-3c4d-56789012cdef
          type: string
      type: object
    FeeEntryResponse:
      additionalProperties: false
      properties:
        amount:
          examples:
            - '1.50'
          type: string
          description: Amount of this fee entry.
        calculationType:
          examples:
            - LEDGER
          type: string
          description: >-
            How this entry was calculated. LEDGER when the ledger's fee package
            computed it.
        calculationValue:
          type: string
          description: >-
            Raw value the calculation was parameterised with. Absent when
            calculationType is LEDGER.
        creditAccount:
          examples:
            - '@fees-pix'
          type: string
          description: Ledger account credited with this fee entry.
        feeLabel:
          examples:
            - LEDGER_FEE
          type: string
          description: >-
            Label of this fee entry. LEDGER_FEE on every entry the ledger
            reported: its answer names no fee, so creditAccount is what
            distinguishes one entry from another.
      required:
        - feeLabel
        - amount
      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.