Create an Asset Report
Learn how to create Asset Reports with the Assets product
In this guide, we'll start from scratch and walk through how to use Assets to generate and retrieve Asset Reports. If a user's Asset Report involves data from multiple financial institutions, the user will need to allow access to each institution, which will in turn enable you to access their data from each institution. If you are already familiar with using Plaid and are set up to make calls to the Plaid API, you can skip ahead to Creating Asset Reports.
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 in the Dashboard. This will provide basic information about your app to help users manage their connection on the Plaid Portal at my.plaid.com. The 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 it in any other calls.
1// Using Express2const express = require('express');3const app = express();4app.use(express.json());5
6const { Configuration, PlaidApi, PlaidEnvironments } = require('plaid');7
8const 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});17
18const 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. Asset Reports can consist of user data from multiple financial institutions; users will need to use Link to provide access to each financial institution, providing you with multiple Items. 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. Since, for Assets, users may need to grant access to more than one financial institution via Link, you may need to initialize Link more than once.
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.
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: ['assets'],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});18
19linkHandler.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
for each Item the user provided you with via Link. The access_token
will allow us to make authenticated calls to the Plaid API for its corresponding financial institution. 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
s and item_id
s in a secure datastore, as they’re used to access Item
data and identify webhooks
, respectively. An access_token
will remain valid unless you actively chose to expire it via rotation or remove the corresponding Item via /item/remove
. An 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 });11
12 // 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;16
17 res.json({ public_token_exchange: 'complete' });18 } catch (error) {19 // handle error20 }21});
Creating Asset Reports
Now that the authentication step is out of the way, we can begin using authenticated endpoints from the Plaid API and create an Asset Report using the /asset_report/create
endpoint.
Assets sample request: create
Select group for content switcher1const { AssetReportCreateRequest } = require('plaid');2
3const daysRequested = 90;4const options = {5 client_report_id: '123',6 webhook: 'https://www.example.com',7 user: {8 client_user_id: '789',9 first_name: 'Jane',10 middle_name: 'Leah',11 last_name: 'Doe',12 ssn: '123-45-6789',13 phone_number: '(555) 123-4567',14 email: 'jane.doe@example.com',15 },16};17const request: AssetReportCreateRequest = {18 access_tokens: [accessToken],19 days_requested,20 options,21};22// accessTokens is an array of Item access tokens.23// Note that the assets product must be enabled for all Items.24// All fields on the options object are optional.25try {26 const response = await plaidClient.assetReportCreate(request);27 const assetReportId = response.data.asset_report_id;28 const assetReportToken = response.data.asset_report_token;29} catch (error) {30 // handle error31}
Sample response data is below.
1{2 "asset_report_token": "assets-sandbox-6f12f5bb-22dd-4855-b918-f47ec439198a",3 "asset_report_id": "1f414183-220c-44f5-b0c8-bc0e6d4053bb",4 "request_id": "Iam3b"5}
Fetching asset data
Once an Asset Report has been created, it can be retrieved to analyze the user's loan eligibility. For more detailed information on the schema for Asset Reports, see /asset_report/get
.
Asset Reports are not generated instantly. If you receive a PRODUCT_NOT_READY
error when calling /asset_report/get
, the requested Asset Report has not yet been generated. To be alerted when the requested Asset Report has been generated, listen to Assets webhooks.
Assets sample request: get
Select group for content switcher1const { AssetReportGetRequest } = require('plaid');2
3const request: AssetReportGetRequest = {4 asset_report_token: assetReportToken,5 include_insights: true,6};7try {8 const response = await plaidClient.assetReportGet(request);9 const assetReportId = response.data.asset_report_id;10} catch (error) {11 // handle error12}
Sample response data is below.
1{2 "report": {3 "asset_report_id": "bf3a0490-344c-4620-a219-2693162e4b1d",4 "client_report_id": "123abc",5 "date_generated": "2020-06-05T22:47:53Z",6 "days_requested": 2,7 "items": [8 {9 "accounts": [10 {11 "account_id": "3gE5gnRzNyfXpBK5wEEKcymJ5albGVUqg77gr",12 "balances": {13 "available": 200,14 "current": 210,15 "iso_currency_code": "USD",16 "limit": null,17 "unofficial_currency_code": null18 },19 "days_available": 2,20 "historical_balances": [21 {22 "current": 210,23 "date": "2020-06-04",24 "iso_currency_code": "USD",25 "unofficial_currency_code": null26 },27 {28 "current": 210,29 "date": "2020-06-03",30 "iso_currency_code": "USD",31 "unofficial_currency_code": null32 }33 ],34 "mask": "1111",35 "name": "Plaid Saving",36 "official_name": "Plaid Silver Standard 0.1% Interest Saving",37 "owners": [38 {39 "addresses": [40 {41 "data": {42 "city": "Malakoff",43 "country": "US",44 "postal_code": "14236",45 "region": "NY",46 "street": "2992 Cameron Road"47 },48 "primary": true49 },50 {51 "data": {52 "city": "San Matias",53 "country": "US",54 "postal_code": "93405-2255",55 "region": "CA",56 "street": "2493 Leisure Lane"57 },58 "primary": false59 }60 ],61 "emails": [62 {63 "data": "accountholder0@example.com",64 "primary": true,65 "type": "primary"66 },67 {68 "data": "extraordinarily.long.email.username.123456@reallylonghostname.com",69 "primary": false,70 "type": "other"71 }72 ],73 "names": ["Alberta Bobbeth Charleson"],74 "phone_numbers": [75 {76 "data": "1112223333",77 "primary": false,78 "type": "home"79 },80 {81 "data": "1112225555",82 "primary": false,83 "type": "mobile1"84 }85 ]86 }87 ],88 "ownership_type": null,89 "subtype": "savings",90 "transactions": [],91 "type": "depository"92 },93 {94 "account_id": "BxBXxLj1m4HMXBm9WZJyUg9XLd4rKEhw8Pb1J",95 "balances": {96 "available": null,97 "current": 56302.06,98 "iso_currency_code": "USD",99 "limit": null,100 "unofficial_currency_code": null101 },102 "days_available": 2,103 "historical_balances": [],104 "mask": "8888",105 "name": "Plaid Mortgage",106 "official_name": null,107 "owners": [108 {109 "addresses": [110 {111 "data": {112 "city": "Malakoff",113 "country": "US",114 "postal_code": "14236",115 "region": "NY",116 "street": "2992 Cameron Road"117 },118 "primary": true119 },120 {121 "data": {122 "city": "San Matias",123 "country": "US",124 "postal_code": "93405-2255",125 "region": "CA",126 "street": "2493 Leisure Lane"127 },128 "primary": false129 }130 ],131 "emails": [132 {133 "data": "accountholder0@example.com",134 "primary": true,135 "type": "primary"136 },137 {138 "data": "extraordinarily.long.email.username.123456@reallylonghostname.com",139 "primary": false,140 "type": "other"141 }142 ],143 "names": ["Alberta Bobbeth Charleson"],144 "phone_numbers": [145 {146 "data": "1112223333",147 "primary": false,148 "type": "home"149 },150 {151 "data": "1112225555",152 "primary": false,153 "type": "mobile1"154 }155 ]156 }157 ],158 "ownership_type": null,159 "subtype": "mortgage",160 "transactions": [],161 "type": "loan"162 },163 {164 "account_id": "dVzbVMLjrxTnLjX4G66XUp5GLklm4oiZy88yK",165 "balances": {166 "available": null,167 "current": 410,168 "iso_currency_code": "USD",169 "limit": null,170 "unofficial_currency_code": null171 },172 "days_available": 2,173 "historical_balances": [174 {175 "current": 410,176 "date": "2020-06-04",177 "iso_currency_code": "USD",178 "unofficial_currency_code": null179 },180 {181 "current": 410,182 "date": "2020-06-03",183 "iso_currency_code": "USD",184 "unofficial_currency_code": null185 }186 ],187 "mask": "3333",188 "name": "Plaid Credit Card",189 "official_name": "Plaid Diamond 12.5% APR Interest Credit Card",190 "owners": [191 {192 "addresses": [193 {194 "data": {195 "city": "Malakoff",196 "country": "US",197 "postal_code": "14236",198 "region": "NY",199 "street": "2992 Cameron Road"200 },201 "primary": true202 },203 {204 "data": {205 "city": "San Matias",206 "country": "US",207 "postal_code": "93405-2255",208 "region": "CA",209 "street": "2493 Leisure Lane"210 },211 "primary": false212 }213 ],214 "emails": [215 {216 "data": "accountholder0@example.com",217 "primary": true,218 "type": "primary"219 },220 {221 "data": "extraordinarily.long.email.username.123456@reallylonghostname.com",222 "primary": false,223 "type": "other"224 }225 ],226 "names": ["Alberta Bobbeth Charleson"],227 "phone_numbers": [228 {229 "data": "1112223333",230 "primary": false,231 "type": "home"232 },233 {234 "data": "1112225555",235 "primary": false,236 "type": "mobile1"237 }238 ]239 }240 ],241 "ownership_type": null,242 "subtype": "credit card",243 "transactions": [],244 "type": "credit"245 }246 ],247 "date_last_updated": "2020-06-05T22:47:52Z",248 "institution_id": "ins_3",249 "institution_name": "Chase",250 "item_id": "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6"251 }252 ],253 "user": {254 "client_user_id": "123456789",255 "email": "accountholder0@example.com",256 "first_name": "Alberta",257 "last_name": "Charleson",258 "middle_name": "Bobbeth",259 "phone_number": "111-222-3333",260 "ssn": "123-45-6789"261 }262 },263 "request_id": "eYupqX1mZkEuQRx",264 "warnings": []265}
Working with Assets data
After your initial /asset_report/create
and /asset_report/get
requests, you may want your application to fetch updated Asset Reports, provide Audit Copies of Asset Reports, and more. Consult the API Reference to explore these and other options.
Next steps
If you're ready to launch to Production, see the Launch checklist.