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.
Group settings
Section titled “Group settings”A group is kept with these settings. Change them with hourctl apply, hourctl sync or the admin API.
| Field | Values | Default |
|---|---|---|
id | 1 to 64 letters, digits, - or _ | required |
domains | any of people, access, lists, settings, punches, each once | none (the group keeps nothing) |
sinks | sinks the group’s own events go to. Each must exist. | none |
people, access, lists, settings, punches | the domain settings | see below |
placement | placement rules, at most 100 | none. Everyone is on every member. |
routes | default routes. Each names a system and a tenant, never a person. | none |
external_ids | what other systems know the group by, such as {"payroll": "site-12"} | none |
metadata | a JSON object kept as given, never read by Connect | none |
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.
Domain settings
Section titled “Domain settings”| Setting | Domains | Values | Default |
|---|---|---|---|
authority | people, lists, settings | group or shared (authority) | group |
biometrics | people | true means the group keeps biometric templates, face photos and display photos. Needs HOURADVANTAGE_SECRET_KEY. | false |
lockout_minutes | punches | A 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 |
Limits
Section titled “Limits”| Limit | Value |
|---|---|
| Label key | 1 to 63 letters, digits, -, _, . or / |
| Label value | 1 to 255 characters of plain words (letters, digits, -, _, .) joined by / into a path, such as west/nevada/plant-7 |
| Labels per endpoint, device or person | 64 |
| Placement rules per group | 100 |
A person’s metadata | a JSON object of at most 16 KiB |
Domains and row kinds
Section titled “Domains and row kinds”| Domain | Rows | What members are sent |
|---|---|---|
people | people 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 |
access | schedules, holidays, access groups, zones | set_schedule, set_holiday, set_access_group and their deletes. Zones are never sent. |
lists | work, job and tip codes, messages | set_list_item, delete_list_item |
settings | values per settings class (<class>/<name>) | one set_settings per member with every outstanding value of its class |
punches | the latest punches per person, and zone state | The sync mark on member punch events. Answers to devices that ask. set_punch_state to devices that take it. |
| Domain | Kind | Key | Fields |
|---|---|---|---|
people | person | user id | name, 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. |
people | credential | <user_id>/<kind>/<slot>/<format> | Written with PUT .../credentials/{kind}/{slot}. The kinds are fingerprint, face, face_photo, palm, finger_vein, iris, photo. |
access | schedule | any | name, 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. |
access | holiday | any | name, from, to, type |
access | access_group | any | name, schedules (schedule keys), doors (none: all) |
access | zone | any | see Zones |
lists | work_code, job_code, tip_code | the code | name |
lists | message | any | text, user_ids, from, minutes |
settings | setting | <class>/<name> | value (written with PUT .../settings/{class}) |
external_ids,routesandmetadataare 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
maxitems of a list takes the group’s firstmaxby key. The rest areunsupporteduntil there is room. A message withuser_idsgoes 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).
| Domain | Standard actions refused |
|---|---|
people | upsert_user, delete_user, set_cards, change_user_id, rename_user, set_biometric, delete_biometrics, set_user_photo, delete_user_photo, clear_users, wipe |
access | set_schedule, delete_schedule, set_holiday, delete_holiday, set_access_group, delete_access_group, wipe |
lists | set_list_item, delete_list_item, set_work_code, delete_work_code, show_message, wipe |
settings | set_settings |
punches | set_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.
Outcomes and row states
Section titled “Outcomes and row states”For each row and member, the outcome is one of:
| Outcome | Meaning |
|---|---|
applies | The 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"}. |
unsupported | The 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_applicable | The member does not take this kind of data at all. |
not_placed | The 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.
| State | Meaning |
|---|---|
pending | To be sent, or being sent (the row shows the action carrying it). |
in_sync | The member holds the row’s current version. |
failed | Sending failed (see error). It stays failed until the registry’s row changes or an app runs retry. No time sends it again. |
unsupported | The member takes this kind of data, but not this row (see reason). |
diverged | A 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_applicable | The member does not take this kind of data. |
needs_reboot | A 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_placed | Not placed on the member. Taken off it if it held it. |
deleted | A delete the member confirmed, while the group still keeps the row’s tombstone. |
Changing a user id: the replace steps
Section titled “Changing a user id: the replace steps”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.
| Step | What happens | Done when |
|---|---|---|
settle | the package’s declared action that collects the old id’s remaining punches | It is answered, or a short wait passes. Late punches still arrive under the alias. |
create | the person under the new id, with every credential the group holds that the member takes | the member has them all |
verify_new | The 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_old | delete_user of the old id | done |
verify_old | the member is asked for the old user | It 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. |
Punch marks
Section titled “Punch marks”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:
| Field | Meaning |
|---|---|
group | The group. |
previous | The person’s latest earlier punch at any member within the last day. It holds time, state_name, endpoint, device. |
duplicate | Another of the person’s recent punches is within 60 seconds of this one, before or after. |
within_lockout | Less than lockout_minutes passed since previous. Always false when lockout_minutes is 0. |
late | A later punch of the person was already known: this one arrived out of order. It never replaces the latest. |
clock_ahead | The 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. |
zone | The zone the punch’s reader is in, {"name", "violation"}. Null when none. |
user_id_alias_of | The 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 clock set ahead
Section titled “A clock set ahead”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:
| Mode | What the device gets |
|---|---|
mark only (no mode) | Nothing. Its punches are marked. |
pull | The 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). |
push | set_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.
| Field | Values | Default |
|---|---|---|
name | the zone’s name | the row’s key |
readers | [{"endpoint", "device", "reader", "direction"}]. direction is in or out. With no reader: every reader of the device. | required |
rule | anti_passback: entering while inside, or leaving while outside, is a violation. timed: entering again within minutes of entering is a violation. | anti_passback |
minutes | for timed | 0 |
reset | "HH:MM". Every day from this wall time (in the asking device’s endpoint time zone) nobody is inside. | none |
mode | hard: 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:
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:
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 tonullis cleared. - A write to a domain the group does not keep is 409, as is an
if_versionthat 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
afterandlimit.limitis 100 unless given, at most 1000.
| Method | Path | |
|---|---|---|
| GET | /api/tenants/{tenant}/sync | Every group: its settings, endpoints and member count. |
| POST | /api/tenants/{tenant}/sync | Add 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=true | Remove 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}/members | Each 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}/resync | Forget what was applied ({"domain"} optional), take inventory, send everything again. Answers rows. |
| POST | /api/tenants/{tenant}/sync/{name}/members/{endpoint}/{device}/retry | Send 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}/resume | Take 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-id | Carry 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}/routes | The person’s routes: the defaults, their own and the candidates a punch would have. |
| GET | /api/tenants/{tenant}/sync/{name}/unrouted | The punches set aside as unrouted. |
| POST | /api/tenants/{tenant}/sync/{name}/unrouted/{id}/route | Route one: to a route given, its candidates passed on, or worked out again. |
| POST | /api/tenants/{tenant}/sync/{name}/unrouted/route | Work them all (or one person’s) out again. |
hourctl
Section titled “hourctl”| Command | Does |
|---|---|
hourctl sync | list every group |
hourctl sync show hq | one group: settings, endpoints, rows per domain |
hourctl sync status hq | its 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=true | change its settings |
hourctl sync delete hq [--delete-data] | remove it (and the data it keeps) |
hourctl endpoint set office --sync-group hq / --no-sync-group | put an endpoint’s devices in a group, or back into a group of their own |
hourctl endpoint set office --label area=warehouse | set 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 hq | show, 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 A1 | take a paused member’s reports again |
hourctl sync forget hq office A1 | forget a member that left |
hourctl sync people hq [--after N] [--select "role = office"] | the people |
hourctl sync person show hq 1001 | one 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 1001 | delete a person |
hourctl sync change-id hq 1001 2001 [--allow-reenroll] / hourctl sync retry-change-id hq 1001 | change 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 7 | access 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 1001 | a person’s latest punches |
hourctl route list --person hq/1001 / route add / route remove | a 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) |
Events
Section titled “Events”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
eventsis sent theperson.*,access.changed,list.changedandsetting.changedevents of changes that came from a device. It is not sent those made through the API (originapi:...), and it is not sentsync.member. A sink that names them is sent all of them (the default set). sync.membersays a memberjoined,left, waspausedorresumed, its declaration changed (declaration_changed), its labels changed (placement_changed), or a member that left wasforgotten.person.replacedsays, once every member has finished a user id change, how each one did it.