Query and manage data sync status for a company's connections.
Codat caches data pulled from integrations. This module lets you check the freshness of each data type and trigger on-demand refreshes.
Sync Statuses
| Status | Meaning |
|---|---|
Complete | Last sync succeeded. Data is available. |
FetchError | Sync failed. Check the error message. |
NotSupported | This data type is not supported for the integration. |
ProcessingQueued | A sync has been queued but not yet started. |
Processing | Sync is currently running. |
ValidationError | Data failed Codat's validation step. |
AuthError | Connection was deauthorized mid-sync. |
Example
{:ok, statuses} = Codat.Platform.DataStatus.get(client, "company-id")
invoices_status = statuses["invoices"]
invoices_status["currentStatus"] # => "Complete"
invoices_status["lastSuccessfulSync"] # => "2024-01-15T10:30:00Z"
Summary
Functions
Returns the sync status for all data types for a given company.
Returns the sync status for a single data type.
Returns a single pull operation by its dataset ID.
Returns the history of pull operations (data syncs) for a company.
Queues an on-demand sync for a specific data type on a company.
Queues an on-demand sync for all data types on a company.
Functions
@spec get(Codat.Client.t() | String.t(), String.t() | keyword()) :: {:ok, map()} | {:error, Codat.Error.t()}
Returns the sync status for all data types for a given company.
Returns a map keyed by data type name (e.g. "invoices", "bills").
Example
{:ok, statuses} = Codat.Platform.DataStatus.get(client, "company-id")
# => %{"invoices" => %{"currentStatus" => "Complete", ...}, ...}
@spec get_for_type(Codat.Client.t() | String.t(), String.t(), String.t() | keyword()) :: {:ok, map()} | {:error, Codat.Error.t()}
Returns the sync status for a single data type.
Example
{:ok, status} = Codat.Platform.DataStatus.get_for_type(client, "company-id", "invoices")
status["currentStatus"] # => "Complete"
status["lastSuccessfulSync"] # => "2024-01-15T10:30:00Z"
@spec get_pull_operation( Codat.Client.t() | String.t(), String.t(), String.t() | keyword() ) :: {:ok, map()} | {:error, Codat.Error.t()}
Returns a single pull operation by its dataset ID.
Example
{:ok, op} = Codat.Platform.DataStatus.get_pull_operation(client, "company-id", "dataset-id")
op["status"] # => "Complete"
@spec pull_operations( Codat.Client.t() | String.t(), String.t() | keyword(), keyword() ) :: {:ok, map()} | {:error, Codat.Error.t()}
Returns the history of pull operations (data syncs) for a company.
Options
:page,:page_size— pagination:query— filter operations
Example
{:ok, ops} = Codat.Platform.DataStatus.pull_operations(client, "company-id")
@spec refresh(Codat.Client.t() | String.t(), String.t(), String.t() | keyword()) :: {:ok, map()} | {:error, Codat.Error.t()}
Queues an on-demand sync for a specific data type on a company.
Example
{:ok, _} = Codat.Platform.DataStatus.refresh(client, "company-id", "invoices")
@spec refresh_all(Codat.Client.t() | String.t(), String.t() | keyword()) :: {:ok, map()} | {:error, Codat.Error.t()}
Queues an on-demand sync for all data types on a company.
Returns immediately. Subscribe to the data.sync.complete webhook
to be notified when each data type finishes syncing.
Example
{:ok, _} = Codat.Platform.DataStatus.refresh_all(client, "company-id")