Lending helps you make smarter credit decisions on small businesses by enabling you to pull your customers' latest data from the operating systems they are already using. You can use that data for automating decisioning and surfacing new insights on the customer, all via one API.
Lending API: Our Lending API helps you make smarter credit decisions on small businesses by enabling you to pull your customers' latest data from accounting, banking, and commerce software they are already using. It also includes features to help providers verify the accuracy of data and process it more efficiently.
The Lending API is built on top of the latest accounting, commerce, and banking data, providing you with the most important data points you need to get a full picture of SMB creditworthiness and make a comprehensive assessment of your customers.
Explore product | See OpenAPI spec
| Endpoints | Description |
|---|---|
| Companies | Create and manage your SMB users' companies. |
| Connections | Create new and manage existing data connections for a company. |
| Bank statements | Retrieve banking data from linked bank accounts. |
| Sales | Retrieve standardized sales data from a linked commerce software. |
| Financial statements | Financial data and reports from a linked accounting software. |
| Liabilities | Debt and other liabilities. |
| Accounts payable | Data from a linked accounting software representing money the business owes money to its suppliers. |
| Accounts receivable | Data from a linked accounting software representing money owed to the business for sold goods or services. |
| Transactions | Data from a linked accounting software representing transactions. |
| Company info | View company information fetched from the source platform. |
| Data integrity | Match mutable accounting data with immutable banking data to increase confidence in financial data. |
| Excel reports | Download reports in Excel format. |
| Manage data | Control how data is retrieved from an integration. |
| File upload | Endpoints to manage uploaded files. |
| Loan writeback | Implement the loan writeback procedure in your lending process to maintain an accurate position of a loan during the entire lending cycle. |
To add the SDK as a dependency to your project:
go get github.com/codatio/client-sdk-go/lendingpackage main
import (
"context"
lending "github.com/codatio/client-sdk-go/lending/v8"
"github.com/codatio/client-sdk-go/lending/v8/pkg/models/shared"
"log"
)
func main() {
ctx := context.Background()
s := lending.New()
res, err := s.AccountCategoriesUpdated(ctx, &shared.AccountCategoriesUpdatedWebhook{
AlertID: lending.String("a9367074-b5c3-42c4-9be4-be129f43577e"),
ClientID: lending.String("bae71d36-ff47-420a-b4a6-f8c9ddf41140"),
ClientName: lending.String("Bank of Dave"),
CompanyID: lending.String("8a210b68-6988-11ed-a1eb-0242ac120002"),
Data: &shared.AccountCategoriesUpdatedWebhookData{
ModifiedDate: lending.String("2022-10-23"),
},
DataConnectionID: lending.String("2e9d2c44-f675-40ba-8049-353bfcb5e171"),
Message: lending.String("Account categories updated for company f1c35bdc-1546-41b9-baf4-3f31135af968."),
RuleID: lending.String("70af3071-65d9-4ec3-b3cb-5283e8d55dac"),
RuleType: lending.String("Account Categories Updated"),
})
if err != nil {
log.Fatal(err)
}
if res != nil {
// handle response
}
}Available methods
- ListTransactions - List bank account transactions
- DownloadAttachment - Download bill attachment
- Get - Get bill
- GetAttachment - Get bill attachment
- List - List bills
- ListAttachments - List bill attachments
- DownloadAttachment - Download supplier attachment
- Get - Get supplier
- GetAttachment - Get supplier attachment
- List - List suppliers
- ListAttachments - List supplier attachments
- DownloadAttachment - Download customer attachment
- Get - Get customer
- GetAttachment - Get customer attachment
- List - List customers
- ListAttachments - List customer attachments
- DownloadAttachment - Download direct income attachment
- Get - Get direct income
- GetAttachment - Get direct income attachment
- List - List direct incomes
- ListAttachments - List direct income attachments
- DownloadAttachment - Download invoice attachment
- DownloadPdf - Get invoice as PDF
- Get - Get invoice
- GetAttachment - Get invoice attachment
- List - List invoices
- ListAttachments - List invoice attachments
- ListReconciled - List reconciled invoices
- GetAgedCreditors - Aged creditors report
- GetAgedDebtors - Aged debtors report
- IsAgedCreditorsAvailable - Aged creditors report available
- IsAgedDebtorsAvailable - Aged debtors report available
- List - List account balances
- Get - Get categorized bank statement
- EndUploadSession - End upload session
- GetUploadConfiguration - Get upload configuration
- SetUploadConfiguration - Set upload configuration
- StartUploadSession - Start upload session
- UploadBankStatementData - Upload data
- Create - Create company
- Delete - Delete a company
- Get - Get company
- List - List companies
- Update - Update company
- GetAccountingProfile - Get company accounting profile
- GetCommerceProfile - Get company commerce profile
- Create - Create connection
- Delete - Delete connection
- Get - Get connection
- List - List connections
- Unlink - Unlink connection
- Details - List data integrity details
- Status - Get data integrity status
- Summaries - Get data integrity summaries
- Download - Download Excel report
- Generate - Generate Excel report
- GetStatus - Get Excel report status
- Download - Download all files for a company
- ListUploaded - List all files uploaded by a company
- Upload - Upload files for a company
- Get - Get balance sheet
- GetCategorizedAccounts - Get categorized balance sheet statement
- Get - Get cash flow statement
- Get - Get profit and loss
- GetCategorizedAccounts - Get categorized profit and loss statement
- GenerateLoanSummary - Generate loan summaries report
- GenerateLoanTransactions - Generate loan transactions report
- GetLoanSummary - Get loan summaries
- ListLoanTransactions - List loan transactions
- Create - Create account
- GetCreateModel - Get create account model
- Create - Create bank account
- GetCreateUpdateModel - Get create/update bank account model
- Create - Create bank account transactions
- GetCreateModel - Get create bank account transactions model
- Create - Create direct cost
- GetCreateModel - Get create direct cost model
- Create - Create payment
- GetCreateModel - Get create payment model
- Create - Create source account
- CreateMapping - Create bank feed account mapping
- ListMappings - List bank feed account mappings
- Create - Create supplier
- GetCreateUpdateModel - Get create/update supplier model
- Create - Create transfer
- GetCreateModel - Get create transfer model
- GetStatus - Get data status
- AllDataTypes - Refresh all data
- DataType - Refresh data type
- GenerateReport - Generate report
- ListReports - List reports
- GetCustomerRetention - Get customer retention metrics
- GetLifetimeValue - Get lifetime value metrics
- GetRevenue - Get commerce revenue metrics
- GetOrders - Get orders report
- GetRefunds - Get refunds report
- DownloadAttachment - Download direct cost attachment
- Get - Get direct cost
- GetAttachment - Get direct cost attachment
- List - List direct costs
- ListAttachments - List direct cost attachments
This SDK defines the following custom types to assist with marshalling and unmarshalling data.
types.Date is a wrapper around time.Time that allows for JSON marshaling a date string formatted as "2006-01-02".
d1 := types.NewDate(time.Now()) // returns *types.Date
d2 := types.DateFromTime(time.Now()) // returns types.Date
d3, err := types.NewDateFromString("2019-01-01") // returns *types.Date, error
d4, err := types.DateFromString("2019-01-01") // returns types.Date, error
d5 := types.MustNewDateFromString("2019-01-01") // returns *types.Date and panics on error
d6 := types.MustDateFromString("2019-01-01") // returns types.Date and panics on errorSome of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retry.Config object to the call by using the WithRetries option:
package main
import (
"context"
lending "github.com/codatio/client-sdk-go/lending/v8"
"github.com/codatio/client-sdk-go/lending/v8/pkg/models/shared"
"github.com/codatio/client-sdk-go/lending/v8/pkg/retry"
"log"
"pkg/models/operations"
)
func main() {
ctx := context.Background()
s := lending.New(
lending.WithSecurity(shared.Security{
AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
}),
)
res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{
Description: lending.String("Requested early access to the new financing scheme."),
Name: "Technicalium",
}, operations.WithRetries(
retry.Config{
Strategy: "backoff",
Backoff: &retry.BackoffStrategy{
InitialInterval: 1,
MaxInterval: 50,
Exponent: 1.1,
MaxElapsedTime: 100,
},
RetryConnectionErrors: false,
}))
if err != nil {
log.Fatal(err)
}
if res.Company != nil {
// handle response
}
}If you'd like to override the default retry strategy for all operations that support retries, you can use the WithRetryConfig option at SDK initialization:
package main
import (
"context"
lending "github.com/codatio/client-sdk-go/lending/v8"
"github.com/codatio/client-sdk-go/lending/v8/pkg/models/shared"
"github.com/codatio/client-sdk-go/lending/v8/pkg/retry"
"log"
)
func main() {
ctx := context.Background()
s := lending.New(
lending.WithRetryConfig(
retry.Config{
Strategy: "backoff",
Backoff: &retry.BackoffStrategy{
InitialInterval: 1,
MaxInterval: 50,
Exponent: 1.1,
MaxElapsedTime: 100,
},
RetryConnectionErrors: false,
}),
lending.WithSecurity(shared.Security{
AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
}),
)
res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{
Description: lending.String("Requested early access to the new financing scheme."),
Name: "Technicalium",
})
if err != nil {
log.Fatal(err)
}
if res.Company != nil {
// handle response
}
}Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both.
By Default, an API error will return sdkerrors.SDKError. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to respective Errors tables in SDK docs for more details on possible error types for each operation.
For example, the Create function may return the following errors:
| Error Type | Status Code | Content Type |
|---|---|---|
| sdkerrors.ErrorMessage | 400, 401, 402, 403, 429, 500, 503 | application/json |
| sdkerrors.SDKError | 4XX, 5XX | */* |
package main
import (
"context"
"errors"
lending "github.com/codatio/client-sdk-go/lending/v8"
"github.com/codatio/client-sdk-go/lending/v8/pkg/models/sdkerrors"
"github.com/codatio/client-sdk-go/lending/v8/pkg/models/shared"
"log"
)
func main() {
ctx := context.Background()
s := lending.New(
lending.WithSecurity(shared.Security{
AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
}),
)
res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{
Description: lending.String("Requested early access to the new financing scheme."),
Name: "Technicalium",
})
if err != nil {
var e *sdkerrors.ErrorMessage
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
var e *sdkerrors.SDKError
if errors.As(err, &e) {
// handle error
log.Fatal(e.Error())
}
}
}The default server can also be overridden globally using the WithServerURL(serverURL string) option when initializing the SDK client instance. For example:
package main
import (
"context"
lending "github.com/codatio/client-sdk-go/lending/v8"
"github.com/codatio/client-sdk-go/lending/v8/pkg/models/shared"
"log"
)
func main() {
ctx := context.Background()
s := lending.New(
lending.WithServerURL("https://api.codat.io"),
lending.WithSecurity(shared.Security{
AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
}),
)
res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{
Description: lending.String("Requested early access to the new financing scheme."),
Name: "Technicalium",
})
if err != nil {
log.Fatal(err)
}
if res.Company != nil {
// handle response
}
}The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface:
type HTTPClient interface {
Do(req *http.Request) (*http.Response, error)
}The built-in net/http client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout.
import (
"net/http"
"time"
"github.com/myorg/your-go-sdk"
)
var (
httpClient = &http.Client{Timeout: 30 * time.Second}
sdkClient = sdk.New(sdk.WithClient(httpClient))
)This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration.
This SDK supports the following security scheme globally:
| Name | Type | Scheme |
|---|---|---|
AuthHeader |
apiKey | API key |
You can configure it using the WithSecurity option when initializing the SDK client instance. For example:
package main
import (
"context"
lending "github.com/codatio/client-sdk-go/lending/v8"
"github.com/codatio/client-sdk-go/lending/v8/pkg/models/shared"
"log"
)
func main() {
ctx := context.Background()
s := lending.New(
lending.WithSecurity(shared.Security{
AuthHeader: "Basic BASE_64_ENCODED(API_KEY)",
}),
)
res, err := s.Companies.Create(ctx, &shared.CompanyRequestBody{
Description: lending.String("Requested early access to the new financing scheme."),
Name: "Technicalium",
})
if err != nil {
log.Fatal(err)
}
if res.Company != nil {
// handle response
}
}If you encounter any challenges while utilizing our SDKs, please don't hesitate to reach out for assistance. You can raise any issues by contacting your dedicated Codat representative or reaching out to our support team. We're here to help ensure a smooth experience for you.