Skip to main content

Configure customer in Codat

Create a company, its connection, and a source account that form the structure required to establish a bank feed

Overview

When implementing your bank feed solution, you need to create your customer as a company in Codat before registering their accounting software as a connection and creating a source account to represent the company's actual bank account.

You can see how these elements fit together and where they sit in the overall bank feeds process on the diagram below.

A diagram demonstrating the relationship between various Codat concepts and subsequent steps of the Bank Feeds API process

Authorize your API calls

Remember to authenticate when making calls to our API. Navigate to Developers > API keys in the Portal to pick up your authorization header.

Create a company

Within Bank Feeds API, a company represents your SMB customer that wishes to export their transactions from your application to their accounting software.

Use the Create company endpoint to represent your customer in Codat. Make sure to store the company ID as you will use it to establish a connection to an accounting software.

const companyResponse = bankFeedsClient.companies.create({
name: companyName,
});

if(companyResponse.statusCode == 200){
throw new Error("Could not create company")
}

const companyId = companyResponse.company.id
console.log(companyId)

Create a connection

Next, use the Create connection endpoint to connect the company to an accounting data source via one of our integrations. This will allow you to synchronize data with that source.

In the request body, specify a platformKey of the accounting software you're looking to connect.

Accounting softwareplatformKey
Quickbooks Online Bankfeedshcws
Oracle NetSuiteakxx
Xerogbol
FreeAgentfbrh
Sage bank feedsolpr

As an example, let's create a QuickBooks Online (QBO) connection. In response, the endpoint returns a dataConnection object with a PendingAuth status and a linkUrl. Direct your customer to the linkUrl to initiate our Link auth flow and enable them to authorize this connection.

const connectionResponse = bankFeedsClient.connections.create({
requestBody: {
platformKey: "hcws",
},
companyId: companyResponse.company.id,
});

console.log(connectionResponse.connection.linkUrl)
One-time password for QBO

For QBO, the linkUrl contains a one-time password (OTP) that expires after one hour. If the OTP has expired, your customer will receive a 401 error when loading the page. Generate a new OTP by calling the Get connection endpoint.

View code snippets
const connectionOtpResponse = bankFeedsClient.connections.get({
companyId: companyResponse.company.id,
connectionId: connectionResponse.connection.id,
});

console.log(connectionOtpResponse.connection.linkUrl)

Deauthorize a connection

If your customer wants to revoke their approval and sever the connection to their accounting software, use the Unlink connection endpoint.

You can learn more about connection management best practices and see how you can provide this functionality in your app's UI.

const unlinkResponse = bankFeedsClient.connections.unlink({
requestBody: {
status: DataConnectionStatus.Unlinked
},
companyId: companyResponse.company.id,
connectionId: connectionResponse.connection.id,
});

Create a source account

Finally, create a source account using our Create source account endpoint. It represents the company's actual financial account, savings account or credit card within Codat. We categorize accounts as a credit or a debit account type for standardization.

If you require several source bank accounts, simply use the same endpoint to create additional accounts for the existing accounting connection.

As an example, let's create a debit account. If the source account passes validation, you will receive a synchronous response with a 200 status code indicating a successful operation.

UK-specific requirements

For bank accounts in GBP, sortCode is also a required field.

const sourceAccountResponse = bankFeedsClient.sourceAccounts.create({
sourceAccount: {
id: "ac-001",
accountName: "Checking Account",
accountType: "checking",
accountNumber: "01120912",
currency: "USD",
balance: 4002
},
companyId: companyResponse.company.id,
connectionId: connectionResponse.connection.id
});

Once the source account is successfully created, guide your customer through the mapping process to associate it with a corresponding target account in their accounting software. The account will stay in a pending status until that happens, and it must change to linked before you can successfully transmit any bank transactions.

Multi-currency accounts

You can create multiple accounts in different currencies using the same Create source account endpoint for the company and the connection. If the user has not enabled multi-currency in their accounting software, you will receive an error message which you can display to the user.

Update a source account

You may need to modify a source account before the mapping is finalized. For example, your customer might want a bank account name to appear in their accounting software. To do that, use the Update source account endpoint.

const sourceAccountUpdateResponse = bankFeedsClient.sourceAccounts.update({
sourceAccount: {
id: "ac-001",
accountName: "Bank of Dave Checking Account",
accountType: "checking",
accountNumber: "01120912",
currency: "USD",
balance: 4002
},
accountId: sourceAccountResponse.sourceAccount.id,
companyId: companyResponse.company.id,
connectionId: connectionResponse.connection.id
});

Remove a source account

If your customer decides to close their account, you can also remove it from Codat using the Delete source account endpoint. This will not delete the account from your customer's accounting software, but it will disable the bank feed, preventing any new transactions from appearing.

const sourceAccountDeleteResponse = bankFeedsClient.sourceAccounts.delete({
accountId: sourceAccountResponse.sourceAccount.id,
companyId: companyResponse.company.id,
connectionId: connectionResponse.connection.id
});
Recap

You have created the structure of key objects required by Codat's Bank Feeds API: a company, its connection to an accounting data source, and a source account.

Next, provide your customer with a mapping process interface so they can associate the source account with a target account in their accounting software.


  • Enable your customer to map accounts to their accounting software via a mapping UI.

Was this page useful?
👏
👍
🤔
👎
😭