Add Identity to your app
Use Identity to verify user data
In this guide, we'll start from scratch and walk through how to use Identity to retrieve identity data. If you are already familiar with using Plaid and are set up to make calls to the Plaid API, you can skip ahead to Matching identity data (for /identity/match
) or Fetching identity data (for /identity/get
).
Get Plaid API keys and complete application and company profile
If you don't already have one, you'll need to create a Plaid developer account. After creating your account, you can find your API keys under the Team Settings menu on the Plaid Dashboard.
You will also need to complete your application profile and company profile on the Dashboard. The information in your profile will be shared with users of your application when they manage their connection on the Plaid Portal. Your application profile and company profile must be completed before connecting to certain institutions in Production.
Install and initialize Plaid libraries
You can use our official server-side client libraries to connect to the Plaid API from your application:
1// Install via npm2npm install --save plaid
After you've installed Plaid's client libraries, you can initialize them by passing in your client_id
, secret
, and the environment you wish to connect to (Sandbox or Production). This will make sure the client libraries pass along your client_id
and secret
with each request, and you won't need to explicitly include them in any other calls.
In the code samples below, you will need to replace PLAID_CLIENT_ID
and PLAID_SECRET
with your own keys, which you can obtain from the Dashboard. These code samples also demonstrate starting up a server commonly used in each framework (such as Express or Flask).
1// Using Express2const express = require('express');3const app = express();4app.use(express.json());56const { Configuration, PlaidApi, PlaidEnvironments } = require('plaid');78const configuration = new Configuration({9 basePath: PlaidEnvironments.sandbox,10 baseOptions: {11 headers: {12 'PLAID-CLIENT-ID': process.env.PLAID_CLIENT_ID,13 'PLAID-SECRET': process.env.PLAID_SECRET,14 },15 },16});1718const client = new PlaidApi(configuration);
Create an Item in Link
Plaid Link is a drop-in module that provides a secure, elegant authentication flow for each institution that Plaid supports. Link makes it secure and easy for users to connect their bank accounts to Plaid. Note that these instructions cover Link on the web. For instructions on using Link within mobile apps, see the Link documentation.
Using Link, we will create a Plaid Item, which is a Plaid term for a login at a financial institution. An Item is not the same as a financial institution account, although every account will be associated with an Item. For example, if a user has one login at their bank that allows them to access both their checking account and their savings account, a single Item would be associated with both of those accounts. If you want to customize Link's look and feel, you can do so from the Dashboard.
Before initializing Link, you will need to create a new link_token
on the server side of your application.
A link_token
is a short-lived, one-time use token that is used to authenticate your app with Link.
You can create one using the /link/token/create
endpoint. Then, on the client side of your application, you'll need to initialize Link with the link_token
that you just created.
Create a link_token
1app.post('/api/create_link_token', async function (request, response) {2 // Get the client_user_id by searching for the current user3 const user = await User.find(...);4 const clientUserId = user.id;5 const request = {6 user: {7 // This should correspond to a unique id for the current user.8 client_user_id: clientUserId,9 },10 client_name: 'Plaid Test App',11 products: ['identity'],12 language: 'en',13 webhook: 'https://webhook.example.com',14 redirect_uri: 'https://domainname.com/oauth-page.html',15 country_codes: ['US'],16 };17 try {18 const createTokenResponse = await client.linkTokenCreate(request);19 response.json(createTokenResponse.data);20 } catch (error) {21 // handle error22 }23});
Install Link dependency
1<head>2 <title>Connect a bank</title>3 <script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script>4</head>
Configure the client-side Link handler
1const linkHandler = Plaid.create({2 token: (await $.post('/create_link_token')).link_token,3 onSuccess: (public_token, metadata) => {4 // Send the public_token to your app server.5 $.post('/exchange_public_token', {6 public_token: public_token,7 });8 },9 onExit: (err, metadata) => {10 // Optionally capture when your user exited the Link flow.11 // Storing this information can be helpful for support.12 },13 onEvent: (eventName, metadata) => {14 // Optionally capture Link flow events, streamed through15 // this callback as your users connect an Item to Plaid.16 },17});1819linkHandler.open();
Get a persistent access_token
Next, on the server side, we need to exchange our public_token
for an access_token
and item_id
. The access_token
will allow us to make authenticated calls to the Plaid API. Doing so is as easy as calling the /item/public_token/exchange
endpoint from our server-side handler. We'll use the client library we configured earlier to make the API call.
Save the access_token
and item_id
in a secure datastore, as they’re used to access Item
data and identify webhooks
, respectively. The access_token
will remain valid unless you actively chose to expire it via rotation or remove the corresponding Item via /item/remove
. The access_token
should be stored securely, and never in client-side code. A public_token
is a one-time use token with a lifetime of 30 minutes, so there is no need to store it.
1app.post('/api/exchange_public_token', async function (2 request,3 response,4 next,5) {6 const publicToken = request.body.public_token;7 try {8 const response = await client.itemPublicTokenExchange({9 public_token: publicToken,10 });1112 // These values should be saved to a persistent database and13 // associated with the currently signed-in user14 const accessToken = response.data.access_token;15 const itemID = response.data.item_id;1617 res.json({ public_token_exchange: 'complete' });18 } catch (error) {19 // handle error20 }21});
Now that the authentication step is out of the way, we can begin using authenticated endpoints from the Plaid API.
Matching Identity data
To match Identity data, call /identity/match
.
If you are using Identity Verification, you can automatically match data from the linked account against data collected during the Identity Verification flow. To enable this setting, from the Identity Verification section of the Dashboard, access the template editor and on the "Setup" pane of the template, check the box under the "Financial Account Matching" header. If this option is selected, you should call /identity/match
with only an access_token
to obtain match scores.
If you are not using Identity Verification, you will need to send the identity information that you have on file and would like to match against, such as name, phone number, and address, as part of your call to /identity/match
.
1// Match identity provided by client against bank/account identity2const request: IdentityMatchRequest = {3 access_token: accessToken,4};5try {6 const response = await plaidClient.identityMatch(request);7 const accounts = response.data.accounts;8 for (var account of accounts) {9 const legalNameScore = account.legal_name?.score;10 const phoneScore = account.phone_number?.score;11 const emailScore = account.email_address?.score;12 const addressScore = account.address?.score;13 }14} catch (error) {15 // handle error16}
The call to /identity/match
will return a match score for each field that was evaluated. Typically, your threshold to accept the field as a match should be set to at least 70. For more details, see the match score table.
1{2 "accounts": [3 {4 "account_id": "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp",5 "balances": {6 "available": null,7 "current": null,8 "iso_currency_code": null,9 "limit": null,10 "unofficial_currency_code": null11 },12 "mask": "0000",13 "name": "Plaid Checking",14 "official_name": "Plaid Gold Standard 0% Interest Checking",15 "legal_name": {16 "score": 90,17 "is_nickname_match": true,18 "is_first_name_or_last_name_match": true,19 "is_business_name_detected": false20 },21 "phone_number": {22 "score": 10023 },24 "email_address": {25 "score": 10026 },27 "address": {28 "score": 100,29 "is_postal_code_match": true30 },31 "subtype": "checking",32 "type": "depository"33 },34 {35 "account_id": "3gE5gnRzNyfXpBK5wEEKcymJ5albGVUqg77gr",36 "balances": {37 "available": null,38 "current": null,39 "iso_currency_code": null,40 "limit": null,41 "unofficial_currency_code": null42 },43 "mask": "1111",44 "name": "Plaid Saving",45 "official_name": "Plaid Silver Standard 0.1% Interest Saving",46 "legal_name": {47 "score": 30,48 "is_first_name_or_last_name_match": false49 },50 "phone_number": {51 "score": 10052 },53 "email_address": null,54 "address": {55 "score": 100,56 "is_postal_code_match": true57 },58 "subtype": "savings",59 "type": "depository"60 }61 ...62}
Fetching Identity data
If you are not using Identity Match, call /identity/get
to obtain Identity data. You will need to implement your own matching algorithm to determine whether the data returned matches the information that you have on file about the user. For more detailed information on the schema returned, see /identity/get
.
1const { IdentityGetRequest } = require('plaid');23// Pull Identity data for an Item4const request: IdentityGetRequest = {5 access_token: accessToken,6};7try {8 const response = await plaidClient.identityGet(request);9 const identities = response.data.accounts.flatMap(10 (account) => account.owners,11 );12} catch (error) {13 // handle error14}
Example response data is below.
1{2 "accounts": [3 {4 "account_id": "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp",5 "balances": {6 "available": 100,7 "current": 110,8 "iso_currency_code": "USD",9 "limit": null,10 "unofficial_currency_code": null11 },12 "mask": "0000",13 "name": "Plaid Checking",14 "official_name": "Plaid Gold Standard 0% Interest Checking",15 "owners": [16 {17 "addresses": [18 {19 "data": {20 "city": "Malakoff",21 "country": "US",22 "postal_code": "14236",23 "region": "NY",24 "street": "2992 Cameron Road"25 },26 "primary": true27 },28 {29 "data": {30 "city": "San Matias",31 "country": "US",32 "postal_code": "93405-2255",33 "region": "CA",34 "street": "2493 Leisure Lane"35 },36 "primary": false37 }38 ],39 "emails": [40 {41 "data": "accountholder0@example.com",42 "primary": true,43 "type": "primary"44 },45 {46 "data": "accountholder1@example.com",47 "primary": false,48 "type": "secondary"49 }50 ],51 "names": ["Alberta Bobbeth Charleson"],52 "phone_numbers": [53 {54 "data": "1112223333",55 "primary": false,56 "type": "home"57 },58 {59 "data": "1112224444",60 "primary": false,61 "type": "work"62 },63 {64 "data": "1112225555",65 "primary": false,66 "type": "mobile1"67 }68 ]69 }70 ],71 "subtype": "checking",72 "type": "depository"73 }74 ],75 "item": {76 "available_products": ["balance", "credit_details", "investments"],77 "billed_products": [78 "assets",79 "auth",80 "identity",81 "liabilities",82 "transactions"83 ],84 "consent_expiration_time": null,85 "error": null,86 "institution_id": "ins_3",87 "item_id": "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6",88 "webhook": "https://www.genericwebhookurl.com/webhook"89 },90 "request_id": "3nARps6TOYtbACO"91}
Tutorial and example code in Plaid Pattern
For a real-life example of an app that incorporates Identity, see the Node-based Plaid Pattern Account Funding sample app. Pattern Account Funding is a sample account funding app that fetches Identity data in order verify identity prior to a funds transfer. The Identity code can be found in items.js.
For a tutorial walkthrough of creating a similar app, see Account funding tutorial.
Next steps
If you're ready to launch to Production, see the Launch checklist.