Sync groups
A sync group keeps the same data on a set of clocks, whatever their vendor. You write a change once, through the API. Connect then brings every clock in the group up to date.
A group can keep these kinds of data:
- the people on the clocks, with their cards and credentials
- access schedules
- lists, such as work codes
- device settings
- recent punches
Every table, field and route is in the sync group reference.
Concepts
Section titled “Concepts”| Term | Meaning |
|---|---|
| Sync group | A named set of endpoints. Their devices keep chosen data the same. Every endpoint is in exactly one group. |
| Member | An allowed device of one of the group’s endpoints. |
| Domain | A kind of data the group keeps: people, access, lists, settings, punches. A domain the group does not name is not touched. |
| Registry | The group’s own copy of the data. Each device holds a copy of it. Every change gets the group’s next version number. If two changes touch the same field, the latest one wins. The time on a device’s clock never decides the order. |
| Authority | For people, lists and settings, who decides what they hold. Either the group decides (group), or the group and its devices decide together (shared). For access, the group always decides. |
| Placement | Which people go to which members. You pick them by label with selectors. Without placement, everyone goes to every member. |
| Routes | Where a person’s punches go. A route names a receiving system, a tenant in it and the person’s id there. See routes. |
Sync is opt-in, for each group and each domain. A group with no domains keeps nothing. Connect then only passes what clocks send out as events, and passes what you ask through the API in as commands.
Three layers narrow what a clock gets, each one narrowing the one before:
- The group’s domains say what is kept.
- Placement says which people go where.
- What a member can hold narrows it last.
Every group holds its people’s per-person flags, whatever its domains. One example is whether biometrics are allowed. See data protection.
Every endpoint is in a group
Section titled “Every endpoint is in a group”An endpoint joins a group with sync_group = "<name>". Several endpoints can share one group.
An endpoint without sync_group gets a group of its own, named after the endpoint, with no domains. If you switch domains on in that group, only that endpoint’s devices sync. For example, hourctl sync set office domains=people.
To put an endpoint back in a group of its own, run hourctl endpoint set office --no-sync-group.
Removing an endpoint does not remove its group. If the endpoint’s own group name is already taken, the group is named <id>-2, <id>-3, and so on. Another group or endpoint can take the name. So can a group that still keeps data.
Members
Section titled “Members”Every allowed device of a group’s endpoints is a member. Blocked, pending and forgotten devices are not members. Nothing is deleted from a device that stops being a member.
A device that leaves is remembered, along with the deletes it has not done yet. It stays remembered until it rejoins and is sent them, or until you forget it (hourctl sync forget hq office A1). A delete is kept while a device may still hold what was deleted.
To keep a device out of a group, put it on an endpoint of its own.
When you move an endpoint to another group, its devices join the new group as fresh members. Connect sends device.moved. It also calls the endpoint’s policy’s moved hook.
This applies if the new group keeps people and the device holds another group’s people. The old people are cleared from the device first, before anything else is sent. They are never taken into the new group. After that, the device gets the new group’s people, as its placement says.
Domains
Section titled “Domains”| Domain | What the group keeps |
|---|---|
people | people, their cards, keypad PINs and passwords, and, with biometrics = true, their templates and photos |
access | schedules, holidays, access groups, and zones for anti-passback |
lists | work, job and tip codes, and messages |
settings | device settings, per settings class |
punches | each person’s latest punches, shared across members |
For people, access, lists and settings, the group keeps desired state. That means the registry says what each member should hold, and Connect sends it.
Punches are facts. Connect does not drop or rewrite a punch. It marks each one with what the group knows. See punches.
Authority
Section titled “Authority”People, lists and settings each have one source of authority. You set it for each domain, for example people.authority = "shared".
authority | A change or delete made at a device | Use it when |
|---|---|---|
group (default) | is put back. The device is sent the group’s value again. Nothing a device does reaches the registry. | your systems write through the API and are the master |
shared | is taken into the registry and sent to every other member, as an API write would be | people are enrolled and edited at the clocks |
Settings follow the same rule. Where lists are shared, a list item that a device adds is taken in. Otherwise it is left on the device.
Access (schedules, holidays, access groups) is always the group’s. It has no setting, and a group that names access is refused.
The group does not see a change made at a device. The change stays on the device until the group’s row is sent to that member again. That happens in two cases:
- The row changes in the group.
- You resync the member for access. Run
hourctl sync resync hq office A1 --domain access, or use the resync call with{"domain": "access"}. Either one sends every access row again.
People enrolled at a clock
Section titled “People enrolled at a clock”Sometimes a clock reports a user that the group does not have and that Connect did not put there. That user was enrolled at the clock.
Whatever the authority, they become a person of the group at once. They get Connect’s own id for them. The group also keeps what the clock reported, never their PIN or password, and enrolled: "<endpoint>/<device>".
- Not linked yet. Until they are linked, they stay on the clock that enrolled them, whatever the group’s placement says. They count toward the tenant’s limit on people.
- Their punches go out at once. They are routed as anyone’s. A group’s default route can send them to Time and Attendance. Time and Attendance keeps them as an unlinked person.
- Setting an id links them. Set an external id, or a route of their own that names their id there. You can write it through the API. The endpoint’s policy’s
enrolledhook can write it too. Once they are linked, Connect sends them to every clock their placement picks. One exception applies. A clock that holds a password or PIN of theirs that the group does not have keeps it, and is not sent the person without it. person.enrolledmarks the moment. Another system can then link, label or delete them through the API.
A user the group deleted is deleted again from a clock that reports them. A template of a person who withdrew consent is never taken in, and is deleted from the device.
Placement
Section titled “Placement”Placement says which people go to which members. It uses labels on the members and on the people. Selectors pick them.
Placement only narrows. With no rules and no device list of a person’s own, everyone goes to every member.
| Part | Where it is set |
|---|---|
| Member labels | Its endpoint’s labels, with the device’s own put over them. Endpoint: labels = { building = "a", area = "warehouse" }. Device: hourctl device label office A1 area=warehouse, or PATCH /api/tenants/{tenant}/devices/{endpoint}/{device} with {"labels": {...}} (null removes one). |
| Person labels | The person’s labels field ({"role": "office"}). Your HR or T&A system usually writes it. |
| Rules | The group’s placement list. Each rule pairs a people selector with a devices selector. A person goes on a member when any rule’s people selector picks the person and its devices selector picks the member. A rule without people picks every person. A rule without devices picks every member. |
| A person’s own list | The person’s devices field (["office/A1", "yard/W2"]) places them on exactly those members, whatever the rules. An empty list places them nowhere. |
[[sync_group.placement]] # office staff on every clockpeople = "role = office"
[[sync_group.placement]] # warehouse staff on warehouse clockspeople = "role = warehouse"devices = "area = warehouse"
[[sync_group.placement]] # leads and managers on Nevada's clocks, not the kioskspeople = "role in (lead, manager)"devices = "region ^= west/nevada and kind != kiosk"The same rules with hourctl:
hourctl sync placement add hq --people "role = office"hourctl sync placement add hq --people "role = warehouse" --devices "area = warehouse"hourctl sync placement add hq --people "role in (lead, manager)" --devices "region ^= west/nevada and kind != kiosk"hourctl sync placement hq # show them, numberedhourctl sync placement remove hq 2Connect has no hierarchies of organizations, so a selector that uses under is refused. A selector with a mistake is refused too, when the settings are loaded or changed. The refusal names the column.
- Moving people. Suppose you relabel a device or a person, or change the rules. People who are no longer placed on a member are taken off it. People who are newly placed are sent. A person moved off a clock is taken off it whether or not the clock reports its users. The same goes for anyone a changed clock no longer takes, such as after a firmware upgrade or a new placement. A clock loses only what the group put there.
- Punches are not refused. A punch at a member where the person is not placed is kept and delivered like any other. It is marked
placement: "outside". - Where each person is.
hourctl sync person show hq 1001lists every member with its state for that person.
Compatibility
Section titled “Compatibility”One group can hold clocks of any vendor and protocol version. Each row goes to exactly the members that say they can take it. Nothing is converted or approximated.
- People, cards and keypad PINs go to every member that takes people. A name too long for a clock is cut to fit, and what was cut is listed.
- Templates go only between members that read the same template format. A clock is sent each fingerprint template once. Several vendors share one face credential: a face photo (
face_photo, a JPEG the clock turns into its own template). - Settings go only between members of the same settings class. The standard class
*(volume,languageand a few more) goes to every member that has the setting. - If a member cannot take a row, the row is
unsupportedthere, with the reason. It never fails the write or another member.
What a device takes comes from its package and from what the device reports about itself. Suppose a firmware upgrade adds a face reader. That is noticed, and the rows that apply to it are sent.
Every registry write answers with the outcome for each member. See outcomes.
Direct writes are refused
Section titled “Direct writes are refused”While a group keeps a domain, the group is the only writer of that domain on its members.
Suppose you send an action through POST /api/tenants/{tenant}/devices/{endpoint}/{device}/actions, and it writes a domain its group keeps. It is refused with 409. The refusal names the group and the sync API path to use instead.
A job whose action writes such a domain is refused when you create it. Package commands follow the same rule, based on what they declare they write.
Reads and enrolment stay allowed: query_users, enroll_biometric, get_info, query_punches. The full list is in the reference.
To manage a device by hand, move it to an endpoint outside the group. Or take the domain out of the group.
Turning a domain off
Section titled “Turning a domain off”Take a domain out of a group, or an endpoint out of a group, and sync stops for it at once. Commands not yet handed to a device are cancelled. Nothing is deleted from any device. The registry stays, so turning the domain back on resumes where it was.
The group’s data is deleted only with the group:
hourctl sync delete hq --delete-dataDELETE /api/tenants/{tenant}/sync/{name}?confirm_delete_data=true
Conflicts and device edits
Section titled “Conflicts and device edits”-
The latest change wins, per field. Connect goes by the order in which it took the changes. If two clocks edit a person’s name, the later edit is the name everywhere.
-
Optimistic writes. A write can pass
if_version, the version it read. If the row changed since, the write is refused with 409 and nothing is written. -
Echoes are not edits. A clock may report back a value it was sent, or an older one it has not caught up from. That changes nothing. Only a value it was never sent counts as an edit at the device.
-
A field a device cannot report never comes from it. Absent means unknown. It never means cleared.
-
Deletes win over uploads. Suppose a clock uploads a deleted row again. The row is deleted from the clock again. The delete is kept until every member has confirmed it, including members that left and are remembered. It is kept for at least the gateway’s
retention_days(default 30). -
History is not news. A clock that uploads its whole log reports deletes made before it joined. Those are never acted on.
-
Mass deletes are not followed. A clock that reports clearing its data, or that deletes many users in a short time, is paused. While a clock is paused, nothing it reports is taken in and nothing is sent to it. A
sync.pausedevent is sent. You choose what happens next:Terminal window hourctl sync resume hq office A1 # take what it reports againhourctl sync resync hq office A1 [--domain people] # send it everything -
A secret only the device has. A clock holds a password or PIN for a user that the group does not have. That person is not sent to the clock, so the clock does not lose the secret. The person shows
unsupportedon that member. That lasts until you give the group the secret, or clear it (null).
Changing a user id
Section titled “Changing a user id”To move a person and their credentials to a new id:
-
Start the change:
Terminal window hourctl sync change-id hq 1001 2001The registry moves the person at once. The old id stays an alias for
retention_days. Punches still to come under the old id arrive markeduser_id_alias_of. The change is refused (422) when there is no person1001, or when2001is taken. -
Follow it on each member:
Terminal window hourctl sync person show hq 2001id_changesshows the step each member is at, and any error. -
If a step failed, carry on from where it stopped:
Terminal window hourctl sync retry-change-id hq 1001
A clock that can rename a user gets one rename_user. A clock that cannot rename gets the person under the new id first. It is checked, and only then does the clock lose the old user. See the steps.
A step that fails leaves the old user as it was. When every member is done, person.replaced says how each did it.
Some clocks cannot rename and may hold templates the group does not have, because people enrolled them at the clock. The change would lose those templates. So the change is refused there unless you pass --allow-reenroll. If the group holds the person’s templates in a format the clock reads, they go under the new id and nothing is refused.
Punches
Section titled “Punches”With punches on, every punch from a member is marked with what the group knows about the person. The marks say:
- their previous punch at any member
- whether this punch is a duplicate
- whether it is within the lock-out (
lockout_minutes) - whether it is late
- whether it is in breach of a zone
The same punch uploaded twice counts once. Times compare as instants, so members in different time zones need nothing special. hourctl sync punches hq 1001 shows a person’s latest punches.
Depending on its package, a clock can also ask before it accepts a punch. This is pull: it asks for the person’s last punch, or whether they may pass a zone’s reader. Or the clock can be sent each person’s latest punch. This is push. The fields and modes are in the reference.
Data protection
Section titled “Data protection”Only what is sensitive is encrypted, with the key that seals device keys and sink secrets (HOURADVANTAGE_SECRET_KEY, see operations). “Sealed” below means encrypted with that key.
| Data | At rest | Without HOURADVANTAGE_SECRET_KEY |
|---|---|---|
| Biometric templates, face photos, display photos | sealed | refused: biometrics = true is not accepted, and a credential write answers 422 |
| Keypad PINs, passwords, settings a package marks sensitive | sealed | kept plain, as every secret is without a key (sealed once one is set) |
| Ids, names, roles, validity, cards, access groups, schedules, lists, settings, punches | plain | plain |
- Templates, PINs and passwords are write-only through the API. They never appear in events, the change feed, the audit trail or the log.
- Who may have biometrics is a per-person flag. Every group has it, whatever its domains. The flag, what withdrawing consent does, and how templates move between members are in biometric data.
- Deleting a person deletes their credentials, punch state and aliases. They are deleted from every member too. Some devices leave template bytes in storage after a delete. The package says so.
- If you lose the secret key, sealed rows cannot be opened, and they fail with “cannot unseal”. Everything else keeps syncing.
Coexisting with an external system
Section titled “Coexisting with an external system”| Situation | Configuration | Connect’s role |
|---|---|---|
| Your T&A system already keeps every clock in sync | no domains (the endpoint’s own group) | passes traffic through |
| It manages people but wants lock-out across clocks | domains = ["punches"] | shares punches |
| It wants Connect to fan out its changes, and stays the master | people with authority group; it writes through /api/tenants/{tenant}/sync/{name}/people | applies its writes to every clock |
| Clocks are where people are enrolled | people with authority = "shared"; your system (or the endpoint’s policy) sets an id that links each person enrolled at a clock | keeps the registry; your system follows person.* events and the change feed |
| Some clocks are managed by hand | those on an endpoint without sync_group | passes traffic through |
External ids
Section titled “External ids”Each system you connect may know a person by a different id. A person carries the other systems’ ids in external_ids. For example, hourctl sync person set hq 1001 --external-id payroll=104552.
A sink can name the system it speaks for (system = "payroll"). That sink gets the system’s id for the person in its events. A system can find a person by its own id with GET /api/tenants/{tenant}/sync/{name}/people?external_id=payroll:104552. See external ids.
The change feed
Section titled “The change feed”A system that follows the registry reads the change feed. It starts from the last version it saw:
hourctl sync changes hq --after 1200GET /api/tenants/{tenant}/sync/{name}/changes?after=<version>&limit=<n> returns every row changed since then. It includes deletes. It lists them in version order, without secrets. It also returns next, the version to ask after next time.
A delete stays in the feed for at least retention_days, and until every member has done it. A reader that falls further behind may miss deletes. It should read the whole registry again.
Setting one up
Section titled “Setting one up”Sync groups are settings, like listeners, endpoints and sinks. You change them through the admin API, through hourctl, or with a settings document for hourctl apply.
-
Create the group, naming its domains and sinks:
Terminal window hourctl sync create hq --domain people,punches --sink payroll -
Change any domain setting:
Terminal window hourctl sync set hq people.authority=shared punches.lockout_minutes=5 -
Put endpoints in it, with labels if you use placement:
Terminal window hourctl endpoint set office --sync-group hq --label building=a --label area=office -
Check its members:
Terminal window hourctl sync status hq
The same as a settings document:
[[sync_group]]id = "hq"domains = ["people", "punches"] # domains not listed are not touchedsinks = ["payroll"] # where person.*, sync.* ... events goroutes = [{ system = "attendance", tenant = "acme" }] # optional: default routes
[sync_group.people] # every table is optional; defaults shownauthority = "group" # or "shared"biometrics = false # needs HOURADVANTAGE_SECRET_KEY
[sync_group.punches]lockout_minutes = 0
[[sync_group.placement]] # optional: see Placementpeople = "role = warehouse"devices = "area = warehouse"
[[endpoint]]id = "office"sync_group = "hq"labels = { building = "a", area = "office" }
[[device_labels]] # a device's own labelsendpoint = "office"device = "A1"labels = { area = "warehouse" }Running it
Section titled “Running it”-
Any instance serves any clock. Whichever instance a clock reaches takes its reports and answers it. Two instances do not send sync changes to the same clock at once. If one stops, another carries on. An instance that stops gives up the groups it was working on at once. So another instance, or the one started in its place, takes them over without waiting.
-
Urgent changes first. Deletes, disabling a person and consent withdrawal go ahead of other sync work. Sync work goes behind commands you send yourself. A paused member is sent nothing.
-
An offline clock piles nothing up. When it comes back, it is sent the current rows. Changes overtaken by newer ones are not sent.
-
Lost commands are sent again. How long a clock takes decides nothing. A command is lost in three cases:
- The clock answers one handed out after it, and its package says that makes it missed (
M.missed). - Its package says the clock restarted.
- You give up on it.
A lost write is then handed out once more. If it is lost again, it is unanswered and its row fails. Every sync command is safe to apply twice.
A row that fails stays failed, with its
errorandattempts. It stays that way until its row changes in the group, or until you runhourctl sync retry hq office A1 [--domain people]. That is the retry call. It sends the member’s failed rows again and leaves its other rows as they are. No amount of time sends it again.A clock that has gone away for good holds what it was handed, counted. That lasts until you cancel the action with
--give-up(see actions). - The clock answers one handed out after it, and its package says that makes it missed (
-
Inventory. An inventory is a request to a clock to upload its users, so what it uploads can be compared with what it should hold.
- A clock that can upload its users is asked when it joins, on
resync, once a day, and when its user count is below what it should hold. - That user count is asked for at the head of the log (
people.report.counts_action: once for each position of the log, after everything sent). A package that declares no such action is asked once a day only. - The upload is compared with what the clock should hold only once the package says the upload is complete. That means its
people.report.inventory_completeiscount, and the number of users uploaded equals the user count the clock reports after the upload. The inventory action ends by asking for it. It is never compared just because a quiet time has passed. - While fewer users have come than the clock holds, the inventory waits. If more have come than it holds, or the package cannot say, the inventory is closed without a comparison, and counted (
houradvantage_sync_inventory_uncompared_total{why}). The member’s next inventory closes one that is still waiting. - The inventory does not judge people whose rows changed after it was asked.
- A person the clock lacks is sent again. A user it holds that the group lacks is enrolled.
- A member that is still being filled (rows not yet sent, or on their way) is not asked until it is at the head of the log.
- A clock that cannot upload is sent everything again when its user count drops.
- A clock that can upload its users is asked when it joins, on
-
A clock that was reset, or replaced under the same serial number, is noticed this way and refilled. A new serial number is a new member.
-
A database restored from a backup may be behind the clocks. Sending again is harmless. Users written after the backup turn up as people enrolled at the clocks, to link again.