Add Balance to your app 
========================

#### Use Balance to fetch real-time balance data 

In this guide, we'll start from scratch and walk through how to use Balance to retrieve real-time balance information and assess ACH return risk. If you are already familiar with using Plaid and are set up to make calls to the Plaid API, make sure to note that you should _not_ include `balance` in the [/link/token/create](https://plaid.com/docs/api/link/index.html.md#linktokencreate) products array, but you _should_ include `signal`, if you are using Balance for an ACH risk assessment use case; you can then skip ahead to [Fetching balance data](https://plaid.com/docs/balance/add-to-app/index.html.md#fetching-balance-data) .

#### 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](https://dashboard.plaid.com/signup) . After creating your account, you can find your [API keys](https://dashboard.plaid.com/developers/keys) under the Developers menu on the Plaid Dashboard.

You will also need to complete your [application profile](https://dashboard.plaid.com/settings/company/app-branding) and [company profile](https://dashboard.plaid.com/settings/company/profile) in the Dashboard. The information in your profile will be shared with users of your application when they manage their connection on the [Plaid Portal](https://my.plaid.com) . 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:

```node
// Install via npm
npm install --save plaid

```

```bash
## Not applicable with curl calls

```

```ruby
# Available as a gem
gem install plaid

```

```java
/*
For Gradle, add the following dependency to your build.gradle and replace {VERSION} with the version number you want to use from
- https://github.com/plaid/plaid-java/releases/latest
*/
implementation "com.plaid:plaid-java:{VERSION}"

/*
For Maven, add the following dependency to your POM and replace {VERSION} with the version number you want to use from
- https://github.com/plaid/plaid-java/releases/latest
*/

  com.plaid
  plaid-java
  {VERSION}


```

```python
# Install through pip, only supports Python 3
pip install --upgrade plaid-python

```

```go
go get github.com/plaid/plaid-go

```

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.

```node
// Using Express
const express = require('express');
const app = express();
app.use(express.json());

const { Configuration, PlaidApi, PlaidEnvironments } = require('plaid');

const configuration = new Configuration({
  basePath: PlaidEnvironments.sandbox,
  baseOptions: {
    headers: {
      'PLAID-CLIENT-ID': process.env.PLAID_CLIENT_ID,
      'PLAID-SECRET': process.env.PLAID_SECRET,
    },
  },
});

const client = new PlaidApi(configuration);

```

```bash
## Not applicable with curl calls

```

```ruby
require 'sinatra'
require 'plaid'

set :port, ENV['APP_PORT'] || 8000

configuration = Plaid::Configuration.new
configuration.server_index = Plaid::Configuration::Environment[ENV['PLAID_ENV'] || 'sandbox']
configuration.api_key['PLAID-CLIENT-ID'] =  ENV['PLAID_CLIENT_ID']
configuration.api_key['PLAID-SECRET'] = ENV['PLAID_SECRET']

api_client = Plaid::ApiClient.new(
  configuration
)

client = Plaid::PlaidApi.new(api_client)

```

```java
import java.net.*;
import java.io.*;
import retrofit2.Response;
import java.util.Arrays;
import com.sun.net.httpserver.*;

import com.plaid.client.ApiClient;
import com.plaid.client.request.PlaidApi;

public class PlaidExample {
  private static final String CLIENT_ID = System.getenv("PLAID_CLIENT_ID");
  private static final String SECRET = System.getenv("PLAID_SECRET");

  public static void main(String[] args) {
    HttpServer server = HttpServer.create(
      new InetSocketAddress("localhost", 8000), 0);
    server.createContext("/create_link_token", new GetLinkToken());
    server.setExecutor(null);
    server.start();
  }

  // Additional server code goes here

}

```

```python
import plaid
from plaid.api import plaid_api

from flask import Flask
from flask import render_template
from flask import request
from flask import jsonify

app = Flask(name)

configuration = plaid.Configuration(
  host=plaid.Environment.Sandbox,
  api_key={
    'clientId': PLAID_CLIENT_ID,
    'secret': PLAID_SECRET,
  }
)

api_client = plaid.ApiClient(configuration)
client = plaid_api.PlaidApi(api_client)

# Additional server code goes here

if __name__ == "__main__":
    app.run(port=8000)

```

```go
import (
    "context"
    "net/http"
    "os"

    "github.com/gin-gonic/gin"
    "github.com/plaid/plaid-go/v3/plaid"
)


configuration := plaid.NewConfiguration()
configuration.AddDefaultHeader("PLAID-CLIENT-ID", os.Getenv("CLIENT_ID"))
configuration.AddDefaultHeader("PLAID-SECRET", os.Getenv("SECRET"))
configuration.UseEnvironment(plaid.Sandbox)
client := plaid.NewAPIClient(configuration)


func main() {
  r := gin.Default()
  // Server endpoints would be declared here
  // e.g.  r.POST("/create_link_token", createLinkToken)
 r.POST("/create_link_token", createLinkToken)

  err := r.Run(":8000")
  if err != nil {
    panic("unable to start server")
  }
}

```

#### 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](https://plaid.com/docs/link/index.html.md) .

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](https://dashboard.plaid.com/link) .

If you are using Balance for a payments use case and you do not set the [Link Account Select UI](https://dashboard.plaid.com/link/account-select) to "enabled for one account", your UI flow when creating a payment must handle the scenario of an end user linking an Item with multiple accounts and allow them to specify which account to use for the payment.

In order to launch Link in Production, you must [select use cases for your Link customization](https://dashboard.plaid.com/link/data-transparency-v5) . This requirement is not enforced in Sandbox.

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](https://plaid.com/docs/api/link/index.html.md#linktokencreate) endpoint. Then, on the client side of your application, you'll need to initialize Link with the `link_token` that you just created.

If using Balance for ACH return risk assessment, include `signal` in the `products` array, along with all other Plaid product(s) you will be using with Balance.

For all other Balance use cases, omit `signal`, but instead include the Plaid product(s) you will be using with Balance in the `products` array.

`balance` cannot be included in the `products` array when calling [/link/token/create](https://plaid.com/docs/api/link/index.html.md#linktokencreate) .

##### Create a link\_token 

```node
app.post('/api/create_link_token', async function (request, response) {
  // Get the client_user_id by searching for the current user
  const user = await User.find(...);
  const clientUserId = user.id;
  const linkTokenRequest = {
    user: {
      // This should correspond to a unique id for the current user.
      client_user_id: clientUserId,
    },
    client_name: 'Plaid Test App',
    products: ['signal, auth'],
    language: 'en',
    webhook: 'https://webhook.example.com',
    redirect_uri: 'https://domainname.com/oauth-page.html',
    country_codes: ['US'],
  };
  try {
    const createTokenResponse = await client.linkTokenCreate(linkTokenRequest);
    response.json(createTokenResponse.data);
  } catch (error) {
    // handle error
  }
});

```

```bash
curl -X POST https://sandbox.plaid.com/link/token/create \
-H 'Content-Type: application/json' \
-d '{
  "client_id": "${PLAID_CLIENT_ID}",
  "secret": "${PLAID_SECRET}",
  "client_name": "Plaid Test App",
  "user": { "client_user_id": "${UNIQUE_USER_ID}" },
  "products": ["signal, auth"],
  "country_codes": ["US"],
  "language": "en",
  "webhook": "https://webhook.example.com",
  "redirect_uri": "https://domainname.com/oauth-page.html"
}'

```

```ruby
post '/api/create_link_token' do
  # Get the client_user_id by searching for the current user
  current_user = User.find(...)
  client_user_id = current_user.id

  # Create a link_token for the given user
  request = Plaid::LinkTokenCreateRequest.new(
    {
      user: { client_user_id: client_user_id },
      client_name: 'Plaid Test App',
      products: ['signal, auth'],
      country_codes: ['US'],
      language: "en",
      redirect_uri: nil_if_empty_envvar('PLAID_REDIRECT_URI'),
      webhook: 'https://webhook.example.com'
    }
  )
  response = client.link_token_create(request)
  content_type :json
  response.to_json
end

```

```java
import com.plaid.client.model.Products;
import com.plaid.client.model.CountryCode;
import com.plaid.client.model.LinkTokenCreateRequest;
import com.plaid.client.model.LinkTokenCreateRequestUser;
import com.plaid.client.model.LinkTokenCreateResponse;

public class PlaidExample {

  ...
  static class GetLinkToken implements HttpHandler {
    private static PlaidApi plaidClient;

    public void handle(HttpExchange t) throws IOException {
      // Create your Plaid client
      HashMap apiKeys = new HashMap();
      apiKeys.put("clientId", CLIENT_ID);
      apiKeys.put("secret", SECRET);
      ApiClient apiClient = new ApiClient(apiKeys);
      apiClient.setPlaidAdapter(ApiClient.Sandbox);

      plaidClient = apiClient.createService(PlaidApi.class);

      // Get the clientUserId by searching for the current user
      User userFromDB = db.find(...);
      String clientUserId = userFromDB.id;
      LinkTokenCreateRequestUser user = new LinkTokenCreateRequestUser()
        .clientUserId(clientUserId);

      // Create a link_token for the given user
      LinkTokenCreateRequest request = new LinkTokenCreateRequest()
        .user(user)
        .clientName("Plaid Test App")
        .products(Arrays.asList(Products.fromValue("signal, auth")))
        .countryCodes(Arrays.asList(CountryCode.US))
        .language("en")
        .redirectUri("https://domainname.com/oauth-page.html")
        .webhook("https://webhook.example.com");

      Response response = plaidClient
        .linkTokenCreate(request)
        .execute();

      // Send the data to the client
      return response.body();
    }
  }
}

```

```python
from plaid.model.link_token_create_request import LinkTokenCreateRequest
from plaid.model.link_token_create_request_user import LinkTokenCreateRequestUser
from plaid.model.products import Products
from plaid.model.country_code import CountryCode

@app.route("/create_link_token", methods=['POST'])
def create_link_token():
    # Get the client_user_id by searching for the current user
    user = User.find(...)
    client_user_id = user.id

    # Create a link_token for the given user
    request = LinkTokenCreateRequest(
            products=[Products("signal, auth")],
            client_name="Plaid Test App",
            country_codes=[CountryCode('US')],
            redirect_uri='https://domainname.com/oauth-page.html',
            language='en',
            webhook='https://webhook.example.com',
            user=LinkTokenCreateRequestUser(
                client_user_id=client_user_id
            )
        )
    response = client.link_token_create(request)

    # Send the data to the client
    return jsonify(response.to_dict())


```

```go
func createLinkToken(c *gin.Context) {
  ctx := context.Background()

  // Get the client_user_id by searching for the current user
  user, _ := usermodels.Find(...)
  clientUserId := user.ID.String()

  // Create a link_token for the given user
  request := plaid.NewLinkTokenCreateRequest("Plaid Test App", "en", []plaid.CountryCode{plaid.COUNTRYCODE_US}, *plaid.NewLinkTokenCreateRequestUser(clientUserId))
  request.SetWebhook("https://webhook.sample.com")
  request.SetRedirectUri("https://domainname.com/oauth-page.html")
  request.SetProducts([]plaid.Products{plaid.PRODUCTS_SIGNAL, AUTH})

  resp, _, err := testClient.PlaidApi.LinkTokenCreate(ctx).LinkTokenCreateRequest(*request).Execute()

  // Send the data to the client
  c.JSON(http.StatusOK, gin.H{
    "link_token": resp.GetLinkToken(),
  })
}


```

##### Install Link dependency 

index.html

```html
<head>
  <title>Connect a bank</title>
  <script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script>
</head>
```

##### Configure the client-side Link handler 

app.js

```javascript
const linkHandler = Plaid.create({
  token: (await $.post('/create_link_token')).link_token,
  onSuccess: (public_token, metadata) => {
    // Send the public_token to your app server.
    $.post('/exchange_public_token', {
      public_token: public_token,
    });
  },
  onExit: (err, metadata) => {
    // Optionally capture when your user exited the Link flow.
    // Storing this information can be helpful for support.
  },
  onEvent: (eventName, metadata) => {
    // Optionally capture Link flow events, streamed through
    // this callback as your users connect an Item to Plaid.
  },
});

linkHandler.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](https://plaid.com/docs/api/items/index.html.md#itempublic_tokenexchange) 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 choose to expire it via rotation or remove the corresponding Item via [/item/remove](https://plaid.com/docs/api/items/index.html.md#itemremove) . 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.

```node
app.post('/api/exchange_public_token', async function (
  request,
  response,
  next,
) {
  const publicToken = request.body.public_token;
  try {
    const tokenResponse = await client.itemPublicTokenExchange({
      public_token: publicToken,
    });

    // These values should be saved to a persistent database and
    // associated with the currently signed-in user
    const accessToken = tokenResponse.data.access_token;
    const itemID = tokenResponse.data.item_id;

    response.json({ public_token_exchange: 'complete' });
  } catch (error) {
    // handle error
  }
});

```

```bash
curl -X POST https://sandbox.plaid.com/item/public_token/exchange \
-H 'Content-Type: application/json' \
-d '{
  "client_id": "${PLAID_CLIENT_ID}",
  "secret": "${PLAID_SECRET}",
  "public_token": "public-sandbox-12345678-abcd-1234-abcd-1234567890ab"
}'

```

```ruby
access_token = nil

post '/api/exchange_public_token' do
  request = Plaid::ItemPublicTokenExchangeRequest.new(
    {
      public_token: params["public_token"]
    }
  )
  response = client.item_public_token_exchange(request)

  # These values should be saved to a persistent database and
  # associated with the currently signed-in user
  access_token = response.access_token
  item_id = response.item_id

  content_type :json
  {public_token_exchange: "complete"}.to_json
end

```

```java
import com.plaid.client.model.ItemPublicTokenExchangeRequest;
import com.plaid.client.model.ItemPublicTokenExchangeResponse;

public class PlaidExample {

  ...
  static class GetAccessToken implements HttpHandler {
    private static PlaidClient plaidClient;

    private String publicToken;
    private String accessToken;
    private String itemId;

    public void handle(HttpExchange t) throws IOException {
      // Simplified pseudo-code for obtaining public_token
      InputStream is = t.getRequestBody();
      publicToken = is.publicToken();

      // Create your Plaid client
      HashMap apiKeys = new HashMap();
      apiKeys.put("clientId", CLIENT_ID);
      apiKeys.put("secret", SECRET);
      apiKeys.put("plaidVersion", "2020-09-14");
      apiClient = new ApiClient(apiKeys);
      apiClient.setPlaidAdapter(ApiClient.Sandbox);

      plaidClient = apiClient.createService(PlaidApi.class);

      // Exchange public_token for an access_token
      ItemPublicTokenExchangeRequest request = new ItemPublicTokenExchangeRequest()
        .publicToken(publicToken);

      Response response = plaidClient
        .itemPublicTokenExchange(request)
        .execute();

      // These values should be saved to a persistent database and
      // associated with the currently signed-in user
      accessToken = response.body().getAccessToken();
      itemId      = response.body().getItemId();

      String message = "{\"public_token_exchange\": \"complete\"}";
      return Response
        .status(Response.Status.OK)
        .entity(message)
        .type(MediaType.APPLICATION_JSON)
      }
  }
}

```

```python
access_token = None
item_id = None

@app.route('/exchange_public_token', methods=['POST'])
def exchange_public_token():
    global access_token
    public_token = request.form['public_token']
    request = ItemPublicTokenExchangeRequest(
      public_token=public_token
    )
    response = client.item_public_token_exchange(request)

    # These values should be saved to a persistent database and
    # associated with the currently signed-in user
    access_token = response['access_token']
    item_id = response['item_id']

    return jsonify({'public_token_exchange': 'complete'})

```

```go
func getAccessToken(c *gin.Context) {
  ctx := context.Background()
  publicToken := c.PostForm("public_token")

  // exchange the public_token for an access_token
  exchangePublicTokenReq := plaid.NewItemPublicTokenExchangeRequest(publicToken)
    exchangePublicTokenResp, _, err := client.PlaidApi.ItemPublicTokenExchange(ctx).ItemPublicTokenExchangeRequest(
        *exchangePublicTokenReq,
    ).Execute()

  // These values should be saved to a persistent database and
  // associated with the currently signed-in user
  accessToken := exchangePublicTokenResp.GetAccessToken()
  itemID := exchangePublicTokenResp.GetItemId()

  c.JSON(http.StatusOK, gin.H{"public_token_exchange": "complete"})
}



```

#### Fetching Balance data 

Now that the authentication step is out of the way, we can begin using authenticated endpoints from the Plaid API.

There are two ways to use Balance: by using [/signal/evaluate](https://plaid.com/docs/api/products/signal/index.html.md#signalevaluate) , or by using [/accounts/balance/get](https://plaid.com/docs/api/products/signal/index.html.md#accountsbalanceget) .

If you are using Balance to evaluate a proposed ACH transaction for return risk, use [/signal/evaluate](https://plaid.com/docs/api/products/signal/index.html.md#signalevaluate) .

For all other use cases, use [/accounts/balance/get](https://plaid.com/docs/api/products/signal/index.html.md#accountsbalanceget) .

##### Using /signal/evaluate 

###### Creating a Balance-only ruleset 

In the Dashboard, navigate to [Signal->Rules](https://dashboard.plaid.com/signal/risk-profiles) to create a Balance-only ruleset. When you do, Plaid will pre-populate a suggested ruleset; you can either use it as-is or customize it.

In Sandbox, you will be offered a choice between Balance-only and Signal Transaction Scores–powered rulesets. To use Balance, select "Balance-only". In Production, Signal Transaction Scores rulesets will only be provided as an option if you are Production-enabled for the Signal Transaction Scores product.

###### Getting the account\_id 

If you are using [/signal/evaluate](https://plaid.com/docs/api/products/signal/index.html.md#signalevaluate) , you will need to know the `account_id` of the account that is being debited. You can get this in multiple ways, the simplest of which are: by using the `onSuccess` callback in Link (`metadata.accounts[].id`) or by calling [/accounts/get](https://plaid.com/docs/api/accounts/index.html.md#accountsget) .

Method 1: The metadata object from Link onSuccess callback

```json
{
  ...
  "accounts": [
    {
      "id": "ygPnJweommTWNr9doD6ZfGR6GGVQy7fyREmWy",
      "name": "Plaid Checking",
      "mask": "0000",
      "type": "depository",
      "subtype": "checking",
      "verification_status": null
    },
    {
      "id": "9ebEyJAl33FRrZNLBG8ECxD9xxpwWnuRNZ1V4",
      "name": "Plaid Saving",
      "mask": "1111",
      "type": "depository",
      "subtype": "savings"
    }
  ],
  ...
}
```

```bash
curl -X POST https://sandbox.plaid.com/accounts/get \
  -H 'Content-Type: application/json' \
  -d '{
    "client_id": "${PLAID_CLIENT_ID}",
    "secret": "${PLAID_SECRET}",
    "access_token": String
  }'

```

```node
const request: AccountsGetRequest = {
  access_token: ACCESS_TOKEN,
};
try {
  const response = await plaidClient.accountsGet(request);
  const accounts = response.data.accounts;
} catch (error) {
  // handle error
}

```

```python
request = AccountsGetRequest(access_token=ACCESS_TOKEN)
response = client.accounts_get(request)
accounts = response['accounts']

```

```java
AccountsGetRequest request = new AccountsGetRequest()
  .accessToken(ACCESS_TOKEN);
Response response = client()
  .accountsGet(request)
  .execute();
List accounts = response.body().getAccounts();

```

```ruby
request = Plaid::AccountsGetRequest.new({ access_token: ACCESS_TOKEN })
response = client.accounts_get(request)
accounts = response.accounts

```

```go
accountsGetRequest := plaid.NewAccountsGetRequest(accessToken)
accountsGetRequest.SetOptions(plaid.AccountsGetRequestOptions{
  AccountIds: &[]string{},
})

accountsGetResp, _, err = client.PlaidApi.AccountsGet(ctx).AccountsGetRequest(
  *accountsGetRequest,
).Execute()

accounts := accountsGetResp.GetAccounts()

```

A sample response is below (note that [/accounts/get](https://plaid.com/docs/api/accounts/index.html.md#accountsget) returns balance data, but it is cached and not updated in real time):

/accounts/get response

```json
{
  "accounts": [
    {
      "account_id": "blgvvBlXw3cq5GMPwqB6s6q4dLKB9WcVqGDGo",
      "balances": {
        "available": 100, 
        "current": 110,
        "iso_currency_code": "USD",
        "limit": null,
        "unofficial_currency_code": null
      },
      "holder_category": "personal",
      "mask": "0000",
      "name": "Plaid Checking",
      "official_name": "Plaid Gold Standard 0% Interest Checking",
      "subtype": "checking",
      "type": "depository"
    },
    {
      "account_id": "6PdjjRP6LmugpBy5NgQvUqpRXMWxzktg3rwrk",
      "balances": {
        "available": null,
        "current": 23631.9805,
        "iso_currency_code": "USD",
        "limit": null,
        "unofficial_currency_code": null
      },
      "mask": "6666",
      "name": "Plaid 401k",
      "official_name": null,
      "subtype": "401k",
      "type": "investment"
    }
  ],
  ...
```

Once you have obtained both an `access_token` and an `account_id`, you can call [/signal/evaluate](https://plaid.com/docs/api/products/signal/index.html.md#signalevaluate) to evaluate the proposed transaction. If you do not specify a `ruleset_key`, the transaction will be evaluated based on the ruleset named `default`.

```node
const eval_request = {
  access_token: 'access-sandbox-71e02f71-0960-4a27-abd2-5631e04f2175',
  account_id: '3gE5gnRzNyfXpBK5wEEKcymJ5albGVUqg77gr',
  client_transaction_id: 'txn12345',
  amount: 123.45,
}

try {
  const eval_response = await plaidClient.signalEvaluate(eval_request);
  const core_attributes = eval_response.data.core_attributes;
} catch (error) {
  // handle error
}

```

```bash
curl -X POST https://sandbox.plaid.com/signal/evaluate \
-H 'Content-Type: application/json' \
-d '{
   "client_id": "${PLAID_CLIENT_ID}",
   "secret": "${PLAID_SECRET}",
   "access_token": "access-sandbox-71e02f71-0960-4a27-abd2-5631e04f2175",
   "account_id": "3gE5gnRzNyfXpBK5wEEKcymJ5albGVUqg77gr",
   "client_transaction_id": "txn12345",
   "amount": 123.45
 }'

```

```ruby

request = Plaid::SignalEvaluateRequest.new(
  {
    access_token: access_token,
    account_id: '3gE5gnRzNyfXpBK5wEEKcymJ5albGVUqg77gr',
    client_transaction_id: 'txn12345',
    amount: 123.45,
  }
)
response = client.signal_evaluate(request)
result = response.ruleset.result

```

```java
SignalEvaluateRequest request = new SignalEvaluateRequest()
  .accessToken("access-sandbox-71e02f71-0960-4a27-abd2-5631e04f2175")
  .accountId("3gE5gnRzNyfXpBK5wEEKcymJ5albGVUqg77gr")
  .clientTransactionId("txn12345")
  .amount(123.45);

Response response = plaidClient()
  .signalEvaluate(request)
  .execute();
RuleResult result = response.body().getRuleset().getResult();

```

```python
request = SignalEvaluateRequest(
  access_token="access-sandbox-71e02f71-0960-4a27-abd2-5631e04f2175",
  account_id="3gE5gnRzNyfXpBK5wEEKcymJ5albGVUqg77gr",
  client_transaction_id="txn123",
  amount=123.45,
)
response = client.signal_evaluate(request)
result = response['ruleset']['result']

```

```go
request := plaid.NewSignalEvaluateRequest(
  "access-sandbox-71e02f71-0960-4a27-abd2-5631e04f2175",
  "3gE5gnRzNyfXpBK5wEEKcymJ5albGVUqg77gr",
  "txn12345",
  123.45,
)
response, _, err := client.PlaidApi.SignalEvaluate(ctx).SignalEvaluateRequest(*request).Execute()
result := response.GetRuleset().GetResult()

```

To determine which action to take, use the `ruleset.result` value of `accept`, `reroute`, or `review`. To learn more about these values, see [Signal rules](https://plaid.com/docs/signal/signal-rules/index.html.md#using-signal-ruleset-results) .

You can also view the real-time current and available balances in `core_attributes.current_balance` and `core_attributes.available_balance`.

#### Reporting outcomes 

If the result was `review`, report your final review decision to Plaid using [/signal/decision/report](https://plaid.com/docs/api/products/signal/index.html.md#signaldecisionreport) or by uploading a CSV. For more details, see [Reporting decisions and returns](https://plaid.com/docs/signal/reporting-returns/index.html.md) .

```node
const decision_report_request = {
  client_transaction_id: 'txn12345',
  initiated: true,
  days_funds_on_hold: 3,
};

try {
  const decision_report_response = await plaidClient.signalDecisionReport(
    decision_report_request,
  );
  const decision_request_id = decision_report_response.data.request_id;
} catch (error) {
  // handle error
}

```

```bash
curl -X POST https://sandbox.plaid.com/signal/decision/report \
-H 'content-type: application/json' \
 -d '{
   "client_id": "${PLAID_CLIENT_ID}",
   "secret": "${PLAID_SECRET}",
   "client_transaction_id": "txn123",
   "initiated": true
 }'

```

```ruby
request = Plaid::SignalDecisionReportRequest.new(
  {
    client_transaction_id: 'txn12345',
    initiated: true,
    days_funds_on_hold: 3
  }
)
response = client.signal_decision_report(request)
request_id = response.request_id

```

```java
SignalDecisionReportRequest request = new SignalDecisionReportRequest()
  .clientTransactionId("txn12345")
  .initiated(true)
  .daysFundsOnHold(3);

Response response = plaidClient()
  .signalDecisionReport(request)
  .execute();
String requestID = response.body().getRequestId();

```

```python
request = SignalDecisionReportRequest(
  client_transaction_id="txn12345",
  initiated=True,
  days_funds_on_hold=3,
)
response = client.signal_decision_report(request)
request_id = response['request_id']

```

```go
request := plaid.NewSignalDecisionReportRequest(
  "txn12345",
  true,
)
request.SetDaysFundsOnHold(3)
response, _, err := client.PlaidApi.SignalDecisionReport(ctx).SignalDecisionReportRequest(*request).Execute()
request_id := response.GetRequestId()

```

If you allow a transfer that does end up returned, report that result back to Plaid as well. You can do this by calling [/signal/return/report](https://plaid.com/docs/api/products/signal/index.html.md#signalreturnreport) or by uploading a CSV. For more details, see [Reporting decisions and returns](https://plaid.com/docs/signal/reporting-returns/index.html.md) .

```node
const return_report_request = {
  client_transaction_id: 'txn12345',
  return_code: 'R01',
};

try {
  const return_report_response = await plaidClient.signalReturnReport(
    return_report_request,
  );
  const request_id = return_report_response.data.request_id;
  console.log(request_id);
} catch (error) {
  // handle error
}

```

```bash
curl -X POST https://sandbox.plaid.com/signal/return/report \
-H 'content-type: application/json' \
-d '{
   "client_id": "${PLAID_CLIENT_ID}",
   "secret": "${PLAID_SECRET}",
   "client_transaction_id": "txn12345",
   "return_code": "R01"
 }'

```

```ruby
request = Plaid::SignalReturnReportRequest.new(
  {
    client_transaction_id: 'txn12345',
    return_code: 'R01'
  }
)
response = client.signal_return_report(request)
request_id = response.request_id

```

```java
SignalReturnReportRequest request = new SignalReturnReportRequest()
  .clientTransactionId("txn12345")
  .returnCode("R01");

Response response = client()
  .signalReturnReport(request)
  .execute();

String requestId = response.body().getRequestId();

```

```python
request = SignalReturnReportRequest(
  client_transaction_id="txn12345",
  return_code="R01",
)
response = client.signal_return_report(request)
request_id = response['request_id']

```

```go
request := plaid.NewSignalReturnReportRequest(
  "txn12345",
  "R01",
)
response, _, err := client.PlaidApi.SignalReturnReport(ctx).SignalReturnReportRequest(*request).Execute()
request_id := response.GetRequestId()

```

##### Using /accounts/balance/get 

For more detailed information on the schema returned, see [/accounts/balance/get](https://plaid.com/docs/api/products/signal/index.html.md#accountsbalanceget) .

```node
const { AccountsBalanceGetRequest } = require('plaid');

// Pull real-time balance information for each account associated
// with the Item
const request: AccountsBalanceGetRequest = {
  access_token: accessToken,
};
try {
  const response = await plaidClient.accountsBalanceGet(request);
  const accounts = response.data.accounts;
} catch (error) {
  // handle error
}

```

```bash
curl -X POST https://sandbox.plaid.com/accounts/balance/get \
-H 'Content-Type: application/json' \
-d '{
   "client_id": "${PLAID_CLIENT_ID}",
   "secret": "${PLAID_SECRET}",
  "access_token": String,
  "options": {
    "account_ids": [String]
  }
}'

```

```ruby
# Pull real-time balance information for each account associated
# with the Item
request = Plaid::AccountsBalanceGetRequest.new({ access_token: access_token })
response = client.accounts_balance_get(request)
accounts = response.accounts

```

```java
import com.plaid.client.model.AccountsBalanceGetRequest;
import com.plaid.client.model.AccountsGetResponse;

// Pull real-time balance information for each account associated
// with the Item
AccountsBalanceGetRequest request = new AccountsBalanceGetRequest()
  .accessToken(accessToken);

Response response = client()
  .accountsBalanceGet(request)
  .execute();
List accounts = response.body().getAccounts();

```

```python
from plaid.model.accounts_balance_get_request import AccountsBalanceGetRequest

# Pull real-time balance information for each account associated
# with the Item
request = AccountsBalanceGetRequest(access_token=access_token)
response = client.accounts_balance_get(request)
accounts = response['accounts']

```

```go
import (
    "context"
)

balancesGetResp, _, err := client.PlaidApi.AccountsBalanceGet(ctx).AccountsBalanceGetRequest(
  *plaid.NewAccountsBalanceGetRequest(accessToken),
).Execute()

accounts := balancesGetResp.GetAccounts()

```

Example response data is below.

Balance sample response

```json
{
  "accounts": [
    {
      "account_id": "BxBXxLj1m4HMXBm9WZZmCWVbPjX16EHwv99vp",
      "balances": {
        "available": 100,
        "current": 110,
        "iso_currency_code": "USD",
        "limit": null,
        "unofficial_currency_code": null
      },
      "mask": "0000",
      "name": "Plaid Checking",
      "official_name": "Plaid Gold Standard 0% Interest Checking",
      "subtype": "checking",
      "type": "depository"
    },
    {
      "account_id": "dVzbVMLjrxTnLjX4G66XUp5GLklm4oiZy88yK",
      "balances": {
        "available": null,
        "current": 410,
        "iso_currency_code": "USD",
        "limit": 2000,
        "unofficial_currency_code": null
      },
      "mask": "3333",
      "name": "Plaid Credit Card",
      "official_name": "Plaid Diamond 12.5% APR Interest Credit Card",
      "subtype": "credit card",
      "type": "credit"
    },
    {
      "account_id": "Pp1Vpkl9w8sajvK6oEEKtr7vZxBnGpf7LxxLE",
      "balances": {
        "available": null,
        "current": 65262,
        "iso_currency_code": "USD",
        "limit": null,
        "unofficial_currency_code": null
      },
      "mask": "7777",
      "name": "Plaid Student Loan",
      "official_name": null,
      "subtype": "student",
      "type": "loan"
    }
  ],
  "item": {
    "available_products": [
      "balance",
      "credit_details",
      "identity",
      "investments"
    ],
    "billed_products": ["assets", "auth", "liabilities", "transactions"],
    "consent_expiration_time": null,
    "error": null,
    "institution_id": "ins_3",
    "item_id": "eVBnVMp7zdTJLkRNr33Rs6zr7KNJqBFL9DrE6",
    "webhook": "https://www.genericwebhookurl.com/webhook"
  },
  "request_id": "qk5Bxes3gDfv4F2"
}
```