Skip to content

Sync group reference

This page lists what a sync group is made of. That is its settings, the rows it keeps, the states a member’s rows can be in, and the API, command line and events that work with it. For what a sync group is and how to set one up, see Sync groups.

A group is kept with these settings. Change them with hourctl apply, hourctl sync or the admin API.

FieldValuesDefault
id1 to 64 letters, digits, - or _required
domainsany of people, access, lists, settings, punches, each oncenone (the group keeps nothing)
sinkssinks the group’s own events go to. Each must exist.none
people, access, lists, settings, punchesthe domain settingssee below
placementplacement rules, at most 100none. Everyone is on every member.
routesdefault routes. Each names a system and a tenant, never a person.none
external_idswhat other systems know the group by, such as {"payroll": "site-12"}none
metadataa JSON object kept as given, never read by Connectnone

An endpoint names its group with sync_group, which must exist. A [[device_labels]] entry must name a device that exists. hourctl export writes groups, endpoints’ sync_group and labels, and devices’ own labels.

SettingDomainsValuesDefault
authoritypeople, lists, settingsgroup or shared (authority)group
biometricspeopletrue means the group keeps biometric templates, face photos and display photos. Needs HOURADVANTAGE_SECRET_KEY.false
lockout_minutespunchesA punch less than this many minutes after the person’s previous one is within the lock-out. 0 turns it off. Never below 0.0
LimitValue
Label key1 to 63 letters, digits, -, _, . or /
Label value1 to 255 characters of plain words (letters, digits, -, _, .) joined by / into a path, such as west/nevada/plant-7
Labels per endpoint, device or person64
Placement rules per group100
A person’s metadataa JSON object of at most 16 KiB
DomainRowsWhat members are sent
peoplepeople and their credentials (templates, face photos, display photos)upsert_user (always the whole record), delete_user, rename_user, set_biometric, delete_biometrics, set_user_photo, delete_user_photo
accessschedules, holidays, access groups, zonesset_schedule, set_holiday, set_access_group and their deletes. Zones are never sent.
listswork, job and tip codes, messagesset_list_item, delete_list_item
settingsvalues per settings class (<class>/<name>)one set_settings per member with every outstanding value of its class
punchesthe latest punches per person, and zone stateThe sync mark on member punch events. Answers to devices that ask. set_punch_state to devices that take it.
DomainKindKeyFields
peoplepersonuser idname, role, enabled, valid_from, valid_to, cards ([{"number", "format", "facility"}]), access_groups (access group keys), biometrics (false: refused), labels, devices (["<endpoint>/<device>"], see placement), external_ids, routes, metadata. Secrets: keypad_pin, password. Connect sets enrolled ("<endpoint>/<device>") for a person enrolled at a clock.
peoplecredential<user_id>/<kind>/<slot>/<format>Written with PUT .../credentials/{kind}/{slot}. The kinds are fingerprint, face, face_photo, palm, finger_vein, iris, photo.
accessscheduleanyname, days, holiday (holiday keys). days runs sun to sat. Each day is a list of ["HH:MM", "HH:MM"] intervals. A day left out allows nothing.
accessholidayanyname, from, to, type
accessaccess_groupanyname, schedules (schedule keys), doors (none: all)
accesszoneanysee Zones
listswork_code, job_code, tip_codethe codename
listsmessageanytext, user_ids, from, minutes
settingssetting<class>/<name>value (written with PUT .../settings/{class})
  • external_ids, routes and metadata are never sent to a device.
  • A card belongs to one person of the group at a time. Writing a card another person holds is refused (422), as is a card list naming the same number twice.
  • Numbered rows (schedules, holidays, access groups) take the smallest free number in the group, from 1. Each package declares which of its devices’ slots the group may use. Nothing outside them is written, so a device’s own schedules stay as they are. The ZK packages give the group schedules 26 to 50. The ZK 2.4 package also gives holidays 26 to 50 and access groups 50 to 99.
  • Settings class * holds the standard names only (volume, language, date_format, time_format, screen_timeout_seconds, ntp_server, lock_seconds). It goes to every member whose settings catalog has the name. A class’s own value beats the * value. A package’s class is, by default, its name and major.minor version.
  • A member that holds at most max items of a list takes the group’s first max by key. The rest are unsupported until there is room. A message with user_ids goes only to members holding at least one of those people.

Actions refused while a group keeps a domain

Section titled “Actions refused while a group keeps a domain”

A direct action that writes a domain the device’s group keeps is answered 409 (direct writes are refused).

DomainStandard actions refused
peopleupsert_user, delete_user, set_cards, change_user_id, rename_user, set_biometric, delete_biometrics, set_user_photo, delete_user_photo, clear_users, wipe
accessset_schedule, delete_schedule, set_holiday, delete_holiday, set_access_group, delete_access_group, wipe
listsset_list_item, delete_list_item, set_work_code, delete_work_code, show_message, wipe
settingsset_settings
punchesset_punch_state

A package’s own actions and commands are refused the same way, by what they declare they write. Reads and enrolment stay allowed: query_users, enroll_biometric, get_info, query_punches.

For each row and member, the outcome is one of:

OutcomeMeaning
appliesThe member takes it, possibly cut to what it holds. What it loses is listed as omitted: {"field": "name", "reason": "cut to 24 characters: the device holds 24"}.
unsupportedThe member takes this kind of data but not this row. It covers an id that does not fit, a template format it does not read, a keypad PIN or password too long (never cut), and more rows than its slots. Listed with the reason.
not_applicableThe member does not take this kind of data at all.
not_placedThe group’s placement does not put the person on the member.

Every registry write answers with its version and the outcomes:

{
"version": 42,
"changed": 1,
"members": {
"applies": 3,
"unsupported": [{ "endpoint": "office", "device": "A1", "key": "1001", "reason": "..." }],
"not_applicable": 1,
"not_placed": 0
}
}

hourctl sync rows and GET .../members/{endpoint}/{device}/rows show each of a member’s rows in one of these states. --state filters them.

StateMeaning
pendingTo be sent, or being sent (the row shows the action carrying it).
in_syncThe member holds the row’s current version.
failedSending failed (see error). It stays failed until the registry’s row changes or an app runs retry. No time sends it again.
unsupportedThe member takes this kind of data, but not this row (see reason).
divergedA change the member reported could not be taken into the group (a card another person holds). The member holds it, the group does not.
not_applicableThe member does not take this kind of data.
needs_rebootA setting applied that takes effect when the device restarts. Cleared when the device reports it started. Connect never restarts a device on its own.
not_placedNot placed on the member. Taken off it if it held it.
deletedA delete the member confirmed, while the group still keeps the row’s tombstone.

A member that cannot rename a user is moved to the new id one step at a time. The old user is untouched until the new one is proven. id_changes in hourctl sync person show shows the step each member is at.

StepWhat happensDone when
settlethe package’s declared action that collects the old id’s remaining punchesIt is answered, or a short wait passes. Late punches still arrive under the alias.
createthe person under the new id, with every credential the group holds that the member takesthe member has them all
verify_newThe member is asked for the new user: its declared check, else its inventory.The user comes back as it was sent. A member with neither skips it.
delete_olddelete_user of the old iddone
verify_oldthe member is asked for the old userIt is gone: the declared check fails, or the inventory shows it. A member that can only upload its inventory cannot confirm it. An upload without the user may be partial. So the change goes on unverified. houradvantage_sync_replace_unverifiable_total counts these. The daily inventory finds the user if it is still there. The group deleted it, so its delete is sent again.

With punches on, every punch from a member that names a user and a time carries a sync object next to what the package reported:

FieldMeaning
groupThe group.
previousThe person’s latest earlier punch at any member within the last day. It holds time, state_name, endpoint, device.
duplicateAnother of the person’s recent punches is within 60 seconds of this one, before or after.
within_lockoutLess than lockout_minutes passed since previous. Always false when lockout_minutes is 0.
lateA later punch of the person was already known: this one arrived out of order. It never replaces the latest.
clock_aheadThe punch’s time is more than 5 minutes after the moment it reached Connect. The clock that made it is set ahead. The punch is delivered as the clock reported it. It is never the person’s latest punch and passes no zone. So the person’s real punches after it are judged as usual. See a clock set ahead.
zoneThe zone the punch’s reader is in, {"name", "violation"}. Null when none.
user_id_alias_ofThe new id, when the punch was made under an old id.
placement"outside" when the group keeps people and the person is not placed on that member.

A punch cannot be made after it reaches Connect. So a punch dated more than 5 minutes ahead comes from a clock set wrong. The 5 minutes are an allowance for the drift of a clock between the times it sets itself by the server.

If it were taken as the person’s newest punch, it would make every real punch after it late. It would also freeze their punch state, and a zone’s anti-passback with it, until the real time reached it.

Such a punch is marked clock_ahead and still delivered as a fact. But it is kept out of the punch state and the zone state. The clock’s entries in its own log (a delete, a clear) dated ahead of their arrival are taken as history, never as done now.

The device says so. Its info carries clock_ahead (since, and by_seconds as first seen) while its punches come from the future. One device.clock_ahead event is told when it is first seen so, not one per punch. A message of punches none of which is ahead clears the status. A later fault is told again.

Each package declares how its devices take part:

ModeWhat the device gets
mark only (no mode)Nothing. Its punches are marked.
pullThe device asks before it decides. Connect answers in the device’s time zone with last_punch (the person’s latest punch within the last day) and check (may the person pass a zone’s reader).
pushset_punch_state with the person’s latest punch (user_id, time, state_name, work_code, lockout_until, zone, inside). A newer one replaces one still waiting. One not sent within a day of the punch is dropped.

A zone is an access row of kind zone, for anti-passback and timed re-entry. Writing one needs the group to keep access. Marking punches against it needs punches.

FieldValuesDefault
namethe zone’s namethe row’s key
readers[{"endpoint", "device", "reader", "direction"}]. direction is in or out. With no reader: every reader of the device.required
ruleanti_passback: entering while inside, or leaving while outside, is a violation. timed: entering again within minutes of entering is a violation.anti_passback
minutesfor timed0
reset"HH:MM". Every day from this wall time (in the asking device’s endpoint time zone) nobody is inside.none
modehard: a device that asks first (check) is told to refuse a violation. soft: allowed, and marked.hard

A person with no known punches is never in violation. Someone Connect has not seen go in may come out.

bash:

Terminal window
hourctl sync row set hq access zone lobby rule=anti_passback mode=soft \
'readers=[{"endpoint":"office","device":"A1","direction":"in"},{"endpoint":"office","device":"A2","direction":"out"}]'

PowerShell:

Terminal window
hourctl sync row set hq access zone lobby rule=anti_passback mode=soft `
'readers=[{\"endpoint\":\"office\",\"device\":\"A1\",\"direction\":\"in\"},{\"endpoint\":\"office\",\"device\":\"A2\",\"direction\":\"out\"}]'

All routes are under the admin API. {name} is the group’s id.

  • Registry writes take {"fields": {...}, "secrets": {...}, "if_version": N}. This is a partial upsert. A field left out is untouched. A field set to null is cleared.
  • A write to a domain the group does not keep is 409, as is an if_version that does not match. A change the registry cannot take (a card another person holds) is 422.
  • Every write is in the audit trail, without secrets.
  • Pages take after and limit. limit is 100 unless given, at most 1000.
MethodPath
GET/api/tenants/{tenant}/syncEvery group: its settings, endpoints and member count.
POST/api/tenants/{tenant}/syncAdd a group. 201. 409 if the id exists.
GET/api/tenants/{tenant}/sync/{name}Its settings, endpoints, and per domain the number of rows and of member rows by state.
PATCH/api/tenants/{tenant}/sync/{name}Change its settings: a JSON merge patch.
DELETE/api/tenants/{tenant}/sync/{name}?confirm_delete_data=trueRemove it. 409 while an endpoint names it, or while it holds data and confirm_delete_data is not true. With it, every row, credential, punch state and alias of the group is deleted. Nothing is deleted from devices.
GET/api/tenants/{tenant}/sync/{name}/membersEach member: declaration, settings class, labels, counts by domain and state, last error, paused, its inventory action and when it last took one, and its id_changes under way. Then members that left and are remembered, with left_at and deletes_waiting.
DELETE/api/tenants/{tenant}/sync/{name}/members/{endpoint}/{device}Forget a member that left: its unconfirmed deletes no longer wait for it. 404 if no such member left. 409 for a current member.
GET/api/tenants/{tenant}/sync/{name}/members/{endpoint}/{device}/rows?domain=&state=The member’s rows with their state, omitted, reason or error. A row being sent shows the action carrying it. A failed one shows its error and attempts. 400 for an unknown state.
POST/api/tenants/{tenant}/sync/{name}/members/{endpoint}/{device}/resyncForget what was applied ({"domain"} optional), take inventory, send everything again. Answers rows.
POST/api/tenants/{tenant}/sync/{name}/members/{endpoint}/{device}/retrySend the member’s failed rows again ({"domain"} optional). Its other rows are left as they are. Answers rows: how many failed rows will be sent.
POST/api/tenants/{tenant}/sync/{name}/members/{endpoint}/{device}/resumeTake what a paused member reports again. Answers resumed (false if it was not paused).
GET/api/tenants/{tenant}/sync/{name}/people?after=&limit=&select=&external_id=People, in version order, without secrets, with next. select keeps those a selector picks by their labels. external_id=payroll:104552 finds a person by another system’s id.
GET/api/tenants/{tenant}/sync/{name}/people/{user_id}The person, credential metadata, every member with its state for them, and id_changes. A deleted person is shown (deleted: true) until the tombstone goes. 404 after.
PUT/api/tenants/{tenant}/sync/{name}/people/{user_id}Write a person (fields and secrets as in row kinds). A field at the top level, or one that is not a person’s, is 400.
DELETE/api/tenants/{tenant}/sync/{name}/people/{user_id}Delete the person, from the registry and every member.
GET, PUT/api/tenants/{tenant}/sync/{name}/people/{user_id}/biometrics{"user_id", "allow_biometrics"}. PUT {"allow": false} or true, in any group. Refusing someone who was allowed answers what was withdrawn (biometrics).
POST/api/tenants/{tenant}/sync/{name}/people/{user_id}/change-id{"new_user_id", "allow_reenroll"}. 400 if the new id is empty or the same. 422 if there is no such person or the new id is taken.
POST/api/tenants/{tenant}/sync/{name}/people/{user_id}/retry-change-idCarry on an id change where it stopped on each member. Answers retried: the members, with their step. 404 if there is no id change of that person.
PUT/api/tenants/{tenant}/sync/{name}/people/{user_id}/credentials/{kind}/{slot}{"format", "data_base64", "attrs"}. 400 for an unknown kind or data that is not base64. 422 without HOURADVANTAGE_SECRET_KEY, without people.biometrics, or for a person refused biometrics.
DELETE/api/tenants/{tenant}/sync/{name}/people/{user_id}/credentials[/{kind}[/{slot}]]Remove all of a person’s credentials, those of a kind, or one slot.
GET, PUT/api/tenants/{tenant}/sync/{name}/settings/{class}{"values": {"volume": 70, "language": null}}. null takes a value away from the group. Members keep what they have. Class * takes the standard names only.
GET, PUT, DELETE/api/tenants/{tenant}/sync/{name}/access/{kind}/{key}One access row (schedule, holiday, access_group, zone): {"fields", "if_version"}.
GET, PUT, DELETE/api/tenants/{tenant}/sync/{name}/lists/{kind}/{key}One list item (work_code, job_code, tip_code, message): {"fields", "if_version"}.
POST/api/tenants/{tenant}/sync/{name}/batch{"upsert": [...], "delete": [...]}: 1 to 10 000 changes, all or none. Each names domain (people, access, lists, settings), kind and key, with fields, secrets and if_version. Credentials are written one at a time. Sending the same batch again changes nothing more.
GET/api/tenants/{tenant}/sync/{name}/changes?after=&limit=The change feed.
GET/api/tenants/{tenant}/sync/{name}/punches/{user_id}The person’s latest punch and recent ones. 404 if none is recent.
GET/api/tenants/{tenant}/sync/{name}/people/{user_id}/routesThe person’s routes: the defaults, their own and the candidates a punch would have.
GET/api/tenants/{tenant}/sync/{name}/unroutedThe punches set aside as unrouted.
POST/api/tenants/{tenant}/sync/{name}/unrouted/{id}/routeRoute one: to a route given, its candidates passed on, or worked out again.
POST/api/tenants/{tenant}/sync/{name}/unrouted/routeWork them all (or one person’s) out again.
CommandDoes
hourctl synclist every group
hourctl sync show hqone group: settings, endpoints, rows per domain
hourctl sync status hqits members: rows by domain and state, settings class, labels, pauses, last error. Also members that left, with the deletes waiting for them.
hourctl sync create hq --domain people --domain punches --sink payroll [people.authority=shared]add a group
hourctl sync set hq domains=people,punches people.biometrics=truechange its settings
hourctl sync delete hq [--delete-data]remove it (and the data it keeps)
hourctl endpoint set office --sync-group hq / --no-sync-groupput an endpoint’s devices in a group, or back into a group of their own
hourctl endpoint set office --label area=warehouseset an endpoint’s labels
hourctl device label office A1 area=warehouse building=set a device’s own labels (key= removes one)
hourctl sync placement hq / placement add hq --people "role = warehouse" --devices "area = warehouse" / placement remove hq N / placement clear hqshow, add, remove one, or remove every placement rule
hourctl sync rows hq office A1 [--domain people] [--state failed]one member’s rows. NEXT says what each waits for.
hourctl sync resync hq office A1 [--domain people]send a member everything again
hourctl sync retry hq office A1 [--domain people]send a member’s failed rows again
hourctl sync resume hq office A1take a paused member’s reports again
hourctl sync forget hq office A1forget a member that left
hourctl sync people hq [--after N] [--select "role = office"]the people
hourctl sync person show hq 1001one person, with each member’s state
hourctl sync person set hq 1001 name="Ann Lee" --card 12345 --card 777 --label role=office --device office/A1 --pin 1234 [--password PW] [--external-id payroll=104552] [--if-version N]write a person. field= clears a field. --card, --label and --device (repeatable) replace the cards, labels and device list. --no-cards, --no-labels and --no-devices clear them.
hourctl sync person delete hq 1001delete a person
hourctl sync change-id hq 1001 2001 [--allow-reenroll] / hourctl sync retry-change-id hq 1001change a user id / carry on where it stopped
hourctl sync biometrics hq 1001 [--allow | --refuse]show, allow or refuse a person’s biometrics, in any group
hourctl sync setting hq zk-push-tft [volume=70 language=]show a class’s values, or set them (name= takes one away)
hourctl sync row show hq lists work_code 7 / row set hq lists work_code 7 name=Packing / row delete hq lists work_code 7access and list rows. A value starting with [ or { is read as JSON.
hourctl sync changes hq [--after N]the change feed
hourctl sync punches hq 1001a person’s latest punches
hourctl route list --person hq/1001 / route add / route removea person’s or a group’s routes (hourctl route)
hourctl unrouted list hq / unrouted route hq [ID]the punches set aside as unrouted, and routing them (hourctl unrouted)

person.changed, person.deleted, person.replaced, person.enrolled, inventory.extra_user, access.changed, list.changed, setting.changed, sync.member, sync.paused and tenant.limit_reached go to the group’s sinks, with the endpoint sync:<name> (events). A group with no domains sends none of them.

  • A sink that names no events is sent the person.*, access.changed, list.changed and setting.changed events of changes that came from a device. It is not sent those made through the API (origin api:...), and it is not sent sync.member. A sink that names them is sent all of them (the default set).
  • sync.member says a member joined, left, was paused or resumed, its declaration changed (declaration_changed), its labels changed (placement_changed), or a member that left was forgotten.
  • person.replaced says, once every member has finished a user id change, how each one did it.