# Finish a bank link for a deal

Trades the public token Plaid Link handed the browser for a long-lived access token, seals it, reads the item's accounts, and records who consented from where. Re-running it for a bank already linked repairs that link rather than adding a second one.

Access class: `def:read`.

## Endpoint

`POST /v1/definitions/{key}/rows/{rowId}/plaid/exchange`

## Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| key | path | string | Yes |
| rowId | path | string | Yes |

## Request body

Content type: `application/json`.

```json
{
  "body": {
    "institutionId": "",
    "institutionName": "string",
    "publicToken": "string"
  },
  "params": {
    ":key": "string",
    ":rowId": ""
  },
  "query": {}
}
```

## Responses

### 201

the action's answer

Content type: `application/json`.

```json
{
  "data": {
    "accounts": [
      {
        "availableBalanceMinor": "string",
        "currency": "string",
        "currentBalanceMinor": "string",
        "id": "",
        "mask": "string",
        "name": "string",
        "officialName": "string",
        "plaidAccountId": "",
        "subtype": "string",
        "type": "string"
      }
    ],
    "consentedAt": "string",
    "consentedByEmail": "string",
    "consentedByKind": "string",
    "consentedByUserId": 1,
    "consentedIp": "string",
    "createdAt": "string",
    "dealId": "",
    "environment": "string",
    "id": "",
    "institutionId": "",
    "institutionName": "string",
    "lastError": "string",
    "lastSyncedAt": "string",
    "plaidItemId": "",
    "status": "string"
  }
}
```

### default

a refusal: `{"error": "<what a person needs to read>"}`. 401 no credential, 402 the plan does not include this, 403 the seat does not, 404 the thing does not exist or is not yours to see.

Content type: `application/json`.

```json
{
  "error": "string"
}
```
