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

# Refund a deposit blocked by the AML check

> Sends a crypto deposit that failed the AML check (`deposit_data.aml_declined`, status `declined`) back out to the given address. Nothing was credited, so nothing is taken back. Callable by the member the deposit was addressed to or the account owner, with `can_withdraw` and the same TOTP rule as withdrawals.

Returns as soon as the crypto service accepts the request. The outcome arrives asynchronously: on success the transaction becomes `canceled` and `deposit_data.refund` carries `tx_hash`, `blockchain_url` and the `amount` sent; on failure `deposit_data.refund.status` is `failed` with an `error_code` and the request can be sent again. Poll POST /transactions for the outcome. Finup charges no fee, but the network fee is taken out of the transfer (on Tron up to 3 USDT).



## OpenAPI

````yaml /openapi.json post /transactions/{transaction_id}/aml-refund
openapi: 3.1.0
info:
  title: Finup Public API
  version: 1.0.0
  description: >-
    Client-facing Finup API reference generated from current public endpoint
    metadata.
servers:
  - url: https://api.finup.io/backend
    description: Production
security: []
tags:
  - name: Accounts
    description: Current account, account setup, and account capabilities.
  - name: Transactions
    description: Account transaction lists and aggregates.
  - name: Cards
    description: Card issuing, listing, funding, and status changes.
paths:
  /transactions/{transaction_id}/aml-refund:
    post:
      tags:
        - Transactions
      summary: Refund a deposit blocked by the AML check
      description: >-
        Sends a crypto deposit that failed the AML check
        (`deposit_data.aml_declined`, status `declined`) back out to the given
        address. Nothing was credited, so nothing is taken back. Callable by the
        member the deposit was addressed to or the account owner, with
        `can_withdraw` and the same TOTP rule as withdrawals.


        Returns as soon as the crypto service accepts the request. The outcome
        arrives asynchronously: on success the transaction becomes `canceled`
        and `deposit_data.refund` carries `tx_hash`, `blockchain_url` and the
        `amount` sent; on failure `deposit_data.refund.status` is `failed` with
        an `error_code` and the request can be sent again. Poll POST
        /transactions for the outcome. Finup charges no fee, but the network fee
        is taken out of the transfer (on Tron up to 3 USDT).
      parameters:
        - name: transaction_id
          in: path
          required: true
          description: Transaction id of the blocked deposit, from POST /transactions.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AmlRefundRequest'
      responses:
        '201':
          description: Success
          content:
            application/json:
              schema:
                type: object
                required:
                  - result
                properties:
                  result:
                    $ref: '#/components/schemas/AmlRefund'
        '400':
          description: >-
            Code missing, or the address is the deposit address, invalid on the
            deposit network, or belongs to Finup
        '401':
          description: Missing or invalid credentials
        '403':
          description: Insufficient permission for this operation
        '404':
          description: Resource not found
        '409':
          description: The deposit is not refundable, or a refund already exists for it
        '422':
          description: Invalid 2FA code
        '428':
          description: 2FA is not enabled for the caller
      security:
        - apiKeyAuth: []
components:
  schemas:
    AmlRefundRequest:
      type: object
      required:
        - withdraw_address
      properties:
        withdraw_address:
          type: string
          minLength: 10
          maxLength: 128
          example: TQ5NMqJjjkDWbYi1dmQ8e3n8ZHPyYsMQxA
          description: >-
            Address the deposit is sent back to, on the network it arrived on.
            Must not be the deposit address itself.
        code:
          type: string
          example: '123456'
          description: >-
            TOTP code. Required unless the account is suspended or blocked and
            the user has no 2FA enabled.
    AmlRefund:
      type: object
      properties:
        status:
          type: string
          enum:
            - requested
            - processing
            - completed
            - failed
          example: requested
          description: >-
            requested — accepted by the crypto service; processing — being sent;
            completed — sent, see tx_hash and blockchain_url, and the
            transaction itself is now canceled; failed — nothing left Finup, the
            deposit is still declined and the refund can be asked for again.
        withdraw_address:
          type: string
          example: TQ5NMqJjjkDWbYi1dmQ8e3n8ZHPyYsMQxA
          description: Address the blocked deposit is being sent back to.
        amount:
          type: string
          nullable: true
          example: null
          description: >-
            Amount actually sent back, in the deposit currency. The provider
            takes the network fee out of the transfer (on Tron up to 3 USDT), so
            it is only known once the refund is sent.
        fee_amount:
          type: string
          nullable: true
          example: null
          description: >-
            Network fee the provider took out of the transfer, in the deposit
            currency; null until the refund is sent.
        tx_hash:
          type: string
          nullable: true
          example: null
          description: Hash of the refund transaction; null until it is confirmed.
        blockchain_url:
          type: string
          nullable: true
          example: null
          description: Block explorer link for tx_hash, ready to show as-is.
        error_code:
          type: string
          nullable: true
          example: null
          description: >-
            Machine-readable failure reason, null unless status is failed:
            insufficient_gas, insufficient_balance, transaction_reverted,
            provider_unavailable or transfer_failed. Map it to your own wording.
        requested_at:
          type: string
          format: date-time
          nullable: true
        completed_at:
          type: string
          format: date-time
          nullable: true
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

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