Requesting Account Information (AIS)

PSD2ClosedPSD2 stands for Payment Services Directive 2 and is a new EU regulation in effect since September 14, 2019. It governs electronic and other non-cash payments. The main provision of PSD2 is for Strong Customer Authentication (SCA), a process that seeks to make online payments more secure and reduce fraud while increasing authorisation rates. The European Banking Authority (EBA) recently extended the deadline for PSD2 compliance until December 31, 2020. defines the "Account Information Service" as an online service to provide consolidated information (balance, transaction history) on one or more payment accounts held by a PSUClosedPayment Services User – an individual person or legal business entity making use of an Open Banking service as a payee, payer or both. with one or more payment service providers.

As it relates to an AISPClosedAccount Information Service Provider – a TPP authorised to access consumer or business account data from the account holder's financial institutions with the account holder's explicit consent., this essentially means that, under open banking protocols, banks allow access to a customer's account data by TPPs only if the customer (PSU) explicitly gives consent (grants permission) to let the bank allow such access.

In the context of the account information queries discussed here, AISP and TPPClosedThird-Party Provider – an authorised online service provider introduced as part of Open Banking. TPPs exist outside of the account holder’s relationship with their bank but may be involved in transactions carried out by the user. are one and the same.

The scope of analysis and service Token supports includes comparing a PSU's accounts and transaction history to a range of financial service options, aggregating data across participating financial institutions and customers to create marketing profiles, and making new transactions and account changes on the PSU's behalf.

To access Account Details, the value of supportsInformation must be true for each bank displayed to the user for selection from the GET /banks payload.

API support for accessing a PSU's account information institutes a communications workflow that ensures all PSD2 mandates for PSU consent and authorisation are met.

Pictured above (hover to enlarge) is the general flow. Guidance on making the appropriate POST and GET calls, as well as handling Token's responses to these requests is covered next.

Detailed API request-reply code samples supporting each use case are available in the API's Postman profiles. Download the PostmanClosedA tool for performing integration testing with your API. It allows for repeatable, reliable tests that can be automated and used in a variety of environments and includes useful tools for persisting data and simulating how a user might actually be interacting with the system. app from https://www.postman.com/downloads/.

Correlated in the following table, the {{BASE_URL}} for calls and redirects depends on the environment in which you're operating.

Environment BASE_URL
API calls
Production https://api.token.io
Sandbox https://api.sandbox.token.io
Web App Redirect (for consent)
Production https://web-app.token.io
Sandbox https://web-app.sandbox.token.io

Be sure to include the BASE_URL for the appropriate environment and purpose in each call.

Making a Token Request

To initiate a request with the bank for account information, you'll need to be able to identify yourself as a TPP in good standing using one of two ways; either your Member ID or your Alias, defined as follows:

  • Member ID – unique value generated by the Developer Dashboard when you signed up.
  • Alias – unique email or domain you supplied to the dashboard when you signed up.

For purposes of an AIS request — to avoid a mismatch caused by a typo — use both.

You can obtain the values from the dashboard by following these steps:

    (1)   If the dashboard isn't already open in a browser tab, sign in.

    (2)   Click Member Information in navigation panel on the left.

    (3)  Click the "eye" icon to the right of each value to reveal it.

    (4)   Copy the value you need.

Once the PSU gives consent for you to initiate AIS on the PSU's behalf, here's the call for POSTing /token-requests:

{

    "requestPayload": {

        "to": {

            "alias": { // include only one type and its corresponding value

                "realmId": "value available from dashboard",

                "type": "EIDAS",

                "type": "EMAIL",

                "value": "noverify@token.io" // example value

                "value": "value available from dashboard"

            }

            "id": "m:nP4w3u5y8ddrxDJkjimgSX9e4fZ:5zKtXEAq"// TPP member ID

        },

        "authorizationMetadata": {   // map from response to GET /banks call

            "additionalProp1": "string",

            "additionalProp2": "string",

            "additionalProp3": "string"

        },

        "accessBody": {

            "type": [

                "ACCOUNTS",

                "BALANCES",

                "TRANSACTIONS"

                "TRANSFER_DESTINATIONS"

            ]

        },

        "description": "test",

        "redirectUrl": "https://sample-merchant-domain.com"

    }

}

The most important request fields and their corresponding descriptions are listed in the following table.

Key Fields in the Access Token Request
Field Required/Optional Description
accessBody Required Specifies the type of information for which access permission is requested:

  • ACCOUNTS – list of accounts with associated names

  • BALANCES – current balance of each requested account

  • TRANSACTIONS – recorded account activity in terms of debits and credits

  • TRANSFER_DESTINATIONS – account number and sort code, where applicable

alias Required A human-readable proxy for your member identifier that contains your alias type (DOMAIN, EMAIL, other) and a value string. Find your alias in the sandbox after logging in by clicking the Payload Constructor button in the Payload Builder card.
authorizationMetadata Required Maps the key-value pairs from the GET /banks response, where key is the name of the field and value is the value of the field. Needed to capture additional information from the user for initial authorization by the bank, thereby allowing the user to proceed with providing consent for the initiation request.
callbackState Optional TPP-specified string allowing state to be persisted between the request and callback phases of the flow
description Optional Description of the access request with the following qualifiers:

  •  description in a subsequent call must match description in originating request

  •  description omitted in originating request must also be omitted in subsequent calls

  •  description omitted in subsequent call will be replaced with refId

This description field maps to description in the bank's consentRequest presented to the user.

Warning: If description in a subsequent token request for lookups/changes/updates (retrieve, redeem, or cancel) doesn't match the description in the originating token request, an exception will be thrown.

id Required Member ID of the TPP, a constant value in all requests; find yours in the sandbox after logging in by clicking the Construct Payload button in the Payload Builder card.
redirectUrl Required Defines the URL to which the user is returned upon a successful token request and/or redemption.
refId Optional Reference identifier for the token; not to be confused with requestId.

RefId maps to tppRefId in the bank's consentRequest. It is needed to match/verify the originating token request with the bank's consent request.

Warning: A description mismatch between the originating token request and subsequent token lookups/changes/updates (retrieve, redeem, or cancel) will throw an exception.

token_expiration Optional Sets the consent expiration date and time for access requests (default is 90 days per PSD2ClosedPSD2 stands for Payment Services Directive 2 and is a new EU regulation in effect since September 14, 2019. It governs electronic and other non-cash payments. The main provision of PSD2 is for Strong Customer Authentication (SCA), a process that seeks to make online payments more secure and reduce fraud while increasing authorisation rates. The European Banking Authority (EBA) recently extended the deadline for PSD2 compliance until December 31, 2020. regulation); override of the default value is not supported by all banks. This is a particularly important parameter to pass to CMA9ClosedAs part of the Open Banking initiative, the CMA9 are the nine largest banks in the UK as determined by the Competition and Markets Authority (CMA). The CMA is an independent department of the UK government chartered to promote market competition and fairness, and reduce any harmful monopolies. banks to ensure an adequate custom consent expiry period is set for the access token upon successful authorisation.

JSON in a successful response payload will look something like this:

{"Data:["Permissions":["ReadAccountsDetails","ReadBalances"], "ExpirationsDateTime":"2020-10-21T18:03:07.371+01:00"}, "Risk":{}}

traceID Optional TPP-provided unique value captured by Token and sent across to the bank to be stored with the request throughout its lifecycle as an audit-trail aid.

Caution: A PANClosedPrimary Account Number – refers to a 14-, 15-, 16-, or even up to 19-digit number generated as a unique identifier designated for a primary account; also called payment card number and permanent card number. is disallowed in the token request payload within the refId and description fields. In accordance with the PA-DSSClosedPayment Application Data Security Standard – Council-managed program formerly under the supervision of the Visa Inc. program known as the Payment Application Best Practices (PABP). The goal of PA-DSS is to help software vendors and others develop secure payment applications that do not store prohibited data, such as full magnetic stripe, CVV2 or PIN data, and ensure their payment applications support compliance with the PCI DSS. Payment applications that are sold, distributed or licensed to third parties are subject to the PA-DSS requirements. In-house payment applications developed by merchants or service providers that are not sold to a third party are not subject to the PA-DSS requirements, but must still be secured in accordance with the PCI DSS. security standard, RegexClosedAPI to define a pattern for searching or manipulating strings. is used for pattern matching of numeric strings that intentionally or inadvertently reveal or resemble a PAN in the refId or description of a token request. Potential PAN patterns found will now throw an exception.

Here's an example of the response you'll receive:

{

   "tokenRequest": {

        "id": "rq:3RKfCA7KQEEZERLoFsAt3MoAnoP5:5zKtXEAq", // RequestId; add to BASE_URL for consent

        "requestPayload": {

            "redirectUrl": "https://sample-merchant-domain.com/ais"

            "to": {

                "alias": {

                    "type": "EMAIL",

                    "value": noverify@token.io"

                },

                "id": "m:23xPa7sYxTG2PeK72MmaFPT1RiPW:5zKtXEAq" // TPP member ID

            },

        "authorizationMetadata": {   // map from response to GET /banks call

            "additionalProp1": "string",

            "additionalProp2": "string",

            "additionalProp3": "string"

        },

            "accessBody": {

                "type": [

                    "ACCOUNTS",

                    "BALANCES",

                    "TRANSACTIONS",

                    "TRANSFER_DESTINATIONS"

                ]

            },

            "description": "test"

        }

    }

}

From the response, create the redirect URL by appending the request id (shown above in red) to the appropriate redirect BASE_URL, then send it to the user for the PSU's explicit consent.

https://{{BASE_URL}}/app/request-token/{{Insert request-id here}}

// example = https://web-app.sandbox.token.io/app/request-token/rq:3RKfCA7KQEEZERLoFsAt3MoAnoP5:5zKtXEAq

Tip: You can specify a particular language by passing its language code (lang=country-code) as a parameter appended to the URL above, which the user can override in the webapp according to personal preference. Here's an example for passing the desired ISO 639-1ClosedCodes for the representation of names of languages—Part 1: Alpha-2 code, is the first part of the ISO 639 series of international standards for language codes. Part 1 covers the registration of two-letter codes. There are 184 two-letter codes registered as of December 2018. The registered codes cover the world's major languages. See https://www.iso.org/iso-639-language-codes.html language code for German (de):

https://web-app.token.io/app/request-token/rq:o9adbFqJXcaDGNDaykPvpSZFZDW:5zKtXEAq?lang=de

After user consent is provided, the bank will redirect the user back to the TPP with tokenId as a query parameter.

"redirectUrl": "https://sample-merchant-domain.com"/ais?tokenId=sample_token_id

To derive the complete redirect URL, you'll need to URL decodeClosedURL encoding makes sure that the characters in the URL that are not allowed to be put into the URL directly can still be used. For example a space or : is not allowed, but replacing it with %20 or %3A encodes a space or : (and most browsers will display a space in the browser bar). For encoded URLs, use Java's URLDecoder (java.net.URLDecoder) unless you have a different preference. the tokenId value provided.

Using the tokenId sent by the bank, the TPP can now access everything for which the user gave consent. The scope of consent must correspond to the resources requested by the TPP in the POST /token requests call (within the accessbody.type array). All subsequent AIS guidance discussed here assumes that consent for the ACCOUNTS, BALANCES, TRANSACTIONS, and/or TRANSFER_DESTINATIONS is granted by the user.

Important: The GET /accounts call discussed next must pass in an appropriate authorisation header. See Construct the Request Authorisation Header in Onboarding to review the details.

GET /accounts

As a recognized TPP, access the user's account information by making a GET request to the /accounts endpoint. Remember to include the base URL.

Here's an example of the bank's response:

{

    "accounts": [

        {

         "id": "a:8DbPteGnytmMbKXdnWTReeRB6cYWKXZ84JgLTBC7fKL4:5zKcENpV",

         "name": "N26 Main Checking",

         "bankId": "n26",

         "accountFeatures": {

         "supportsInformation": true,

         "supportsSendPayment": true,

         "supportsReceivePayment": true

         },

         "accountDetails": {

             "identifier": "MJzqR1A2NSgTg",

             "type": "CHECKING",

             "status": "ACTIVE",

             "metadata": {

                 "clientId": "1"

             }

         }

       },

    {

      "id": "a:6hLu9jSeDpXV9cWafdQxvxVFgoptZX65hwVWPgzCBBGL:5zKcENpV",

      "name": "N26 Savings",

      "bankId": "n26",

      "accountFeatures": {

          "supportsInformation": true,

          "supportsSendPayment": true,

          "supportsReceivePayment": true

      },

      "accountDetails": {

          "identifier": "r4KIihP9twv5",

          "type": "CHECKING",

          "status": "ACTIVE",

          "metadata": {

              "clientId": "1"

          }

      }

    }

  ]

}

Important Update: In the GET /accounts response payload, account_identifiers are now specified in accountDetails, which include bic and account_holder_name. Previously, TPPs could obtain these data — account identifiers, BICClosedBank Identifier Code – a unique identifier for a specific financial institution. A BIC is composed of a 4-character bank code, a 2-character country code, a 2-character location code and an optional 3-character branch code., and customer name — after a GET /account call with a subsequent GET /account/{account_Id}/transfer-destinations call, wherein the debit-side bank returned its preferred transfer method(s) — SEPAClosedSingle Euro Payments Area – a payments system created by the European Union (EU) which harmonizes the way cashless payments transact between euro countries. European consumers, businesses, and government agents who make payments by direct debit, instant credit transfer, and through credit transfers use the SEPA architecture. The single euro payment area is approved and regulated by the European Commission. SEPA currently includes 36 members. It encompasses the 28 EU member states along with Iceland, Norway, Liechtenstein, Switzerland, Andorra, Vatican City, Monaco and San Marino. The single euro payment area remains an ongoing, collaborative process between these parties. SEPA is in the process of harmonizing rules regarding mobile and online payments., FPSClosedFaster Payments Service – UK banking initiative to reduce payment times between different banks' customer accounts from the three working days that transfers take using the long-established BACS system to typically a few seconds., DomesticClosedBanks make domestic wire transfers (as opposed to international wire transfers) to send funds to financial institutions residing in the same country or financial zone., etc. — along with the bic and CustomerData.

However, to optimise API utilisation and eliminate the additional call to transfer-destinations to get account details, banks are now required to populate account_identifiers, bic and account_holder_name in the accountDetails returned by the GET /accounts call.

GET /accounts/{account_id}/balance

To access the user's account balance information, the TPP can now make a GET request to the /accounts/{account_id}/balance endpoint, where {account_id} is an id (shown above in yellow) returned in the response.

Here's an example of the response to the GET /accounts{account-id}/balance call:

{

    "balance": {

        "accountId": "a:8DbPteGnytmMbKXdnWTReeRB6cYWKXZ84JgLTBC7fKL4:5zKcENpV",

        "current": {

            "currency": "USD",

            "value": "12009.1000"

        },

        "available": {

            "currency": "USD",

            "value": "12009.1000"

        }

    },

    "status": "SUCCESSFUL_REQUEST"

}

The TPP can also retrieve balances for multiple accounts in a single call. Simply make the GET request to /account-balance?account_id={{ACCOUNT_ID_1}}&account_id={{ACCOUNT_ID_2}}&etc...

Based on the responses to these respective account balance queries, you can display the requested account information to the user.

GET /accounts/{account_id}/transactions

In accordance with the guidance above, a typical Transaction History payload for a selected account (based on a GET /accounts/{account_id}/transactions call takes the following form:

{

 "transactions": [{

     "id": "42909b155d4942299c39017686b5dc36",

      "type": "DEBIT",

      "status": "SUCCESS",

      "amount": {

          "currency": "EUR",

          "value": "100.0000"

      },

      "tokenId": "tt:3kFGtpEKHu8S2fJuEkb6YPnHZ4bJ2oUrYPCsJop68vCH:5zKcENpV",

      "tokenTransferId": "t:2UhwCZ3BMaEcAUK8bZdukor7NL4tH6TBuu6aJMp5KKfX:5zKcENpV",

      "createdAtMs": "1576788659686",

      "providerTransactionDetails": {}

 }],

 "offset": "pJUkL87QdDQu3mL9z1VK793RWasi19ERywLHP3L4uwjmEfcZPEPDU2R6rbDj6KbSogQcv",

 "status": "SUCCESSFUL_REQUEST"

}

Consistent with the request-response structure discussed above, the API also supports information access to standing order information (GET /accounts/{account_id}/standing-orders/{standing_order_id}), along with a specific account's established transfer destinations (GET /accounts/{account_id}/transfer-destinations) to fetch the IBANClosedInternational Bank Account Number – a number attached to all bank accounts in the EU countries, plus Norway, Switzerland, Liechtenstein and Hungary. The IBAN is made up of a code identifying the country to which the account belongs, the account holder's bank, and the account number itself..

Payee Information. Based on the standard adopted by the bank, creditor account (payee) information (legal name and/or address) is included in customerData within providerTransactionDetails for single transactions and in customerData within providerStandingOrderDetails for standing orders, outlined as follows:

Note: For all GET /account and GET /accounts endpoints, please ensure that you request permission for each desired endpoint — ACCOUNTS, BALANCES, TRANSACTIONS, and/or TRANSFER_DESTINATIONS — in the accessBody of your token request.

* * * *

Optionally, you can add a customer tracking header — customer-initiated (boolean), token-customer-ip-address, token-customer-device-id — to GET /accounts, GET /accounts/{account_id}/balance, and GET /accounts/{account_id}/transactions calls to let the bank know that a particular API call was initiated by the PSUClosedPayment Services User – an individual person or legal business entity making use of an Open Banking service as a payee, payer or both.. This may be useful in circumnavigating bank restrictions that impose a 4-times-a-day (i.e., the same 24-hour period) access limit on the same AISPClosedAccount Information Service Provider – a TPP authorised to access consumer or business account data from the account holder's financial institutions with the account holder's explicit consent. in accordance with RTS regulationsClosedRegulatory Technical Standard – detailed specifications to achieve the strict security requirements for payment service providers in the EU..

For example:

header 'customer-initiated:true'\

-header 'token-customer-ip-address:127.0.0.1'\

-header 'token-customer-device-id:Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0:'

Please refer to the API's Swagger Reference for additional details on all of the above.