Skip to content

Synchronizations

A synchronization is a batch of tasks posted in one PostAsyncTasks call. Each task names what to synchronize (target) and whose access Ubikap uses to read it from your API (source). Ubikap reads the data itself: you never send it.

Every externalId is an id in your software, never a Ubikap key.

FieldWhat it identifies
source.credential.externalIdA user of your software. Ubikap reads your API with the access this user granted when they connected Ubikap, or else with the office’s own access.
target.workspace.externalIdA dossier. In Ubikap, it becomes a workspace.
target.person.externalIdA person already attached to a Ubikap workspace. Numeric.
target.company.externalIdA company already attached to a Ubikap workspace. Numeric.

The ids are not checked when you post: an unknown id is accepted, and the task fails later.

tasks holds one entry or more, each with exactly one task type. A batch with a task type that is not implemented is refused as a whole, with INVALID_ARGUMENT This task '<type>' is not implemented: nothing is queued.

Task typetargetWhat Ubikap does
synchronizeOfficeUsers{}Creates, updates and deactivates the office’s users from your software’s users. Runs at most once a day per office: a second request the same day ends done without effect.
upsertWorkspaceworkspaceCreates the workspace and its company from the dossier, or updates them. createWorkspace and updateWorkspace do the same.
synchronizeWorkspaceAccessesworkspaceApplies the dossier’s confidentiality, manager and collaborators to the workspace’s accesses.
synchronizeStockholdersworkspaceUpdates the stockholders and stock types.
synchronizeGovernanceworkspaceUpdates the workspace’s governance.
updateOtherPersonworkspace, personUpdates a person attached to the workspace.
updateOtherCompanyworkspace, companyUpdates a company attached to the workspace.
synchronizeFullWorkspaceworkspaceShortcut: expands into upsertWorkspace, synchronizeWorkspaceAccesses, synchronizeStockholders and synchronizeGovernance, plus updateOtherPerson / updateOtherCompany for every person and company already attached to the workspace.

Every task type takes source: { credential: { externalId } }.

The proto also declares createOfficeUser, updateOfficeUser, createMeeting, updateMeeting, createOtherPerson, createOtherCompany, createDocument and updateDocument: they are not implemented yet, and are refused.

  • PostAsyncTasks only queues the tasks and answers with a synchronizationId (a 64-character hexadecimal string). Each call creates a new synchronization, even with the same tasks.
  • The tasks of a synchronization run one after another, in a fixed order whatever the order you posted them in: office users, workspace, accesses, stockholders, governance, persons, companies.
  • A failed task does not stop the next ones.
  • When a task failed, Ubikap retries the synchronization automatically a few times. Only the tasks that are not done run again.
  • Nothing calls you back when a synchronization ends: poll its state.
StateMeaning
pendingQueued, not started.
runningRunning now.
doneSucceeded.
failedFailed, possibly after retries.

GetSynchroState with a synchronizationId returns:

  • tasks: every task of the synchronization, with its type, state, createdAt and updatedAt, most recently updated first. A synchronizeFullWorkspace appears as the tasks it expanded into.
  • stats: pendingCount, runningCount, doneCount and failedCount.

The synchronization has ended when pendingCount and runningCount are both 0. An unknown synchronizationId returns no task and zero counts, not an error.

GetGlobalSynchroState: the office, or one workspace

Section titled “GetGlobalSynchroState: the office, or one workspace”

GetGlobalSynchroState sums up the synchronizations of the token’s office. With filter.workspace.externalId, it only considers the tasks of that workspace (office-level tasks such as synchronizeOfficeUsers are then left out).

FieldContent
running.synchronizationIdsSynchronizations with a task running.
pending.synchronizationIdsSynchronizations with a task waiting, and none running.
failed.synchronizationIdsSynchronizations holding the latest attempt of a task type, for a workspace, that failed — not every synchronization with a failed task: see below.
lastSuccessfulThe most recent synchronization whose tasks are all done: its synchronizationId and its date, when it was posted. Absent when there is none.

Use it to show a “last synchronized” date, or to find what still needs a new attempt.