Tenants
A tenant is one customer of the install: a company, a group of companies, or a staffing agency. Everything Time and Attendance keeps belongs to a tenant. Nothing of one tenant is visible from another. This page covers a tenant’s lifecycle, moving a tenant between installs, and the events a tenant sends.
Each tenant has its own people, facts, setup, policy layers and packages, ledgers, exceptions, exports and events. The same person id in two tenants is two different people. A tenant has one or more employers. Inside a tenant, “organization” means its own structure, such as a plant, a client site or a union local. These are kept in hierarchies.
Time and Attendance tenants are a separate list from Connect’s tenants. A Connect sink names the Time and Attendance tenant it delivers punches to. It needs one of that tenant’s delivery keys (punch deliveries).
A tenant
Section titled “A tenant”| Field | |
|---|---|
id | 1 to 64 letters, digits, - or _. Paths, sinks and tokens (attend:<tenant>) name it. |
name | A name for people to know it by. |
external_ids | Its id in each other system ({"payroll": "C-1042"}). |
metadata | A JSON object of at most 16 KiB and 16 levels deep, kept as given. The engine never reads it. Your business rules can (policy step reference). |
status | active or suspended. |
Lifecycle
Section titled “Lifecycle”| API | hourctl | |
|---|---|---|
| List | GET /api/attendance/tenants | hourctl attend tenants list |
| Create | POST /api/attendance/tenants | hourctl attend tenants create acme --name "Acme Staffing" |
| Read | GET /api/attendance/tenants/{tenant} | hourctl attend tenants show acme |
| Change | PATCH /api/attendance/tenants/{tenant} | hourctl attend tenants update acme --metadata @acme.json |
| Suspend | POST /api/attendance/tenants/{tenant}/suspend | hourctl attend tenants suspend acme |
| Resume | POST /api/attendance/tenants/{tenant}/resume | hourctl attend tenants resume acme |
| Delete | DELETE /api/attendance/tenants/{tenant} | hourctl attend tenants delete acme --yes |
- Changing the name or external ids changes nothing else. Changing the metadata recalculates everyone in the tenant, because business rules can read it. New metadata over the limit is refused (400, for example
tenant 'acme': metadata takes 20480 bytes as JSON, more than the 16384 it may). Metadata already stored over the limit is still given to the rules. A change that leaves it alone is accepted. - Suspending stops all work for the tenant. While it is suspended, nothing of it is recalculated and it sends no events. Its API answers reads and refuses writes (409). Issuing a delivery key and adding or changing a sink are among the refused writes. Revoking a key and removing a sink stop something, and are taken. Deliveries to it are refused, so its punches wait in Connect’s outbox. When you resume it, it accepts writes again, its sinks deliver what waited, and its people are recalculated.
- Deleting removes everything kept for the tenant at once. That includes its delivery keys and sinks. It also revokes every token scoped to it. A tenant created again with the same id is reached by none of those tokens. It accepts no delivery signed with the old keys. Its sinks and tokens go first and the tenant last. So a delete that stops part way leaves nothing that reaches the tenant. A delete for a tenant that is gone (404) still takes them.
- Loading a document into a tenant (below) holds it. The tenant says
loading: true. It cannot be changed, suspended, resumed or deleted (409,tenant 'acme' is being loaded from a document) until the load ends. The end of the load gives it the status the document asked for. A load that stopped part way holds the tenant until it is gone on with or its hold runs out.
Every other attendance route belongs to a tenant, under /api/attendance/tenants/{tenant}/ (attendance API). hourctl names the tenant with its global --tenant option (-t, or HOURADVANTAGE_TENANT). Every hourctl attend command except tenants and test needs it:
hourctl --tenant acme attend ledger 104552A token scoped attend:acme reaches only acme’s routes. It cannot read or change the tenant record itself, its lifecycle, or its whole export and import (tokens).
Writing a tenant out and loading it
Section titled “Writing a tenant out and loading it”You can write a whole tenant out as a portable document. You can load it into a tenant on this install or another. Use this to move a customer, to keep a copy before deleting, or to rename a tenant.
hourctl attend tenants export acme -o acme.ndjson # GET .../tenants/{tenant}/exporthourctl attend tenants import acme acme.ndjson # POST .../tenants/{tenant}/importThe document is JSON lines. Each line is one object with one key:
| Line | What it holds |
|---|---|
tenant | First: the document’s format (3) and the tenant (id, name, external ids, metadata, status). A document of format 2 is read too. |
metadata | A version of the tenant’s metadata, metadata and stored, in the order kept. The last is the tenant’s own. A closed period is worked out with the metadata as of its close. So a tenant loaded keeps every version. A tenant made by the load has them. A tenant there was keeps its own metadata and its own versions. A document of format 2 has none. It is loaded with the metadata as one version stored from the beginning. |
setup | A revision of a setup item: person (absent for the tenant’s own), kind, id, item (null when removed), by, stored. In the order kept. |
layer | A policy layer revision, with by and stored. |
package | A revision of the tenant’s own policy package: its version, source, layers, scenarios, state and results, by, stored. |
adopted | An adoption of a package (want: a major version or an exact one; null when dropped), by, stored. |
employer | An employer: id, name, external_ids, created. |
hierarchy | A hierarchy: id, name, created. |
organization | An organization: hierarchy, id, name, parents (its parent from each day on), external_ids, labels, metadata, created. |
location | A work location: id, name, zone, jurisdiction, values (where it has any), external_ids, labels, metadata, created. |
sink | A sink of the tenant’s events, as GET .../sinks/{id} shows it. Its signing secret is left out. secret_set says whether it had one. |
unlinked | An unlinked person: id, the sender’s ids, first_seen, last_seen, and their links, each with whom to, by and stored. Before the people. |
person | A person, their record (employer, worker) and every fact about them, each with its stored, in the order kept. |
closed | The record of one of the person’s closed periods: person, side, period, closed (the close it was made at), code (the code version that calculated it) and ledger as it stood at its close. |
unreadable | An unreadable punch: id, the event as it came, why, and stored. In the order kept. |
export | A payroll export made (who, when, which period, how it ended) and people: which ledger of each person it wrote, as [person, hash]. |
end | Last: how many people and facts the document has. |
Loading follows these rules:
-
The ids must match. The document’s tenant must be the one in the path. To load it under another id, say so with
?from=<the document's id>(hourctl attend tenants import moved acme.ndjson --from acme). Without it, a document for another id is refused (400) and nothing is created. -
The target must be empty. A tenant that does not exist is created as the document describes it. One that exists must have no data yet. That means no facts, setup, layers, packages, exports or unreadable punches. Only one load into a tenant can run at a time. A second is refused (409).
-
The tenant is suspended while it loads. Nothing of it is calculated. Its deliveries and API writes are refused until the
endline has loaded. Then it takes the document’s status (or its own, if it already existed). -
Loading sends no events. The closed periods, approved timecards and exceptions in the document were announced where it came from. So payroll never hears of them twice. What is stored after the load sends events as usual.
-
A broken document stops the load, and loading it again goes on. Any of these stops the load, naming the line:
- A document cut short (no
endline). - A line that does not parse or is refused.
- A store lost part way.
What loaded before it stays, and the tenant stays suspended. Load the same document again to go on where it stopped. Each line stored already and the same is skipped, and the rest is loaded. The tenant is released once the
endline has loaded. A line stored already but differently is refused (409), naming it (employer ca is stored already, and differently). So is another document while the load is unfinished. A load whose instance was lost holds the tenant for up to a minute after it last read a line. Then a load of the same document takes it over. - A document cut short (no
-
Sinks load after everything else. Every sink is checked before any is kept. An invalid one is refused (400; the tenant is loaded with none of its sinks). A sink whose id the tenant already has is left as it is. Signing secrets are never exported, so the answer’s
secrets_to_setnames the loaded sinks that had one. They post unsigned until you set it again (PATCH .../sinks/{id}withsecret).
Everything loaded keeps the time it was stored at the source (stored). A setup, layer or package line without one counts as stored from the beginning. So periods come out the same after the move. Unreadable punches load in the same order, ready to be put right. Unlinked people load with their links, so their punches stay where they were. A shared package the tenant adopts must be published on the install that loads it (shared packages).
Ledgers are not in the document, except the records of closed periods. The loading install calculates them again from the facts. This is background work that takes turns with new punches. A punch another tenant sends meanwhile is calculated in the next batch. From the same facts, setup and policy they come out the same. The timecards are the same, and an export’s “changed since” reads the same on both installs. A closed period is read from its record. What was paid stays what was paid, whatever version the loading install runs.
Getting punches into a tenant
Section titled “Getting punches into a tenant”Punch deliveries covers how punches reach a tenant. In short:
How punches find their tenant
Section titled “How punches find their tenant”Every delivery names its tenant and is signed with one of that tenant’s delivery keys (how punches find their tenant).
Delivery keys
Section titled “Delivery keys”A delivery key is a write-only key a tenant issues to each sender (delivery keys).
Delivering punches
Section titled “Delivering punches”Senders outside the install post signed batches to POST /api/attendance/tenants/{tenant}/deliveries (delivering punches).
A refused sink
Section titled “A refused sink”A delivery to a missing or suspended tenant, or without a valid key, is refused. The sink waits in Connect’s outbox without losing anything (a refused sink).
A punch that cannot be read
Section titled “A punch that cannot be read”A punch with no time or no person is kept with the reason, to be put right (a punch that cannot be read).
Events and sinks
Section titled “Events and sinks”Time and Attendance tells your systems what they need to act on or keep up to date with. These are the events (event reference):
exception.raisedandexception.resolvedtimecard.approvedperiod.closedandperiod.adjustedleave.requested,leave.decidedandleave.cancelledrecalculation.parkedperson.unlinked_seenandperson.linkedpackage.updated
These events are kept in Time and Attendance’s own event log, apart from Connect’s. Connect’s events, sinks and API never show them. Time and Attendance’s sinks are sent none of Connect’s. The two engines share only how events are delivered.
Each event belongs to its tenant and uses the standard envelope:
| Field | Value |
|---|---|
tenant | The Time and Attendance tenant (the event’s data names it too). |
endpoint | attendance. |
device | What the event is about: a person’s id, or their timecard (104552/pay/2026-10-05). |
package | houradvantage-attend. |
id | Stable: the same event sent again has the same id, so receivers can deduplicate on it. |
A sink is a webhook the events are posted to. It is set up the same way as a Connect sink. Its settings are:
urlsecret. Each post is then signed withx-houradvantage-timestampandx-houradvantage-signature.events. These are the types it is sent, and all of them when it names none.matchlatest_onlymax_per_secondbatchbatch_bytes
A tenant’s sink is sent its tenant’s events. It is also sent those posted into the tenant by the systems it names in sources (below). An install-level sink is sent every tenant’s events and names no sources.
| API | hourctl | |
|---|---|---|
| List, with what waits | GET .../sinks, GET .../sinks/status | hourctl -t acme attend sinks |
| Add | POST .../sinks | hourctl -t acme attend sink add payroll --url https://payroll.example.com/in --event period.closed |
| Read | GET .../sinks/{id} | |
| Change | PATCH .../sinks/{id} | hourctl -t acme attend sink set payroll --default-events |
| Move | POST .../sinks/{id}/position | hourctl -t acme attend sink position payroll latest |
| Remove | DELETE .../sinks/{id} | hourctl -t acme attend sink remove payroll |
... is /api/attendance/tenants/{tenant} for a tenant’s sinks and /api/attendance for the install’s (hourctl --install attend sinks). An attend:<tenant> token reaches its tenant’s sinks. The install’s sinks need an install token. A sink change made through any instance applies on every instance at once.
Delivery works as it does for Connect’s sinks (many sinks):
- Each sink gets its events in order, at least once.
- A sink that refuses backs off alone and is never skipped. The others carry on.
- A new sink starts with the events stored after it was made. Removing a sink removes its place. So a sink created again with the same id starts fresh.
- The log has its own sequence numbers, separate from Connect’s.
GET /api/attendance/tenants/{tenant}/events(hourctl -t acme attend events) lists a tenant’s events with them. So you can move a sink back or ahead. - Events are kept for the install’s
retention_daysafter every sink they are for has taken them. They are kept for as long as one has not. A sink that falls behind is told withsink.behindandsink.caught_up. One moved by hand is told withsink.moved. These go in this log (retention).
A tenant’s webhook reaches the same destinations a Connect tenant’s may (where a tenant’s setup reaches). The sink metrics are Connect’s (houradvantage_sink_behind and the rest), labelled log="attend".
Events other systems post
Section titled “Events other systems post”Any system can post events into a tenant at POST /api/attendance/tenants/{tenant}/events, with an attend:<tenant> token or an install token. An HR system, a scheduling app and another install are examples. The body and its checks are the same as for posting into a Connect tenant. The events are kept in the tenant’s log. They reach the tenant’s sinks that name their source in sources, and the install’s sinks. A suspended tenant accepts none (409).
hourctl -t acme attend event post @hires.json --source hrhourctl -t acme attend sink add hr-feed --url https://hr.example.com/in --source hrhourctl -t acme attend events --source hr --followFair recalculation
Section titled “Fair recalculation”Every instance that runs Time and Attendance shares the work of recalculating ledgers across all tenants. No tenant can hold up another:
- People with new facts come first. A punch or other fact for a person is handled before tenant-wide work. So is a change to that person’s own setup. Tenant-wide work is such as a policy change, a tenant setup change, new metadata or a loaded document. When one tenant’s policy change touches 200,000 people, another tenant’s new punch does not wait behind them.
- Tenants take turns. Each tenant with work gets an even share. So a tenant’s backlog does not grow another tenant’s wait. Within its share, a tenant’s live marks take most places. Its bulk marks take every fourth (from a share of four). So a tenant whose live marks fill every batch still has its bulk marks worked out, however busy it is.
- A slow policy slows only its own tenant. A policy step does a bounded amount of work and uses at most 64 MiB of memory per call. A person who hits those limits fails like any other person whose ledgers cannot be worked out. The error is kept on them (
GET .../pending). They wait until something they are worked out from changes. The eventrecalculation.parkedreports it with"reason": "failed". A tenant takes only its share of each batch’s work, so every other tenant carries on at once. - A suspended tenant waits. Its people are not recalculated until it is resumed.
See recalculation for when a person’s ledgers are calculated again.
Tenants in scenarios
Section titled “Tenants in scenarios”Policy scenarios (hourctl attend test, the cookbook) run in a tenant the test runner supplies. A scenario names none. To test a rule that reads the tenant’s metadata, set it in the scenario:
[tenant]metadata = { contract = { long_day = "10h" } }