Exchange Plaid Public Token
This endpoint exchanges a short-lived Plaid publicToken — obtained during the Plaid Link flow — for a long-lived accessToken used to access the user's authorized financial data. The exchange is required before any account balance retrieval, transaction history access, or external account linking can proceed via Plaid. This is version 2 of the token exchange endpoint.
Deprecated: This endpoint is marked deprecated. Use the current Plaid integration endpoints for new implementations.
Endpoint
POST /api/plaidExchangeToken/v2
Authentication
Bearer token required. Obtain via:
POST https://api.banking.netevia.dev/api/auth/v2
Include in header: Authorization: Bearer {token}
Token lifetime: 10 minutes. Refresh via POST /api/auth/refresh.
When to use
Use this endpoint immediately after completing the Plaid Link flow, when your application receives a publicToken from the Plaid SDK. The resulting accessToken is required for all subsequent Plaid API interactions on behalf of the customer, including retrieving account balances, transaction histories, and verifying external accounts for ACH transfers. This applies to personal customers who link external financial accounts.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| publicToken | string | Yes | Short-lived public token returned by the Plaid Link SDK after the user completes the account linking flow. Minimum length: 1. |
| institution | object | Yes | Object identifying the financial institution the user linked. |
| institution.id | string | Yes | Plaid's unique identifier for the institution. Minimum length: 1. |
| institution.name | string | Yes | Human-readable name of the financial institution. Minimum length: 1. |
| accounts | array | Yes | Array of account objects selected by the user during the Plaid Link flow. Must contain at least one account. |
| accounts[].id | string | Yes | Plaid's unique identifier for the account. Minimum length: 1. |
| accounts[].name | string | Yes | Display name of the account (e.g., "Checking"). Minimum length: 1. |
| accounts[].mask | string | Yes | Last four digits of the account number used for display purposes (e.g., "1234"). Minimum length: 1. |
| accounts[].subtype | string | Yes | Account subtype as returned by Plaid (e.g., "checking", "savings"). Minimum length: 1. |
| accounts[].type | string | No | Account type as returned by Plaid (e.g., "depository"). Nullable. |
{
"publicToken": "public-sandbox-abc12345-1234-5678-abcd-abc123456789",
"institution": {
"id": "ins_109508",
"name": "First National Bank"
},
"accounts": [
{
"id": "aBcDeFgHiJkLmNoPqRsTuVwXyZ",
"name": "Checking",
"mask": "4321",
"subtype": "checking",
"type": "depository"
}
]
}Response
200 OK
Returns the Plaid accessToken as a plain string. This token must be stored securely by your application and used for subsequent Plaid API calls on behalf of the user.
| Field | Type | Description |
|---|---|---|
| (response body) | string | The Plaid accessToken corresponding to the exchanged publicToken. |
"access-sandbox-de3ce8ef-33f8-452c-a3d5-8c4b0123abcd"Error Codes
| Code | When it happens |
|---|---|
| 400 | Missing required fields (publicToken, institution, or accounts) or validation error (e.g., empty string values) |
| 401 | Bearer token missing, expired, or invalid |
| 403 | Insufficient permissions to perform the token exchange |
| 404 | Referenced customer or account resource not found |
| 500 | Internal server error or Plaid service unavailable |
Common Mistakes
- Submitting a
publicTokenthat has already been exchanged — Plaid public tokens are single-use and expire after 30 minutes; request a new one via Plaid Link if needed. - Passing an empty
accountsarray — at least one account object must be included in the request. - Omitting required fields inside the
accountsarray objects (id,name,mask,subtypeare all required). - Storing the returned
accessTokeninsecurely — treat it as a sensitive credential equivalent to a password; never log or expose it client-side. - Using this deprecated v2 endpoint for new integrations — check for a current Plaid integration endpoint in the API reference.
Related Endpoints
POST /api/auth/v2— Obtain a Bearer token for authenticating API requestsPOST /api/auth/refresh— Refresh an expiring Bearer tokenGET /api/accounts— Retrieve financial accounts linked to a customer
Example
curl -X POST https://api.banking.netevia.dev/api/plaidExchangeToken/v2 \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"publicToken": "public-sandbox-abc12345-1234-5678-abcd-abc123456789",
"institution": {
"id": "ins_109508",
"name": "First National Bank"
},
"accounts": [
{
"id": "aBcDeFgHiJkLmNoPqRsTuVwXyZ",
"name": "Checking",
"mask": "4321",
"subtype": "checking",
"type": "depository"
}
]
}'