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: Our Lending solution 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 solution 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 solution | 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 NuGet package to a .NET project:
dotnet add package Codat.LendingTo add a reference to a local instance of the SDK in a .NET project:
dotnet add reference Codat/Lending/Codat.Lending.csprojusing Codat.Lending;
using Codat.Lending.Models.Components;
using Codat.Lending.Models.Requests;
var sdk = new CodatLending(authHeader: "Basic BASE_64_ENCODED(API_KEY)");
ListCompaniesRequest req = new ListCompaniesRequest() {
Query = "id=e3334455-1aed-4e71-ab43-6bccf12092ee",
OrderBy = "-modifiedDate",
Tags = "region=uk && team=invoice-finance",
};
var res = await sdk.Companies.ListAsync(req);
// handle responseAvailable methods
- ListTransactions - List bank account transactions
- List - List bills
- Get - Get bill
- ListAttachments - List bill attachments
- GetAttachment - Get bill attachment
- DownloadAttachment - Download bill attachment
- List - List suppliers
- Get - Get supplier
- ListAttachments - List supplier attachments
- GetAttachment - Get supplier attachment
- DownloadAttachment - Download supplier attachment
- List - List customers
- Get - Get customer
- ListAttachments - List customer attachments
- GetAttachment - Get customer attachment
- DownloadAttachment - Download customer attachment
- List - List direct incomes
- Get - Get direct income
- GetAttachment - Get direct income attachment
- DownloadAttachment - Download direct income attachment
- ListAttachments - List direct income attachments
- ListReconciled - List reconciled invoices
- List - List invoices
- Get - Get invoice
- DownloadPdf - Get invoice as PDF
- ListAttachments - List invoice attachments
- GetAttachment - Get invoice attachment
- DownloadAttachment - Download invoice attachment
- IsAgedDebtorsAvailable - Aged debtors report available
- GetAgedDebtors - Aged debtors report
- IsAgedCreditorsAvailable - Aged creditors report available
- GetAgedCreditors - Aged creditors report
- GetUploadConfiguration - Get upload configuration
- SetUploadConfiguration - Set upload configuration
- StartUploadSession - Start upload session
- UploadBankStatementData - Upload data
- EndUploadSession - End upload session
- List - List account balances
- Get - Get categorized bank statement
- List - List companies
- Create - Create company
- Replace - Replace company
- Update - Update company
- Delete - Delete a company
- Get - Get company
- GetAccountingProfile - Get company accounting profile
- GetCommerceProfile - Get company commerce profile
- List - List connections
- Create - Create connection
- Get - Get connection
- Delete - Delete connection
- Unlink - Unlink connection
- Status - Get data integrity status
- Summaries - Get data integrity summaries
- Details - List data integrity details
- Generate - Generate Excel report
- GetStatus - Get Excel report status
- Download - Download Excel report
- ListUploaded - List all files uploaded by a company
- Download - Download all files for a company
- Upload - Upload files for a company
- GetCategorizedAccounts - Get categorized balance sheet statement
- Get - Get balance sheet
- Get - Get cash flow statement
- GetCategorizedAccounts - Get categorized profit and loss statement
- Get - Get profit and loss
- GenerateLoanTransactions - Generate loan transactions report
- ListLoanTransactions - List loan transactions
- GenerateLoanSummary - Generate loan summaries report
- GetLoanSummary - Get loan summaries
- GetCreateModel - Get create account model
- Create - Create account
- GetCreateUpdateModel - Get create/update bank account model
- Create - Create bank account
- GetCreateModel - Get create bank account transactions model
- Create - Create bank account transactions
- GetCreateModel - Get create direct cost model
- Create - Create direct cost
- GetCreateModel - Get create payment model
- Create - Create payment
- Create - Create source account
- ListMappings - List bank feed account mappings
- CreateMapping - Create bank feed account mapping
- GetCreateUpdateModel - Get create/update supplier model
- Create - Create supplier
- GetCreateModel - Get create transfer model
- Create - Create transfer
- GenerateReport - Generate report
- ListReports - List reports
- GetStatus - Get data status
- AllDataTypes - Refresh all data
- DataType - Refresh data type
- GetRevenue - Get commerce revenue metrics
- GetCustomerRetention - Get customer retention metrics
- GetLifetimeValue - Get lifetime value metrics
- GetOrders - Get orders report
- GetRefunds - Get refunds report
- List - List direct costs
- Get - Get direct cost
- GetAttachment - Get direct cost attachment
- DownloadAttachment - Download direct cost attachment
- ListAttachments - List direct cost attachments
The default server can be overridden globally by passing a URL to the serverUrl: string optional parameter when initializing the SDK client instance. For example:
using Codat.Lending;
using Codat.Lending.Models.Components;
using Codat.Lending.Models.Requests;
var sdk = new CodatLending(
serverUrl: "https://api.codat.io",
authHeader: "Basic BASE_64_ENCODED(API_KEY)"
);
ListCompaniesRequest req = new ListCompaniesRequest() {
Query = "id=e3334455-1aed-4e71-ab43-6bccf12092ee",
OrderBy = "-modifiedDate",
Tags = "region=uk && team=invoice-finance",
};
var res = await sdk.Companies.ListAsync(req);
// handle responseThis SDK supports the following security scheme globally:
| Name | Type | Scheme |
|---|---|---|
AuthHeader |
apiKey | API key |
To authenticate with the API the AuthHeader parameter must be set when initializing the SDK client instance. For example:
using Codat.Lending;
using Codat.Lending.Models.Components;
using Codat.Lending.Models.Requests;
var sdk = new CodatLending(authHeader: "Basic BASE_64_ENCODED(API_KEY)");
ListCompaniesRequest req = new ListCompaniesRequest() {
Query = "id=e3334455-1aed-4e71-ab43-6bccf12092ee",
OrderBy = "-modifiedDate",
Tags = "region=uk && team=invoice-finance",
};
var res = await sdk.Companies.ListAsync(req);
// handle responseSome 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 pass a RetryConfig to the call:
using Codat.Lending;
using Codat.Lending.Models.Components;
using Codat.Lending.Models.Requests;
var sdk = new CodatLending(authHeader: "Basic BASE_64_ENCODED(API_KEY)");
ListCompaniesRequest req = new ListCompaniesRequest() {
Query = "id=e3334455-1aed-4e71-ab43-6bccf12092ee",
OrderBy = "-modifiedDate",
Tags = "region=uk && team=invoice-finance",
};
var res = await sdk.Companies.ListAsync(
retryConfig: new RetryConfig(
strategy: RetryConfig.RetryStrategy.BACKOFF,
backoff: new BackoffStrategy(
initialIntervalMs: 1L,
maxIntervalMs: 50L,
maxElapsedTimeMs: 100L,
exponent: 1.1
),
retryConnectionErrors: false
),
request: req
);
// handle responseIf you'd like to override the default retry strategy for all operations that support retries, you can use the RetryConfig optional parameter when intitializing the SDK:
using Codat.Lending;
using Codat.Lending.Models.Components;
using Codat.Lending.Models.Requests;
var sdk = new CodatLending(
retryConfig: new RetryConfig(
strategy: RetryConfig.RetryStrategy.BACKOFF,
backoff: new BackoffStrategy(
initialIntervalMs: 1L,
maxIntervalMs: 50L,
maxElapsedTimeMs: 100L,
exponent: 1.1
),
retryConnectionErrors: false
),
authHeader: "Basic BASE_64_ENCODED(API_KEY)"
);
ListCompaniesRequest req = new ListCompaniesRequest() {
Query = "id=e3334455-1aed-4e71-ab43-6bccf12092ee",
OrderBy = "-modifiedDate",
Tags = "region=uk && team=invoice-finance",
};
var res = await sdk.Companies.ListAsync(req);
// handle responseCodatLendingException is the base exception class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
|---|---|---|
Message |
string | Error message |
StatusCode |
int | HTTP status code |
Headers |
HttpResponseHeaders | HTTP headers |
ContentType |
string? | HTTP content type |
RawResponse |
HttpResponseMessage | HTTP response object |
Body |
string | HTTP response body |
Some exceptions in this SDK include an additional Payload field, which will contain deserialized custom error data when present. Possible exceptions are listed in the Error Classes section.
using Codat.Lending;
using Codat.Lending.Models.Components;
using Codat.Lending.Models.Errors;
using Codat.Lending.Models.Requests;
var sdk = new CodatLending(authHeader: "Basic BASE_64_ENCODED(API_KEY)");
try
{
ListCompaniesRequest req = new ListCompaniesRequest() {
Query = "id=e3334455-1aed-4e71-ab43-6bccf12092ee",
OrderBy = "-modifiedDate",
Tags = "region=uk && team=invoice-finance",
};
var res = await sdk.Companies.ListAsync(req);
// handle response
}
catch (CodatLendingException ex) // all SDK exceptions inherit from CodatLendingException
{
// ex.ToString() provides a detailed error message
System.Console.WriteLine(ex);
// Base exception fields
HttpResponseMessage rawResponse = ex.RawResponse;
HttpResponseHeaders headers = ex.Headers;
int statusCode = ex.StatusCode;
string? contentType = ex.ContentType;
var responseBody = ex.Body;
if (ex is ErrorMessage) // different exceptions may be thrown depending on the method
{
// Check error data fields
ErrorMessagePayload payload = ex.Payload;
long StatusCode = payload.StatusCode;
string Service = payload.Service;
// ...
}
// An underlying cause may be provided
if (ex.InnerException != null)
{
Exception cause = ex.InnerException;
}
}
catch (System.Net.Http.HttpRequestException ex)
{
// Check ex.InnerException for Network connectivity errors
}Primary exceptions:
CodatLendingException: The base class for HTTP error responses.ErrorMessage: Yourqueryparameter was not correctly formed.
Less common exceptions (2)
-
System.Net.Http.HttpRequestException: Network connectivity error. For more details about the underlying cause, inspect theex.InnerException. -
Inheriting from
CodatLendingException:ResponseValidationError: Thrown when the response data could not be deserialized into the expected type.
The C# SDK makes API calls using an ISpeakeasyHttpClient that wraps the native
HttpClient. This
client provides the ability to attach hooks around the request lifecycle that can be used to modify the request or handle
errors and response.
The ISpeakeasyHttpClient interface allows you to either use the default SpeakeasyHttpClient that comes with the SDK,
or provide your own custom implementation with customized configuration such as custom message handlers, timeouts,
connection pooling, and other HTTP client settings.
The following example shows how to create a custom HTTP client with request modification and error handling:
using Codat.Lending;
using Codat.Lending.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
// Create a custom HTTP client
public class CustomHttpClient : ISpeakeasyHttpClient
{
private readonly ISpeakeasyHttpClient _defaultClient;
public CustomHttpClient()
{
_defaultClient = new SpeakeasyHttpClient();
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
// Add custom header and timeout
request.Headers.Add("x-custom-header", "custom value");
request.Headers.Add("x-request-timeout", "30");
try
{
var response = await _defaultClient.SendAsync(request, cancellationToken);
// Log successful response
Console.WriteLine($"Request successful: {response.StatusCode}");
return response;
}
catch (Exception error)
{
// Log error
Console.WriteLine($"Request failed: {error.Message}");
throw;
}
}
public void Dispose()
{
_httpClient?.Dispose();
_defaultClient?.Dispose();
}
}
// Use the custom HTTP client with the SDK
var customHttpClient = new CustomHttpClient();
var sdk = new CodatLending(client: customHttpClient);You can also provide a completely custom HTTP client with your own configuration:
using Codat.Lending.Utils;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
// Custom HTTP client with custom configuration
public class AdvancedHttpClient : ISpeakeasyHttpClient
{
private readonly HttpClient _httpClient;
public AdvancedHttpClient()
{
var handler = new HttpClientHandler()
{
MaxConnectionsPerServer = 10,
// ServerCertificateCustomValidationCallback = customCertValidation, // Custom SSL validation if needed
};
_httpClient = new HttpClient(handler)
{
Timeout = TimeSpan.FromSeconds(30)
};
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
return await _httpClient.SendAsync(request, cancellationToken ?? CancellationToken.None);
}
public void Dispose()
{
_httpClient?.Dispose();
}
}
var sdk = CodatLending.Builder()
.WithClient(new AdvancedHttpClient())
.Build();For simple debugging, you can enable request/response logging by implementing a custom client:
public class LoggingHttpClient : ISpeakeasyHttpClient
{
private readonly ISpeakeasyHttpClient _innerClient;
public LoggingHttpClient(ISpeakeasyHttpClient innerClient = null)
{
_innerClient = innerClient ?? new SpeakeasyHttpClient();
}
public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken? cancellationToken = null)
{
// Log request
Console.WriteLine($"Sending {request.Method} request to {request.RequestUri}");
var response = await _innerClient.SendAsync(request, cancellationToken);
// Log response
Console.WriteLine($"Received {response.StatusCode} response");
return response;
}
public void Dispose() => _innerClient?.Dispose();
}
var sdk = new CodatLending(client: new LoggingHttpClient());The SDK also provides built-in hook support through the SDKConfiguration.Hooks system, which automatically handles
BeforeRequestAsync, AfterSuccessAsync, and AfterErrorAsync hooks for advanced request lifecycle management.
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.