This is a staging build of the docs
We've reorganized our products to make building with Codat easier than ever
Skip to main content

Syncing expenses

Syncing expense-transaction datasets to your customer's accounting software

Once you have pushed data to Codat and created datasets you can then initiate the sync process.

The sync process includes fetching the transactional datasets from the data cache, validating and mapping the data, and then pushing it to the accounting platform.

Datasets

Syncs are independent of creating datasets, so you can continue to create new datasets while a sync is ongoing.

Sync datasets
 POST https://api.codat.io/companies/{companyId}/sync/expenses/syncs
{
"datasetIds": ["fd4cc60e-8666-4443-8fad-12c56d7420ee"]
}

Webhook events

Sync for Expenses provides two webhooks that you can subscribe to.

Sync Failed

The Sync Failed webhook is triggered if any failures occurred during the sync process.

Sync Failed webhook
{
"CompanyId": "1f9559e7-8368-48c9-bdf4-f158e16b8b85",
"ClientId": "30e0f9d2-52c0-4c9f-a806-bcd98a3bcd7e",
"ClientName": "Expense Sync",
"RuleId": "289c80dc-2aee-4b71-afff-9acd8d051080",
"RuleType": "Sync Failed",
"AlertId": "72c1103b-7f17-4a3a-8db5-67c2d360a516",
"Message": "Sync 3bead2a1-1b3d-4d90-8077-cddc5ca68b01 for company 1f9559e7-8368-48c9-bdf4-f158e16b8b85 of type Expense has failed at step Pushing.",
"Data": {
"syncId": "3bead2a1-1b3d-4d90-8077-cddc5ca68b01",
"syncType": "Expense",
"SyncDateRangeStartUtc": "2023-05-03T12:57:58.7576091Z",
"SyncDateRangeFinishUtc": "2023-05-03T12:57:59.7576091Z",
"FailureStage": "Pushing"
}
}

Sync Completed

The Sync Completed webhook is triggered when a sync completes without any failures.

Sync Completed webhook
{
"AlertId": "33a4f8e9-09ae-4334-9b00-7bbe83024672",
"ClientId": "30e0f9d2-52c0-4c9f-a806-bcd98a3bcd7e",
"ClientName": "Expense Sync",
"CompanyId": "1f9559e7-8368-48c9-bdf4-f158e16b8b85",
"Data": {
"syncId": "321363b4-efa9-4fbc-b71c-0b58d62f3248",
"syncType": "Expense",
"SyncDateRangeStartUtc": "2023-05-03T09:56:17.4357111Z",
"SyncDateRangeFinishUtc": "2023-05-03T09:56:18.4357111Z"
},
"Message": "Sync 321363b4-efa9-4fbc-b71c-0b58d62f3248 for company 1f9559e7-8368-48c9-bdf4-f158e16b8b85 of type Expense completed successfully.",
"RuleId": "5c27631d-3b63-4b50-8228-ee502fd113eb",
"RuleType": "Sync Completed"
}

Sync status

Once you have pushed data to Codat, you can use the sync status endpoints to check whether the sync was completed successfully and see the details of any errors that may have occurred.

GET https://api.codat.io/companies/{companyId}/sync/expenses/syncs/syncId/status

Transactions status

In addition to sync status endpoints, Codat provides a transactions endpoint where you can see the status of individual transactions.

This enables you to see if the transaction has synced successfully, or details or the errors associated to the transaction if it was unsuccessful.

GET https://api.codat.io/companies/{companyId}/sync/expenses/syncs/{syncId}/transactions

Was this page useful?
❤️
👍
🤔
👎
😭