Skip to content

Tenants

A Connect tenant is whoever operates clocks through your install. It might be a dealer, a software vendor or an employer.

Each tenant has its own listeners, endpoints, sinks, sync groups, devices, jobs, vars, secrets and events. So you can serve many customers from one install. No customer can see, name or reach another’s.

Time and Attendance keeps tenants of its own. The two engines keep separate tenant lists. A Connect sink names the Time and Attendance tenant it delivers to.

A fresh install has one tenant, default. If you never make another, everything stays in it.

Acme's clocks Globex's clocks port 8443 port 8444 One install Tenant acme its listener, on port 8443 endpoints, sinks, sync groups devices, jobs, vars, secrets its own events Tenant globex its listener, on port 8444 endpoints, sinks, sync groups devices, jobs, vars, secrets its own events nothing shared events events The install's own tenants, settings, packages, tokens, the audit trail install-level sinks: sent every tenant's events
Each tenant's clocks reach its own listener, and everything the tenant keeps is its own. The install keeps the tenants themselves and what is shared. Its sinks are sent every tenant's events.
Field
id1 to 64 letters, digits, - or _. Connect reads no meaning into it. You cannot change it.
nameA name for people to know it by.
statusactive, suspended or stopped (below).
external_idsThe tenant’s id in other systems, {"crm": "C-1042"}. It is kept as given.
metadataA JSON object kept as given. It can be at most 16 KiB as JSON and 16 levels deep. It is never sent in events.
limitsIts own limits, which win over the install’s defaults.

Only an install token or the admin login can list, add, change, suspend, resume, stop or delete tenants.

Terminal window
hourctl tenants
hourctl tenant create acme --name "Acme Manufacturing" --external-id crm=C-1042
hourctl tenant set acme --devices 100
hourctl tenant suspend acme
hourctl tenant resume acme
hourctl tenant delete acme --yes

Over the API, use these routes:

  • GET and POST /api/tenants
  • GET, PATCH and DELETE /api/tenants/{tenant}
  • POST /api/tenants/{tenant}/suspend, /resume and /stop

See the tenants operations and hourctl tenant.

Every route for a tenant’s setup and data is under /api/tenants/{tenant}/. The routes are listeners, endpoints, sinks, sync, devices, jobs, vars, secrets, packages, events, failures, traffic, wire, stream, export and the rest. The packages route holds the tenant’s own policy packages.

To reach them with hourctl, pass --tenant. You can also use -t or HOURADVANTAGE_TENANT. Without it, you reach the default tenant.

Terminal window
hourctl --tenant acme listener add web --http 0.0.0.0:8443
hourctl -t acme endpoints
hourctl -t acme apply acme.toml
hourctl -t acme export

Ids are unique within a tenant, not across tenants. Acme’s endpoint main and the default tenant’s endpoint main are two endpoints.

Every id a request names must be 1 to 64 letters, digits, - or _. That holds for an id in its path, body or query.

An id with a . or a : names nothing in any tenant. The answer is 404. It is 400 in a setup document, or in a sink, listener, endpoint or sync group being made.

No tenant, the default included, can reach another tenant’s resources or the install’s by naming them.

A tenant’s file for hourctl apply has [[listener]], [[endpoint]], [[sink]], [[sync_group]] and [[device_labels]]. Any setup file has the same sections. A tenant’s file holds no tenants and none of the install’s settings.

One tenant’s listener may serve many of its endpoints, each on its own path or topic. It never serves another tenant’s.

A listener on an address and port that another tenant’s listener already binds is refused:

tenant 'acme': listener 'web' would bind 0.0.0.0:8080, which another
tenant's listener binds: a listener is never shared between tenants

Addresses are compared the way a socket binds them:

  • [::ffff:10.0.0.5]:8080 is the IPv4 address.
  • 0.0.0.0 takes every IPv4 address on its port.
  • :: takes every address.
  • Port 0 means a port the system picks. It never clashes.

Two tenants’ MQTT listeners on the same broker may not subscribe to overlapping topics. If they did, each tenant would get the other’s devices’ messages. Give each tenant a topic prefix of its own.

Two topic filters overlap when both of these hold:

  • They have the same number of levels.
  • At each level, the two are the same, or one of them is a placeholder.
tenant 'acme': listener 'bus' would subscribe to 'clocks/+/events' on
broker.example:1883, which overlaps 'clocks/+/events' that another
tenant's listener subscribes to there: tenants never share a broker's
topics (give each tenant topics of its own, such as a prefix)

Brokers are compared by the host and port in their address. The case of the host is ignored. What a name resolves to is not looked at. So two names for one broker count as two brokers here.

The broker’s own ACLs keep each tenant’s login to its own topics.

A tenant’s webhooks and brokers reach public addresses only. The install can list more in tenant_destinations. See security.

The listener and endpoint a device calls decide its tenant. Nothing else in the request is read to decide it.

What is not a tenant’s belongs to the install. That includes:

  • The tenants.
  • The admin settings: limits and its defaults for tenants, retention_days, audit_retention_days, trusted_proxies, tenant_destinations and the log level.
  • Packages.
  • Tokens.
  • The audit trail.
  • The install-level sinks.

To reach them with hourctl, pass --install:

Terminal window
hourctl --install sink add all --url https://warehouse.example.com/in
hourctl --install apply install.toml
hourctl --install export

An install file has [[tenant]], [[sink]] and the install’s settings. If a file has a section that belongs in the other kind of file, apply refuses it and says which.

install.toml
retention_days = 30
[[tenant]]
id = "acme"
name = "Acme Manufacturing"
external_ids = { crm = "C-1042" }
limits = { devices = 100 }
[[sink]]
id = "all"
type = "webhook"
url = "https://warehouse.example.com/in"

retention_days is how long finished work is kept. The default is 30. It covers:

  • Finished commands.
  • Finished jobs, with their devices’ executions.
  • Delivered events.

An event a sink has not taken is never removed for its age. That holds whether the sink is down, paused or belongs to a suspended tenant.

A sink can fall more than retention_days behind. It is then reported once with sink.behind. It is reported once more with sink.caught_up when the sink catches up.

These are Connect’s own events about the sink’s tenant. Their endpoint is source:connect. For an install-level sink, they are the default tenant’s. They are sent to the tenant’s sinks that name connect in their sources, and to the install’s sinks.

Dropping what a sink has not taken is your decision. To do it, move the sink ahead with hourctl sink position.

If you take a sink off an endpoint that stays, the sink is still owed what that endpoint stored before the edit. “After the edit” means after the instance storing the events has put the edit into use. Run hourctl peers to see the version each instance has applied. An instance that has not applied the edit yet still stores under the old setup. The sink is owed what it stores until then as well.

To end what a sink is owed, delete the endpoint, sync group or sink. Its events go once retention_days have passed. Renaming an endpoint is the same as deleting it and adding another. See also retention in operations.

audit_retention_days is how long audit entries are kept. It is separate from retention_days. It is unset by default, so entries are kept for ever. Once set, cleanup removes the entries made that many days ago or more. It must be greater than 0.

  • hourctl settings set audit_retention_days=365 keeps a year.
  • audit_retention_days= (empty) puts it back to unset.

Events are kept by the day they were received, in a partition of the log for each day. An instance may store an event from a day gone by, such as a message set aside and taken in late. That instance looks for that day’s partition each time. If another instance’s cleanup dropped the partition meanwhile, the first instance makes it again. The next cleanup removes the event once every sink has taken it.

For that reason, a limits.set_aside_days longer than retention_days is allowed. The only cost is that late events are removed sooner.

One instance at a time runs cleanup. What a run costs grows with the days it looks at. It does not grow with the number of sinks.

Connect keeps every event with its tenant. The envelope carries these fields:

Field
tenantThe tenant whose endpoint the event is of. Events of the source attendance in Connect’s log say default, but they belong to no Connect tenant. No tenant’s events, stream or sinks show them. Only install-level sinks that name that source are sent them. Time and Attendance keeps its own events in a log of its own.
endpointThe endpoint’s id within the tenant. For a sync group’s own events, it is sync:<group>. For events a system posted, it is source:<source>.
groupThe endpoint’s sync group’s id within the tenant.
deviceThe device’s id.
personConnect’s own id of the person the event is about. It is the event’s user_id in its group, when the group keeps the person. It is an opaque UUID, given when the person is first written. It stays when their user id changes. It differs for a person who is deleted and written again.
requestThe admin API request that caused the event, if any. It holds the request’s id (the X-Request-Id it was answered with), its idempotency_key and its user. The server names the user from the login or the token (token:<name>), never as the caller says (request ids). With it, you can trace an event posted through the API to a person or a token. Events that no request caused have none. Those include a device’s messages, a job’s waves and a ledger worked out.

GET /api/tenants/{tenant}/events reads one tenant’s events.

A tenant’s sink is sent its own tenant’s events, and only those. These are:

  • The events of the endpoints and sync groups that name it.
  • The events that the systems in its sources post into the tenant.

An install-level sink (/api/sinks, hourctl --install sink) is sent every tenant’s events, posted ones included. That suits a data warehouse or an audit feed. It is sent the attendance source’s events only when it names that source.

A sink that speaks for a system (system) is sent only the punches routed to that system. Each one carries the person’s id (routes).

A sink starts with the events stored once something feeds it. Suppose you take a sink off an endpoint’s sinks and name it again later. It carries on from where it stopped. A sink that you delete and make again with the same id starts as a new sink does.

The sink that hands punches to Time and Attendance has type in_process and receiver attendance. It names the Time and Attendance tenant it delivers to. It carries one of that tenant’s delivery keys as its secret. Any Connect tenant may make one, and so may the install.

Naming a tenant proves nothing. The key is what lets the sink deliver. Without a valid key, the deliveries are refused and the sink’s status says why.

A sink in a tenant’s setup is sent that tenant’s punches. A sink at the install level is sent every tenant’s.

A webhook sink delivers the same way to another install’s Time and Attendance. It posts to /api/attendance/tenants/{tenant}/deliveries with the key as its secret. See delivering punches.

Terminal window
# the Time and Attendance tenant acme issues a key to dealer-north
export KEY=$(hourctl -t acme attend delivery-keys create --label "dealer-north")
# dealer-north's sink delivers its punches into acme with it
hourctl -t dealer-north sink add acme-time --receiver attendance \
--receiver-tenant acme --secret-env KEY --event punch

Any system can post events into a tenant for the tenant’s sinks to deliver. It might be an ERP, a scheduling app or another install. It needs a connect:<tenant> token or an install token.

POST /api/tenants/acme/events
Authorization: Bearer hadv_...
{"events": [{"id": "erp-hire-20391", "source": "erp", "type": "employee.hired",
"device": "104552", "data": {"person": "104552", "start": "2026-10-12"}}]}

From the command line, use hourctl -t acme event post. See the command. The shape follows CloudEvents:

Field
sourceThe system that sends it: 1 to 64 letters, digits, - or _. connect is Connect’s own and cannot be posted as.
id1 to 128 characters, no spaces or control characters, unique within its source.
type1 to 64 letters, digits, ., _ or -.
deviceOptional. What it is about, at most 256 characters.
dataA JSON object of at most 16 KiB.

A post holds 1 to 100 events. All of them are kept or none. One invalid event refuses the whole post (400), and the answer says which.

Posting is idempotent. That means a repeat does no harm. Suppose you post an event again with the same source and id within retention_days, such as a retry after a timeout. It is kept once.

The answer lists which ids were kept and which were posted before: {"stored": ["erp-hire-20391"], "duplicates": []}. A suspended or stopped tenant takes no posts (409).

A posted event is an event of the tenant, in the standard envelope:

  • Its endpoint is source:<source>.
  • Its package is the source.
  • Its device is the one posted.
  • Its received_at is when it was kept.
  • Its id is 32 hex digits, derived from the source and the posted id. The id is the same however often you post it.

You can read posted events with the tenant’s events (GET /api/tenants/acme/events?endpoint=source:erp) or its live stream. They go to the tenant’s sinks that name erp in their sources, and to the install-level sinks. Posts are data, like a device’s messages. So they are not in the audit trail.

The sources connect and attendance are Connect’s and Time and Attendance’s own. No system posts as either, whatever token it posts with (400).

Connect keeps its own events about a tenant as a whole under the source connect. They are package.updated, sink.behind, sink.caught_up and sink.moved. A tenant’s sink that names connect in its sources is sent them.

The devices of a suspended or stopped tenant are refused. What happens next depends on the connection:

  • An HTTP request is answered 503 (suspended). The clock keeps what it has and sends it again.
  • An MQTT message is set aside. It is kept, sealed and acknowledged. So it does not hold up the messages after it on the same connection.

Neither kind of message is taken in. No command goes out to the tenant’s devices. None of its jobs, sync groups or sinks runs. Nothing the tenant has is removed.

When you resume the tenant, it carries on at once, on every instance:

  • Its jobs take their next step.
  • Its sync groups send what was written meanwhile.
  • Its sinks deliver what waited.
  • An MQTT message that was set aside is taken in, once.

The default tenant runs whatever another tenant’s status is.

stop works like suspend. Use it for a tenant that is to stay stopped, such as one being moved out or about to be deleted.

DELETE /api/tenants/{tenant} (hourctl tenant delete acme --yes) stops the tenant. Then it removes everything Connect keeps of it:

  • Devices, with their commands, actions and failures.
  • Events.
  • Sync groups’ rows.
  • Jobs, vars and secrets.
  • Its policy packages.
  • Sink positions.
  • Its listeners, which stop listening.
  • Its endpoints, sinks and sync groups.
  • The tenant itself.

Every token scoped to the tenant (connect:<tenant>) is revoked. The instance that deleted the tenant refuses them at once. The other instances refuse them within 60 seconds. The answer lists the tokens’ names in revoked_tokens. If you make a tenant again with the same id, none of those tokens reaches it.

Deleting a Time and Attendance tenant (hourctl attend tenants delete) revokes its attend:<tenant> tokens the same way. It also deletes its delivery keys. The audit trail’s entry for the deletion names the tokens revoked and the delivery keys deleted.

The tenant’s events go with it, whatever the install-level sinks have taken of them. So a tenant is not deleted while an install-level sink has not taken its events. An example is an install’s webhook into payroll that is down.

In that case the answer is 409. It names each such sink and how many events it is owed, counted up to 100,000. Nothing is stopped or removed. You have three choices:

  • Let the sinks take the events.
  • Move a sink past them by hand.
  • Delete anyway with force=true (hourctl tenant delete acme --yes --force). This loses the events.

The tenant’s own sinks go with it. They are no reason to refuse.

An API token belongs to the install, or it is scoped to one tenant of one engine. A token that belongs to the install reaches everything.

ScopeReaches
noneEverything, as the admin login does.
connect:<tenant>The tenant’s Connect routes, under /api/tenants/<tenant>/, including posting events into it.
attend:<tenant>The tenant’s Time and Attendance routes, under /api/attendance/tenants/<tenant>/, including its sinks and events.
Terminal window
hourctl token create acme-ops --scope connect:acme

When you revoke a token (hourctl token revoke acme-ops), the instance that revokes it refuses it at once. The others refuse it within 60 seconds.

The revoked token is kept in the list. It is flagged revoked, with when and by whom. Its name stays taken, so token:<name> in the audit trail always means one token. The trail’s entry for the revocation names the token, its scope, who made it and when it was last used.

A scoped token never reaches another tenant or an install-level route. It also never reaches what runs its own tenant. That covers the tenant’s record, suspend, resume, stop, delete, and its whole export or import, in either engine. Only an install token or the admin login makes tenants and tokens.

An attend:<tenant> token issues, lists and revokes its tenant’s delivery keys (hourctl -t acme attend delivery-keys). A delivery key is not a token. It only delivers punches into the tenant that issued it, at /api/attendance/tenants/<tenant>/deliveries. That route takes no token.

Under /api/tenants/ and /api/attendance/tenants/, the tenant and the route word after it must not be percent-encoded (400). A route word further on that is encoded names no route (404). Path parameters such as a device id or user id may be percent-encoded.

Every token starts hadv_, so a leaked one is easy to spot.

/metrics names tenants and their endpoints and sinks in its labels. Each sink’s label comes with its log, which is connect, or attend for Time and Attendance’s sinks. So /metrics is an install-level route. It needs the admin login or an install token, and it refuses a scoped token (403). Give Prometheus an install token:

scrape_configs:
- job_name: houradvantage
authorization:
credentials_file: /etc/prometheus/houradvantage-token
static_configs:
- targets: ["gateway-1:9090", "gateway-2:9090"]

If no admin login is set, /metrics answers on a loopback address. The whole admin API does the same. The probes (/livez, /api/health, /api/ready) need no login. See metrics.

Each tenant limit is optional.

Limit
devicesDevices it may have that are not waiting to be allowed. A new device beyond it is answered 429 and kept nowhere. A device added through the API is refused 409.
pending_devicesDevices it may have waiting to be allowed, across its endpoints. Each endpoint’s own max_pending_devices applies too.
peoplePeople its sync groups may keep, all groups together. A write through the API that would add one more is refused 422. Nothing a clock sends is refused for it. A person enrolled at a clock is kept and counts (over a limit).
messages_per_secondDevice messages a second its devices may send to one instance, all together. A message over it is answered 503 with Retry-After and not taken in.
packagesPolicy package lines ([email protected]) of its own it may keep. The limit is 50 unless the install’s default or its own limit says otherwise. A push of a line it does not have yet, past the limit, is refused 409. A new revision of a line it has is not refused. Each line keeps its newest five revisions and the active one. So the limit bounds what a tenant’s pushes take. Shared packages are the install’s and count for no tenant.
set_asideMQTT messages it may have set aside at once. The default is 10000, from limits.tenants.set_aside. Use 0 for no limit. One more message is held unacknowledged instead, and the broker keeps it.

The install’s defaults are limits.tenants in the admin settings (PATCH /api/settings, settings). A tenant’s own limits override them.

Counts hold across instances behind any load balancer. The message rate is per instance. A limit only refuses what has not been taken in. Nothing already acknowledged is dropped.

A tenant can go over its people limit without anything being refused. This can happen in three ways:

  • You lower the limit below the people the tenant has.
  • Clocks enroll people.
  • Two writes on two instances take the last place at the same moment.

Nobody is blocked or deleted for it. Instead, Connect sends the sync group’s event tenant.limit_reached once, when the tenant goes over. It says which limit, the limit (allowed) and the count.

One instance sends the event once per crossing. It does not send it again while the tenant stays over. It sends it again, with a new id, only after the tenant has been back within the limit. That happens when people are deleted, the limit is raised or removed, or a group is gone.

If people should be deleted or the tenant’s plan changed, do it in your own business logic, reacting to the event.

The other limits refuse at the door what would pass them, such as a new device or a message. So a device’s input never takes a tenant over them.

Tenants work behind any load balancer, with no affinity. Every instance serves every tenant, with the same setup.

An install can have tens of thousands of sinks across its tenants. Most of them are idle at any moment. Delivery cost follows what is delivered, not how many sinks exist. An idle sink costs nothing.

Each sink is delivered to by one instance at a time, in order. When an instance stops, others take over its sinks within seconds.

Sinks take turns. So one tenant’s backlog or a slow webhook does not hold up another tenant’s sinks for long.

A sink that refuses backs off on its own, up to a minute between tries. Its status says why. It is not disabled for refusing. A resumed tenant’s sinks try again at once.

The metrics houradvantage_sink_shards_held, houradvantage_sink_ready and houradvantage_sink_turns_total show delivery at work (metrics).

A shard is delivered to at once, with nothing to wait out, in two cases:

  • Its holder let it go because it stopped cleanly.
  • Nobody held it before, as when the first instance starts.

Sinks fall into 256 shards by a hash of their key. Each instance holds its share of the shards, which is the shards over the instances, rounded up. It holds them under a lease in the database. It takes up free shards. It lets surplus ones go when another instance starts. Holding them costs an instance one query a second, however many sinks there are.

An instance that dies loses its shards with its connection. The others take them up within a few seconds. Each waits out a delivery the one before may still have had under way.

Stored events wake only the sinks they may be for. Those are the sinks of the endpoints and kinds the events are of, and the install-level sinks. Another instance’s events wake the sinks here through its notes.

At most 128 deliveries are under way at once. Each is one batch of one sink. A sink with events goes to the back of the queue.

Time and Attendance’s sinks are delivered to the same way, from its own log. They have shards of their own, shared among the instances that run it.

Instances of an older version lease each sink, rather than a shard. They can share the database with the newer ones. While one of them is up, the others take each sink’s lease too before delivering to it. So two instances never deliver to one sink at once. To run only the older ones, stop the instances that hold shards first.

The instances of a cluster keep their own clocks. Keep them within a few seconds of each other. Use NTP, or what your platform runs, such as chrony, systemd-timesyncd or a cloud’s time service.

The instance that stores an event dates it. So an instance whose clock is minutes out dates its events minutes out.

Two things are claimed by comparing a stored time to the claiming instance’s clock. They are a policy hook that is owed and a message that is set aside. An instance running ahead takes up a claim early. One running behind takes it up late. Each is off by as much as its clock is out.

Retention counts days and is not sensitive to seconds.