Enriching a Customer's Transactions

Guide as to how customer transactions can be enriched

When a bank statement or open banking data is submitted to Inscribe, we identify the transactions present. Inscribe takes these raw transactions and uses the proprietary Credit Insights engine to enrich each transaction with the following elements:

  • Category
  • Method
  • Vendor

This guide will walk you through the entire process of getting enriched customer transactions, from creating a customer to accessing each of that customer’s transaction objects.

📘

Prerequisite(s)

  • Retrieve your API key as detailed here .

Get Enriched Transactions Flow

  • Create Customer.
  • Associate financial data with the Customer. Financial data in this scenario can be in the form of bank statement documents or Open Banking data. Both forms of financial data can be submitted simultaneously and the transactions will be returned with the data source identified.
  • Verify that the uploaded documents are not fraudulent.
  • View the transaction objects associated with a customer.
  • View the transaction objects associated with an individual bank account.

Step by Step

1. Create Customer

To begin, we must create a customer whose transactions we want to view. Additional information on creating a customer can be viewed here.

sts  
URL = "<https://api.inscribe.ai/api/v2>"  
API_KEY = "Inscribe ..."

headers = {  
    "Authorization": API_KEY,  
    "accept": "application/json",  
    "content-type": "application/json"  
}

payload = {"name": "John Smith"}  
response = requests.post(f"{URL}/customers", json=payload, headers=headers)  
customer = response.json()

2. Associate Financial Data with the Customer

Once your customer has been created, we must associate transactional data with the customer. This data can be in the form of bank statements or open banking data. Both forms can also be associated with the one customer.

To Submit a Document:

customer_id = customer["id"]  
with open("DOCUMENT_FILE_PATH", "rb+") as document:  
    filename = os.path.basename(document.name)  
    files = {"file": (filename, document, "application/octet-stream")}  
    response = requests.post(  
        f"{URL}/customers/{customer_id}/documents",  
        files=files,  
        headers=headers  
    )

To Submit Open Banking Data:

customer_id = customer["id"]  
with open("PLAID_ASSET_FILE_PATH", "r") as asset_report:  
    data = asset_report.read()  
    response = requests.post(  
        f"{URL}/customers/{customer_id}/plaid_assets",  
        headers=headers,  
        data=data  
    )

3a. View the Transactions associated with a Customer

Finally, once the transactional data has been submitted and processed, the customer's transactions are ready to be viewed. The transactions are paginated, therefore you must specify the number of transactions you would like to view per page. A cursor is returned in the metadata of each response which can be used to get the next page of transactions.

The example below demonstrates accessing two pages of transactions where there are 15 transactions per page.

# Get first page of Transactions

response = requests.get(  
    f"{URL}/customers/{customer_id}/transactions?size=15", headers=headers  
)

transactions_first_page = response.json()  
cursor = transactions_first_page["pagination"]["cursor"]

# Get second page of Transactions

response = requests.get(  
    f"{URL}/customers/{customer_id}/transactions?size=15&cursor={cursor}",  
    headers=headers  
)  
transactions_second_page = response.json()  
cursor = transactions_second_page["pagination"]["cursor"]

 3b. View the Customer’s Transactions associated with a Specific Bank Account

If you wish to view the transactions with only one specific bank account for a customer, you can do so by including the bank account identifier in the URL. These transactions are paginated in the same way as step 3a. In this example we will use a random bank account associated with the customer. Detailed information on accessing bank account identifiers can be found here.

# Get BankAccount ID

response = requests.get(  
    f"{URL}/customers/{customer_id}/bank_accounts?size=1",  
    headers=headers  
)  
bank_accounts = response.json()  
bank_account_id = bank_accounts["data"][0]["id"]

# Get first page of Transactions

response = requests.get(  
    f"{URL}/customers/{customer_id}/bank_accounts/{bank_account_id}/transactions?size=15",  
    headers=headers  
)

transactions_first_page = response.json()  
cursor = transactions_first_page["pagination"]["cursor"]

# Get second page of Transactions

response = requests.get(  
    f"{URL}/customers/{customer_id}/transactions?size=15&cursor={cursor}",  
    headers=headers  
)  
transactions_second_page = response.json()  
cursor = transactions_second_page["pagination"]["cursor"]