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

# 申請內部轉帳審批

`requestInternalTransfer`

提交管理者審批請求，於同一個 Fluz 帳戶內，將資金在兩個消費帳戶之間移轉。當審批通過後，Fluz 會執行內部轉帳。

此流程不同於帳戶對帳戶的轉帳。當在不同 Fluz 帳戶之間移轉資金時，請使用 `requestAccountTransfer`。參見 [申請帳戶轉帳審批](/features/request-account-transfer-approval)。

## Scopes

| Action | Scope                       |
| ------ | --------------------------- |
| 建立請求   | `REQUEST_INTERNAL_TRANSFER` |
| 列出請求   | `LIST_APPROVALS`            |
| 核准或拒絕  | `MANAGE_APPROVALS`          |

## Webhook 識別碼

| Field          | Value    |
| -------------- | -------- |
| `approvalType` | `PAYOUT` |
| `approvalCode` | `500402` |

Webhook 事件：`APPROVAL_CREATE`、`APPROVAL_APPROVE`、`APPROVAL_DECLINE`，以及在執行失敗時的 `APPROVAL_HANDLER_ERROR`。

> 內部轉帳與帳戶轉帳共用相同的 `approvalType` 與 `approvalCode`。請使用原始請求的 mutation，或在您的整合中檢視審批的 payload 以加以區分。

## 建立請求

### RequestInternalTransferInput

| Field                          | Type  | Required | Description |
| ------------------------------ | ----- | -------- | ----------- |
| `amount`                       | Float | Yes      | 轉帳金額。必須大於零  |
| `sourceUserCashBalanceId`      | UUID  | Yes      | 提領資金的消費帳戶   |
| `destinationUserCashBalanceId` | UUID  | Yes      | 存入資金的消費帳戶   |

來源與目的地必須是不同的消費帳戶。

### 範例 Mutation

```graphql theme={null}
mutation {
  requestInternalTransfer(
    input: {
      amount: 50.00
      sourceUserCashBalanceId: "6d1b4b19-deef-42f5-80d7-ec34804ce090"
      destinationUserCashBalanceId: "bb584e49-d030-4a6e-a5a9-1c34368cbaed"
    }
  ) {
    success
    messageId
    error {
      code
      message
    }
  }
}
```

### 範例回應

```json theme={null}
{
  "data": {
    "requestInternalTransfer": {
      "success": true,
      "messageId": "1234567890"
    }
  }
}
```

## 核准請求

使用 `approvalId` 呼叫 `approveApprovalRequest`。需要 `MANAGE_APPROVALS`。

```graphql theme={null}
mutation {
  approveApprovalRequest(approvalId: "07df5653-43a8-4532-9881-3ab5857bbe12") {
    success
    approvalId
    action
  }
}
```

當核准後，Fluz 會在指定的消費帳戶之間轉移資金。

## 拒絕請求

使用 `approvalId` 呼叫 `declineApprovalRequest`。需要 `MANAGE_APPROVALS`。

```graphql theme={null}
mutation {
  declineApprovalRequest(approvalId: "07df5653-43a8-4532-9881-3ab5857bbe12") {
    success
    approvalId
    action
  }
}
```

當請求被拒絕時，不會執行任何轉帳。
