Embedded accounting integrations for POS and eCommerce platforms.
Sync for Commerce: The API for Sync for Commerce.
Sync for Commerce automatically replicates and reconciles sales data from a merchant’s source PoS, Payments, and eCommerce systems into their accounting software. This eliminates manual processing by merchants and transforms their ability to run and grow their business.
Explore product | See our OpenAPI spec
Not seeing the endpoints you're expecting? We've reorganized our products, and you may be using a different version of Sync for Commerce.
| Endpoints | Description |
|---|---|
| Connections | Create new and manage existing data connections for a company. |
| Sync | Initiate data syncs and monitor their status. |
| Sync flow settings | Control text and visibility settings for the Sync Flow. |
| Integrations | Get a list of integrations supported by Sync for Commerce and their logos. |
| Advanced controls | View and manage mapping configured for a company's commerce sync. |
- SDK Installation
- SDK Example Usage
- Available Resources and Operations
- Retries
- Error Handling
- Server Selection
- Authentication
To add the NuGet package to a .NET project:
dotnet add package Codat.Sync.CommerceTo add a reference to a local instance of the SDK in a .NET project:
dotnet add reference Codat/Sync/Commerce/Codat.Sync.Commerce.csprojusing Codat.Sync.Commerce;
using Codat.Sync.Commerce.Models.Requests;
using Codat.Sync.Commerce.Models.Components;
var sdk = new CodatSyncCommerce(authHeader: "Basic BASE_64_ENCODED(API_KEY)");
GetSyncFlowUrlRequest req = new GetSyncFlowUrlRequest() {
CommerceKey = "<value>",
AccountingKey = "<value>",
};
var res = await sdk.Connections.GetSyncFlowUrlAsync(req);
// handle responseAvailable methods
- ListCompanies - List companies
- CreateCompany - Create company
- GetConfiguration - Get company configuration
- SetConfiguration - Set configuration
- GetSyncFlowUrl - Start new sync flow
- List - List connections
- Create - Create connection
- UpdateConnection - Update connection
- UpdateAuthorization - Update authorization
- List - List integrations
- GetBranding - Get branding for an integration
- Request - Initiate new sync
- RequestForDateRange - Initiate sync for specific range
- GetStatus - Get sync status
- GetLastSuccessfulSync - Last successful sync
- GetLatestSync - Latest sync status
- Get - Get sync status
- List - List sync statuses
- GetConfigTextSyncFlow - Get preferences for text fields
- UpdateConfigTextSyncFlow - Update preferences for text fields
- GetVisibleAccounts - List visible accounts
- UpdateVisibleAccountsSyncFlow - Update visible accounts
The default server can also be overridden globally by passing a URL to the serverUrl: string optional parameter when initializing the SDK client instance. For example:
using Codat.Sync.Commerce;
using Codat.Sync.Commerce.Models.Requests;
using Codat.Sync.Commerce.Models.Components;
var sdk = new CodatSyncCommerce(
serverUrl: "https://api.codat.io",
authHeader: "Basic BASE_64_ENCODED(API_KEY)"
);
GetSyncFlowUrlRequest req = new GetSyncFlowUrlRequest() {
CommerceKey = "<value>",
AccountingKey = "<value>",
};
var res = await sdk.Connections.GetSyncFlowUrlAsync(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.Sync.Commerce;
using Codat.Sync.Commerce.Models.Requests;
using Codat.Sync.Commerce.Models.Components;
var sdk = new CodatSyncCommerce(authHeader: "Basic BASE_64_ENCODED(API_KEY)");
GetSyncFlowUrlRequest req = new GetSyncFlowUrlRequest() {
CommerceKey = "<value>",
AccountingKey = "<value>",
};
var res = await sdk.Connections.GetSyncFlowUrlAsync(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.Sync.Commerce;
using Codat.Sync.Commerce.Models.Requests;
using Codat.Sync.Commerce.Models.Components;
var sdk = new CodatSyncCommerce(authHeader: "Basic BASE_64_ENCODED(API_KEY)");
GetSyncFlowUrlRequest req = new GetSyncFlowUrlRequest() {
CommerceKey = "<value>",
AccountingKey = "<value>",
};
var res = await sdk.Connections.GetSyncFlowUrlAsync(
retryConfig: new RetryConfig(
strategy: RetryConfig.RetryStrategy.BACKOFF,
backoff: new BackoffStrategy(
initialIntervalMs: 1L,
maxIntervalMs: 50L,
maxElapsedTimeMs: 100L,
exponent: 1.1
),
retryConnectionErrors: false
),
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.Sync.Commerce;
using Codat.Sync.Commerce.Models.Requests;
using Codat.Sync.Commerce.Models.Components;
var sdk = new CodatSyncCommerce(
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)"
);
GetSyncFlowUrlRequest req = new GetSyncFlowUrlRequest() {
CommerceKey = "<value>",
AccountingKey = "<value>",
};
var res = await sdk.Connections.GetSyncFlowUrlAsync(req);
// handle responseHandling errors in this SDK should largely match your expectations. All operations return a response object or throw an exception.
By default, an API error will raise a Codat.Sync.Commerce.Models.Errors.SDKException exception, which has the following properties:
| Property | Type | Description |
|---|---|---|
Message |
string | The error message |
StatusCode |
int | The HTTP status code |
RawResponse |
HttpResponseMessage | The raw HTTP response |
Body |
string | The response content |
When custom error responses are specified for an operation, the SDK may also throw their associated exceptions. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the GetSyncFlowUrlAsync method throws the following exceptions:
| Error Type | Status Code | Content Type |
|---|---|---|
| Codat.Sync.Commerce.Models.Errors.ErrorMessage | 400, 401, 402, 403, 404, 429, 500, 503 | application/json |
| Codat.Sync.Commerce.Models.Errors.SDKException | 4XX, 5XX | */* |
using Codat.Sync.Commerce;
using Codat.Sync.Commerce.Models.Requests;
using Codat.Sync.Commerce.Models.Components;
using System;
using Codat.Sync.Commerce.Models.Errors;
var sdk = new CodatSyncCommerce(authHeader: "Basic BASE_64_ENCODED(API_KEY)");
try
{
GetSyncFlowUrlRequest req = new GetSyncFlowUrlRequest() {
CommerceKey = "<value>",
AccountingKey = "<value>",
};
var res = await sdk.Connections.GetSyncFlowUrlAsync(req);
// handle response
}
catch (Exception ex)
{
if (ex is ErrorMessage)
{
// Handle exception data
throw;
}
else if (ex is Codat.Sync.Commerce.Models.Errors.SDKException)
{
// Handle default exception
throw;
}
}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.