Creating and updating data
Understand how to push data to Codat's integrated platforms
In addition to pulling data from integrations, you can push data to create and update records in the underlying integrations using Codat's data model.
View the full details of Codat's support for pushing data for each accounting platform in the Data Coverage Explorer.
Types of push
Codat supports two types of push to a company's data source:
POST- Create a record in a company's accounting software
PUT- Update an existing record
Create and update operations behave similarly, with both having an options endpoint and returning a pushOperation to allow you to monitor the state of the push.
There are some additional considerations when updating to help ensure the company's data integrity.
Step 1: Options
Before pushing data into accounting software, it is often necessary to collect some details from the user as to how they would like the data to be inserted. This includes names and amounts on transactional entities, but also factors such as categorization of entities, which is often handled differently between different accounting packages. A good example of this is specifying where on the balance sheet/profit and loss reports the user would like a newly-created nominal account to appear.
/options endpoint exposes which fields are required to be pushed for a specific linked company, and the options which may be selected for each field.
You can retrieve the options for a given data type by calling:
See the API reference.
"displayName": "Nominal Account",
"description": "Account represented in the chart of accounts or general ledger.",
"displayName": "Nominal Code",
"description": "Identifier for the nominal account.",
"details": "Must have a length between 1 and 7 characters."
"description": "Name of account as it appears in the chart of accounts or general ledger.",
"displayName": "Fully Qualified Category",
"description": "Account type and category for nominal account.",
"displayName": "Cash On Hand"
This example describes the nominal account object as requiring three properties to be populated:
nominalCodeproperty is a string, which has a validation warning that it must be between 1 and 7 characters long.
nameproperty is an unrestricted string.
fullyQualifiedCategoryproperty is an enum property, namely it accepts a string chosen from a list of options (in this case, "Asset.CashOnHand" and "Asset.Checking"). The
displayNameon the options can be used to display the user a more descriptive name, such as "Cash On Hand" and "Checking".
Displaying options to your user
The structure of the options endpoint is designed such that it can be easily parsed into a set of controls which can be displayed to the end user such that they can select how data is pushed into their accounting software.
For example, when rendering the "fullyQualifiedCategory" from the above example as a control on a HTML form, it can be parsed into the following:
<select name="fullyQualifiedCategory" required>
<option value="Asset.CashOnHand">Cash On Hand</option>
Step 2: Pushing a record
If you attempt to push a record using fields that are not documented in the Options response for that company, the additional data may not be pushed to the platform and you may receive validation errors in response to your "push" request.
The push endpoint
The endpoint for pushing a record is as follows:
An example would be posting a new invoice to an accounting package for a given company.
The request body should be a JSON object which conforms to the structure of the options endpoint above. It is expected that the options endpoint is queried before performing any push operation.
For example, a valid request body for the example above would be as follows:
"name": "Codat Bank Account",
The response from the push endpoint is a PushOperation object, which is structured as follows:
Properties on the object are as follows:
- pushOperationKey: A unique identifier generated by Codat to represent this single push operation. This identifier can be used to track the status of the push, and should be persisted
- dataType: The type of data being pushed, eg invoices, customers
- status: The status of the push operation, which can be
- requestedOnUtc: The datetime (in UTC) when the push was requested
- completedOnUtc: The datetime (in UTC) when the push was completed, null if Pending
- data: The object which was pushed. If the push has completed successfully, this represents the object as it appears in the platform (with any platform-generated fields populated)
- validation: A human-readable object describing validation decisions Codat has made when pushing data into the platform. If a push has failed because of validation errors, they will be detailed here.
Synchronous vs asynchronous push
The majority of platforms are implemented to push asynchronously so you will receive a
Pending push operation in response to your push request. You can use the details in this response to monitor the status of your push request.
For some platforms, pushing may be implemented synchronously and you may receive a
Failed push operation in response to your push request (in place of a
Pending push operation). However, we strongly suggest that you assume that all pushes will be processed asynchronously when integrating with Codat.
It is possible for an operation to be in a
Pending status indefinitely, for example if a user's on-premise software is offline. To avoid possible issues this could create for clients, Codat provides a timeout functionality for push operations in the
Pending status. If the
timeoutInMinutes property has been set on a push operation, Codat will guarantee that the operation will not be processed after that deadline. If the deadline expires, the status of the push operation will change to
Step 3: Monitoring status of push
For asynchronous push operations, where the push is initially in a
Pending status, you may wish to have a process that will provide an update on a final
Failed state, or
Unknown state if the outcome of the push is unclear. This outcome can then be communicated to the user, or further actions can be taken.
Codat supports two methods of monitoring the status of push operations: polling and webhooks.
The Codat API provides two endpoints for monitoring push operations: one for viewing the status of all the most recent push operations, and one for viewing the status of a single push operation, identified by the
PushOperationKey returned when you requested the push.
- List all push operations (paged) for a company using
- Get a single push operation by ID using
You can periodically poll the single endpoint while a push is in a
Pending state to identify when it enters a
Unknown state, at which point the outcome can be communicated to the user.
The list endpoint can be used to present to the user a list of recent push requests and their statuses. This can be useful for applications which push data frequently.
A second option for monitoring push operations is to register a subscription to the "Push status changed" rule. This can be configured by following the instructions in our documentation for subscribing to rules.