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

# 通过银行链接回答信息请求

> 使用 completeRfiPlaidLink，通过 Plaid 链接银行账户来回答银行对账单或地址证明类 RFI 问题。

## 概述

两种问题类型可以通过链接银行账户来回答，而无需上传文件：

| 问题类型 | 银行链接在以下情况下可回答该问题 |
| - | - |
| `BANK_LINK_OR_STATEMENT` | 银行链接成功 |
| `ADDRESS_VERIFICATION_OR_DOCUMENT` | 银行已链接**并且**确认了客户的地址 |

**completeRfiPlaidLink** mutation 会交换来自 Plaid Link 的 public token，将银行链接到客户的 Fluz 账户，并将该链接保存为问题的答案。

它不会提交 RFI。请随后调用 [submitRfi](https://docs.fluz.app/submit-rfi) 将其提交审核。

## 所需权限范围

| 属性 | 值 |
| - | - |
| 端点 | GraphQL API |
| 身份验证 | OAuth Bearer Token。不接受 Basic 身份验证 |
| 所需权限范围 | `MANAGE_RFI` 和 `MANAGE_PAYMENT` |

需要 `MANAGE_PAYMENT` 是因为该银行还会作为资金来源添加到客户的账户中。`createPlaidLinkToken` 同样需要此权限。

## 流程

**1. 创建 Link token**

使用客户的令牌调用 `createPlaidLinkToken`。请参阅[通过 Plaid 链接银行账户](https://docs.fluz.app/features/link-via-plaid.md)。

**2. 打开 Plaid Link**

使用该 token 打开 Plaid Link。客户完成后，Plaid 会返回 `public_token`。

**3. 调用 completeRfiPlaidLink**

传入 `rfiId`、`questionId` 和 `public_token`。银行将被链接，答案将被保存。

**4. 提交 RFI**

调用 [submitRfi](https://docs.fluz.app/submit-rfi)。请在 `answers` 中省略已链接的问题——已保存的链接已经回答了该问题。

## 基本 mutation 结构

```graphql theme={null}
mutation CompleteRfiPlaidLink($input: CompleteRfiPlaidLinkInput!) {
  completeRfiPlaidLink(input: $input) {
    rfiId
    status
    requiresAddress
    bankAccountId
    bankInstitutionAuthId
    newlyLinkedBankInstitutionAuthId
    bankInstitutionName
    platformItemId
    bankAccounts {
      bankInstitutionAuthId
      bankAccountId
      bankName
      lastFour
      type
      subtype
    }
  }
}
```

## 参数

### CompleteRfiPlaidLinkInput

| 字段 | 类型 | 必填 | 描述 |
| - | - | - | - |
| `rfiId` | `UUID!` | 是 | 要回答的 RFI |
| `questionId` | `String!` | 是 | `BANK_LINK_OR_STATEMENT` 或 `ADDRESS_VERIFICATION_OR_DOCUMENT` 类型的问题。1–200 个字符 |
| `publicToken` | `String!` | 是 | Plaid Link 返回的 `public_token`。以 `public-` 开头，最多 256 个字符 |

## cURL 示例

```bash theme={null}
curl -X POST https://transactional-graph.staging.fluzapp.com/api/v1/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{
    "query": "mutation CompleteRfiPlaidLink($input: CompleteRfiPlaidLinkInput!) { completeRfiPlaidLink(input: $input) { rfiId status bankInstitutionName bankAccounts { bankAccountId bankName lastFour type subtype } } }",
    "variables": {
      "input": {
        "rfiId": "7c1e2a90-4b3d-4f6e-9a18-3d5b2c7e8f01",
        "questionId": "q_address",
        "publicToken": "public-sandbox-5c224a01-8314-4491-a06f-39e193d5cddc"
      }
    }
  }'
```

## 响应详情

### CompleteRfiPlaidLinkResponse

| 字段 | 类型 | 描述 |
| - | - | - |
| `rfiId` | `UUID!` | 输入中的 RFI |
| `status` | `RfiStatus!` | 保持为 `PENDING_DOCUMENTS`。使用 `submitRfi` 将 RFI 提交审核 |
| `requiresAddress` | `Boolean!` | 与 `completePlaidLink` 相同：为 `true` 时，请使用 `createPlaidLinkAddress` 附加地址。请参阅[管理已链接的银行账户](https://docs.fluz.app/features/link-external-bank-accounts.md) |
| `bankAccountId` | `UUID` | 已链接的银行账户 |
| `bankInstitutionAuthId` | `UUID` | 已链接的银行连接 |
| `newlyLinkedBankInstitutionAuthId` | `UUID` | 当本次调用创建了新的银行连接时设置 |
| `bankInstitutionName` | `String` | 银行名称 |
| `platformItemId` | `String` | Plaid item 引用，用于之后修复连接 |
| `bankAccounts` | `[PlaidLinkedBankAccount!]!` | 此连接下已链接的账户 |

### PlaidLinkedBankAccount

| 字段 | 类型 | 描述 |
| - | - | - |
| `bankInstitutionAuthId` | `UUID` | 银行连接 |
| `bankAccountId` | `UUID` | 账户 |
| `bankName` | `String` | 银行名称 |
| `lastFour` | `String` | 账号后四位数字 |
| `type` | `String` | Plaid 账户类型，例如 `depository` |
| `subtype` | `String` | Plaid 账户子类型，例如 `checking` |

```json theme={null}
{
  "data": {
    "completeRfiPlaidLink": {
      "rfiId": "7c1e2a90-4b3d-4f6e-9a18-3d5b2c7e8f01",
      "status": "PENDING_DOCUMENTS",
      "bankInstitutionName": "Chase",
      "bankAccounts": [
        {
          "bankAccountId": "4a8d2f61-9c3e-4b7a-a215-6e0f8b9c1d32",
          "bankName": "Chase",
          "lastFour": "4417",
          "type": "depository",
          "subtype": "checking"
        }
      ]
    }
  }
}
```

此次调用之后，读取该问题时会显示 `isSubmitted: true`，且 `answer` 的类型为 `PLAID_BANK_LINK`。

## 地址类问题

对于 `ADDRESS_VERIFICATION_OR_DOCUMENT` 问题，银行必须确认客户的地址。如果银行未能确认：

* 调用将以 `ADDRESS_NOT_VERIFIED` 失败，且不会保存任何答案，
* 该银行**仍保持链接**在客户的账户上，并且
* 客户可以链接其他银行，或者您可以[上传](https://docs.fluz.app/upload-rfi-document)地址证明文件，并在 `submitRfi` 中回答该问题。

## 替换链接

只要 RFI 仍处于 `PENDING_DOCUMENTS` 状态，就可以针对同一问题再次调用 `completeRfiPlaidLink` 来替换已保存的链接。已通过文件回答的问题无法切换为银行链接。

## 错误代码

失败信息会在顶层 `errors` 数组中返回。RFI 错误带有 `extensions.rfiErrorCode`。

| 代码 | `rfiErrorCode` | 描述 | 解决方法 |
| - | - | - | - |
| `AUTH-0002` | — | 使用了 Basic 身份验证 | 使用 Bearer 用户令牌调用 |
| `AUTH-0008` | — | Bearer 令牌没有 `userId` 或 `accountId` | 为用户和账户生成令牌 |
| `AUTH-0031` | — | 令牌缺少 `MANAGE_RFI` 或 `MANAGE_PAYMENT` | 添加这两个权限范围并重新生成令牌 |
| `G-0003` | `ACCESS_DENIED` | RFI 不存在，或未发送给该令牌对应的用户和账户 | 使用您读取该 RFI 时所用的令牌 |
| `ARG-0001` | `INVALID_INPUT` | `rfiId`、`questionId` 或 `publicToken` 格式不正确 | 检查输入 |
| `ARG-0001` | `RFI_NOT_OPEN` | RFI 当前不在等待回答 | 读取 RFI 以查看其状态 |
| `ARG-0001` | `RFI_EXPIRED` | RFI 已过期 | 引导客户联系支持团队 |
| `ARG-0001` | `UNKNOWN_QUESTION` | 没有具有此 `questionId` 的可回答问题 | 使用 RFI 当前问题中的 `questionId` |
| `ARG-0001` | `NOT_A_LINK_QUESTION` | 该问题不是银行链接或地址类问题 | 在 `submitRfi` 中回答 |
| `ARG-0001` | `ALREADY_SUBMITTED` | 该问题已保存了文件 | 无需操作。该问题已回答 |
| `ARG-0001` | `ADDRESS_NOT_VERIFIED` | 银行未确认客户的地址。`extensions.identityMatchStatus` 给出结果。银行仍保持链接 | 链接其他银行，或上传地址证明 |
| `ARG-0001` | `PLAID_LINK_FAILED` | 无法完成银行链接 | 让客户重新尝试 Plaid Link |
| `ARG-0001` 或 `G-0001` | — | Plaid 无法交换 public token | 使用新的 Link token 重新开始 |

## 相关页面

> [card] [提交 RFI](https://docs.fluz.app/submit-rfi)
>
> 链接后将 RFI 提交审核。

> [card] [通过 Plaid 链接银行账户](https://docs.fluz.app/features/link-via-plaid.md)
>
> `createPlaidLinkToken` 与 Plaid Link 流程。


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