{
  "components": {
    "parameters": {
      "IdempotencyKey": {
        "description": "Does the request once, however often it is sent with this key, for 24 hours: sent again with the same request, it is answered as it was the first time (`Idempotent-Replayed: true`); with another, 422; while the first runs still, 409.",
        "example": "0b6f1d3e-2c4a-4f8e-9a1b-7d5c3e2f1a09",
        "in": "header",
        "name": "Idempotency-Key",
        "required": false,
        "schema": {
          "maxLength": 255,
          "minLength": 1,
          "type": "string"
        }
      },
      "RequestId": {
        "description": "An id to follow the request by: answered back in `X-Request-Id`, and in the log, the audit trail and the events the request causes. 1 to 128 letters, digits, `-`, `_`, `.` or `:`; anything else is replaced by a new id.",
        "example": "4f1c2b0e-8a7d-4c51-9e2f-3a6b8d0c1e7f",
        "in": "header",
        "name": "X-Request-Id",
        "required": false,
        "schema": {
          "maxLength": 128,
          "pattern": "^[A-Za-z0-9._:-]+$",
          "type": "string"
        }
      }
    },
    "responses": {
      "Failed": {
        "content": {
          "application/json": {
            "example": {
              "error": "db error: ERROR: permission denied for table settings"
            },
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "Something went wrong in the gateway that asking again will not put right by itself; `error` says what."
      },
      "Forbidden": {
        "content": {
          "application/json": {
            "example": {
              "error": "the Host must name this machine (localhost or a loopback address); an API reached by other names needs the admin login"
            },
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          },
          "text/plain": {
            "example": "a forwarded request needs the admin login; none is set",
            "schema": {
              "type": "string"
            }
          }
        },
        "description": "The Host header does not name a loopback address while one is required (no login configured, or the API listens on loopback), or the Origin header does not match the Host: `{\"error\": ...}` says which. Or no login is configured and the request carries `Forwarded`, `X-Forwarded-For` or `X-Real-IP` (a proxy forwarded it): the plain text body says so. Or an API token asks for a route its scope does not reach: the plain text body says so."
      },
      "TooManyLogins": {
        "content": {
          "text/plain": {
            "example": "too many logins at once; try again",
            "schema": {
              "type": "string"
            }
          }
        },
        "description": "More than 2 admin logins are being checked at once: send the request again after the `Retry-After` seconds. A request carrying the login that checked out last, or an API token, is not held up.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait: 1.",
            "schema": {
              "type": "integer"
            }
          }
        }
      },
      "Unauthorized": {
        "content": {
          "text/plain": {
            "example": "the API token was refused",
            "schema": {
              "type": "string"
            }
          }
        },
        "description": "A login is configured and the request carries neither it nor an API token, or it carries a wrong login (`WWW-Authenticate: Basic realm=\"Hour Advantage\"`, no body). Or the request carries an API token that is not one (revoked, or never made), login or not (`WWW-Authenticate: Bearer realm=\"Hour Advantage\", error=\"invalid_token\"`, the body `the API token was refused`).",
        "headers": {
          "WWW-Authenticate": {
            "description": "The scheme to answer with: `Basic realm=\"Hour Advantage\"`, or for a refused token `Bearer realm=\"Hour Advantage\", error=\"invalid_token\"`.",
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "Unavailable": {
        "content": {
          "application/json": {
            "example": {
              "error": "the gateway is starting; try again shortly"
            },
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "description": "The database cannot be used right now (not reachable, too busy, no connection free in time), or the instance is still starting: send the same request again shortly. An API token that cannot be checked for the same reason is answered 503 in plain text (`the API token cannot be checked right now; try again shortly`)."
      }
    },
    "schemas": {
      "Abort": {
        "additionalProperties": false,
        "description": "Pauses the job when, once `after` devices have finished, `failed_percent`\nor more of those finished failed or timed out.",
        "properties": {
          "after": {
            "description": "How many devices must have finished (succeeded, failed or timed\nout) before the threshold is judged. 1 unless said.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "failed_percent": {
            "description": "The share of finished devices, 1 to 100 per cent, that failed or\ntimed out at which the job pauses.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "failed_percent"
        ],
        "type": "object"
      },
      "Action": {
        "description": "An action as it is kept, with its steps (the commands) in order.",
        "properties": {
          "action": {
            "description": "What was asked for: a standard action, a package action or one of\nthe package's commands.",
            "type": "string"
          },
          "created_at": {
            "description": "When it was queued.",
            "format": "date-time",
            "type": "string"
          },
          "expires_at": {
            "description": "Steps not handed to the device by then are cancelled. Absent when\nnone was given.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "failed_step": {
            "description": "The step that failed it, counted from 1.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "finished_at": {
            "description": "When it was done, failed, cancelled or timed out; null until then.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "gate_step": {
            "description": "The gate it stopped at, counted from 1: the gate failed, or the\naction was cancelled or timed out while waiting on it.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "id": {
            "description": "The action's id, unique across the gateway.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "lane": {
            "$ref": "#/components/schemas/Lane",
            "description": "The lane its steps queue in."
          },
          "origin": {
            "description": "Who queued it, when the gateway did: a sync group's actions say\n`sync:<group>:...`. Absent for actions queued through the API.",
            "type": [
              "string",
              "null"
            ]
          },
          "params": {
            "$ref": "#/components/schemas/Value",
            "description": "Its parameters, by name, sensitive values redacted (null when none\nwere given)."
          },
          "reason": {
            "description": "Why it stopped, for every action that failed, was cancelled or\ntimed out: the step it stopped at (counted from 1) and what became\nof it.",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "$ref": "#/components/schemas/ActionStatus"
          },
          "steps": {
            "description": "Its steps, in the order they go to the device.",
            "items": {
              "$ref": "#/components/schemas/Command"
            },
            "type": "array"
          }
        },
        "required": [
          "id",
          "action",
          "params",
          "status",
          "lane",
          "created_at",
          "steps"
        ],
        "type": "object"
      },
      "ActionCancelled": {
        "description": "What a cancel did: the steps taken back (they never go out) and those\nalready handed to the device (they report as usual).",
        "properties": {
          "already_sent": {
            "description": "The ids of the commands already handed to the device: they finish\nand report as usual.",
            "items": {
              "format": "int64",
              "minimum": 0,
              "type": "integer"
            },
            "type": "array"
          },
          "cancelled": {
            "description": "The ids of the commands taken back before they went out.",
            "items": {
              "format": "int64",
              "minimum": 0,
              "type": "integer"
            },
            "type": "array"
          },
          "id": {
            "description": "The action's id.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "status": {
            "$ref": "#/components/schemas/ActionStatus",
            "description": "Where it stands now."
          }
        },
        "required": [
          "id",
          "status",
          "cancelled",
          "already_sent"
        ],
        "type": "object"
      },
      "ActionInfo": {
        "description": "An action the package offers: a standard one (`GET /api/tenants/{tenant}/actions`), or\none of its own (`standard` false), which it expands into steps.",
        "properties": {
          "command": {
            "description": "The command that is the action, when it is one; otherwise the\npackage expands it into steps.",
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "description": "What the package says about how it does it, if anything.",
            "type": "string"
          },
          "name": {
            "description": "The action's name: what a request names to queue it.",
            "type": "string"
          },
          "params": {
            "description": "The parameters it takes, typed: for a standard action, standard\nones and the package's own (`x_...`); for the package's own action,\nthose it declares.",
            "items": {
              "$ref": "#/components/schemas/Param"
            },
            "type": "array"
          },
          "standard": {
            "description": "A standard action (true), or the package's own (false): a vendor\noperation such as a firmware upgrade, with its own parameters.",
            "type": "boolean"
          },
          "writes": {
            "description": "The sync domains it writes: the standard action's, or what the\npackage's own action declares.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "name",
          "standard",
          "params",
          "writes"
        ],
        "type": "object"
      },
      "ActionStarted": {
        "description": "An action queued: its id, its status and its steps' command ids, in order.",
        "properties": {
          "commands": {
            "description": "The ids of the commands its steps queued, in the order they run.",
            "items": {
              "format": "int64",
              "minimum": 0,
              "type": "integer"
            },
            "type": "array"
          },
          "id": {
            "description": "The action's id.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "status": {
            "$ref": "#/components/schemas/ActionStatus",
            "description": "Where it stands."
          }
        },
        "required": [
          "id",
          "status",
          "commands"
        ],
        "type": "object"
      },
      "ActionStatus": {
        "description": "Where an action stands: `queued` (no step handed to the device yet),\n`in_progress` (some steps handed out, nothing failed), `done` (every\nstep succeeded), `failed` (a step failed or went unanswered; the steps\nafter it not yet handed out were skipped), `cancelled` (cancelled\nbefore every step had gone out; those that had not were cancelled) or\n`timed_out` (its `expires_at` passed before every step had gone out or\npassed; those that had not were cancelled).",
        "enum": [
          "queued",
          "in_progress",
          "done",
          "failed",
          "cancelled",
          "timed_out"
        ],
        "type": "string"
      },
      "Activated": {
        "description": "What an activation did.",
        "properties": {
          "changed": {
            "description": "False when the revision was already the active one: nothing changed.",
            "type": "boolean"
          },
          "changes": {
            "description": "What changed, a line each: the revision made active, the packages\nadded and removed, and each endpoint that now uses another package.\nEmpty when nothing changed.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "line": {
            "description": "Its line: the name and major.minor version.",
            "type": "string"
          },
          "name": {
            "description": "The package's name.",
            "type": "string"
          },
          "revision": {
            "description": "The revision made active.",
            "format": "int32",
            "type": "integer"
          },
          "version": {
            "description": "That revision's version.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "line",
          "revision",
          "version",
          "changed",
          "changes"
        ],
        "type": "object"
      },
      "ActiveLine": {
        "description": "An active package line and what every instance runs of it.",
        "properties": {
          "activated_at": {
            "description": "When it was made the active one.",
            "format": "date-time",
            "type": "string"
          },
          "activated_by": {
            "description": "Who made it the active one: the admin login's user name,\n`token:<name>` for an API token, or `local` without a login.",
            "type": "string"
          },
          "hash": {
            "description": "The active revision's content hash, `sha256:<hex>`.",
            "type": "string"
          },
          "instances": {
            "description": "What each running instance runs of the line.",
            "items": {
              "$ref": "#/components/schemas/LineInstance"
            },
            "type": "array"
          },
          "line": {
            "description": "The line: the name and major.minor version (\"zk-push@3.4\").",
            "type": "string"
          },
          "revision": {
            "description": "The active revision.",
            "format": "int32",
            "type": "integer"
          }
        },
        "required": [
          "line",
          "revision",
          "hash",
          "activated_at",
          "activated_by",
          "instances"
        ],
        "type": "object"
      },
      "ActiveRevision": {
        "description": "The revision active for a package line.",
        "properties": {
          "activated_at": {
            "description": "When it was made the active one.",
            "format": "date-time",
            "type": "string"
          },
          "activated_by": {
            "description": "Who made it the active one: the admin login's user name,\n`token:<name>` for an API token, or `local` without a login.",
            "type": "string"
          },
          "hash": {
            "description": "The revision's content hash, `sha256:<hex>`.",
            "type": "string"
          },
          "revision": {
            "description": "The revision number, counted per package name from 1.",
            "format": "int32",
            "type": "integer"
          },
          "version": {
            "description": "The package version the revision holds; null if the revision is not\namong those kept.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "revision",
          "hash",
          "activated_at",
          "activated_by"
        ],
        "type": "object"
      },
      "Adopt": {
        "additionalProperties": false,
        "description": "How a tenant adopts a package.",
        "properties": {
          "version": {
            "description": "A major version to follow (`\"2\"`: each version of it published\nreaches the tenant), or a version to pin (`\"2.3.1\"`).",
            "example": "2",
            "type": "string"
          }
        },
        "required": [
          "version"
        ],
        "type": "object"
      },
      "AdoptedPackage": {
        "description": "A shared package a tenant adopted, and the version it takes now.",
        "properties": {
          "adopted": {
            "description": "What the tenant adopted: a major version it follows (`2`) or the\nversion it pins (`2.3.1`).",
            "type": "string"
          },
          "follows": {
            "description": "True when it follows a major version: each version of it published\nreaches the tenant. False: pinned.",
            "type": "boolean"
          },
          "name": {
            "description": "The shared package's name.",
            "type": "string"
          },
          "version": {
            "description": "The version it takes now: the newest of the major version followed,\nor the version pinned. Null when no such version is published.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "name",
          "adopted",
          "follows"
        ],
        "type": "object"
      },
      "AdoptedView": {
        "description": "A package the tenant adopted, as Connect shows one, with the versions\nin force by it.",
        "properties": {
          "adopted": {
            "description": "What the tenant adopted: a major version it follows (`2`) or the\nversion it pins (`2.3.1`).",
            "type": "string"
          },
          "follows": {
            "description": "True when it follows a major version: each version of it published\nreaches the tenant. False: pinned.",
            "type": "boolean"
          },
          "held": {
            "description": "Set when a newer version needs what the tenant has not set up, so\nit stays on `version`: `held at 1.0.0: version 1.1.0 needs accrual\ncategory rtt`. It moves on once that is set up. Absent: not held.",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "description": "The package's name.",
            "type": "string"
          },
          "shared": {
            "description": "Whether it is a shared package (else the tenant's own).",
            "type": "boolean"
          },
          "version": {
            "description": "The version it takes now: the highest it admits of those published.\nNull when none is.",
            "type": [
              "string",
              "null"
            ]
          },
          "versions": {
            "description": "The versions in force by it, each from a workday (null: the\nbeginning).",
            "items": {
              "$ref": "#/components/schemas/InForce"
            },
            "type": "array"
          }
        },
        "required": [
          "name",
          "adopted",
          "follows",
          "shared",
          "versions"
        ],
        "type": "object"
      },
      "Advance": {
        "description": "When a job moves to its next wave: `auto` (once every device of the\ncurrent wave succeeded) or `manual` (only when told).",
        "enum": [
          "auto",
          "manual"
        ],
        "type": "string"
      },
      "Alive": {
        "description": "Whether an instance works, as anyone may ask (`GET /api/health`, with no\nlogin): nothing of which instance, version or environment it is.",
        "properties": {
          "ok": {
            "description": "It takes work (`ready`) and its database answers.",
            "type": "boolean"
          },
          "ready": {
            "description": "It takes work: what `GET /api/ready` answers 200 for.",
            "type": "boolean"
          },
          "starting": {
            "description": "True while the instance starts (reaches its database, migrates it,\nloads its devices); absent once it has started.",
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "required": [
          "ok"
        ],
        "type": "object"
      },
      "Answer_LeaveRecorded": {
        "description": "What a write that can be previewed answers: what it did, or with\n`?preview=true`, what it would change (`PreviewView`).",
        "oneOf": [
          {
            "description": "The request recorded.",
            "properties": {
              "id": {
                "type": "string"
              },
              "recorded": {
                "description": "new, or already (the same was recorded before).",
                "type": "string"
              }
            },
            "required": [
              "id",
              "recorded"
            ],
            "type": "object"
          },
          {
            "$ref": "#/components/schemas/PreviewView"
          }
        ]
      },
      "Answer_NoteView": {
        "description": "What a write that can be previewed answers: what it did, or with\n`?preview=true`, what it would change (`PreviewView`).",
        "oneOf": [
          {
            "description": "The note recorded.",
            "properties": {
              "id": {
                "type": "string"
              },
              "recorded": {
                "description": "new, or already (the same note was recorded before).",
                "type": "string"
              }
            },
            "required": [
              "id",
              "recorded"
            ],
            "type": "object"
          },
          {
            "$ref": "#/components/schemas/PreviewView"
          }
        ]
      },
      "Answer_RecordedView": {
        "description": "What a write that can be previewed answers: what it did, or with\n`?preview=true`, what it would change (`PreviewView`).",
        "oneOf": [
          {
            "description": "What came of recording each fact.",
            "properties": {
              "recorded": {
                "description": "For each fact, in order: `new`, or `already` (the same fact was\nrecorded before; nothing changed).",
                "items": {
                  "type": "string"
                },
                "type": "array"
              }
            },
            "required": [
              "recorded"
            ],
            "type": "object"
          },
          {
            "$ref": "#/components/schemas/PreviewView"
          }
        ]
      },
      "ApiToken": {
        "description": "A named admin API token, as kept: never the token itself, only its\nSHA-256.",
        "properties": {
          "created_at": {
            "description": "When it was made.",
            "format": "date-time",
            "type": "string"
          },
          "created_by": {
            "description": "Who made it: the admin login's user name, `token:<name>` for another\ntoken, or `local` without a login.",
            "type": "string"
          },
          "last_used_at": {
            "description": "When it was last used, written at most once a minute per instance;\nnull if it never was.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "description": "Its name, unique: what it is for.",
            "type": "string"
          },
          "revoked": {
            "description": "Whether it was revoked: a revoked token is refused wherever it is\npresented, and is kept, with its name, so that the audit trail's\n`token:<name>` still says which token it was.",
            "type": "boolean"
          },
          "revoked_at": {
            "description": "When it was revoked.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "revoked_by": {
            "description": "Who revoked it, as `created_by` says.",
            "type": [
              "string",
              "null"
            ]
          },
          "scope": {
            "description": "What it reaches: empty for the whole install (an install token);\n`connect:<tenant>` for one Connect tenant's routes only\n(`/api/tenants/<tenant>/...`); `attend:<tenant>` for one Time and\nAttendance tenant's only (`/api/attendance/tenants/<tenant>/...`).",
            "type": "string"
          }
        },
        "required": [
          "name",
          "created_at",
          "created_by"
        ],
        "type": "object"
      },
      "AuditEntry": {
        "description": "One change made through the admin API, or one the gateway made itself: written before the change is made, and finished once it\nhas been (`outcome`).",
        "properties": {
          "action": {
            "description": "The request's method and path: \"POST /api/sinks\"; for a change the\ngateway made itself, its name for it (\"job.paused\") and the user is\n`houradvantage`.",
            "type": "string"
          },
          "at": {
            "description": "When the change was made.",
            "format": "date-time",
            "type": "string"
          },
          "body": {
            "description": "The request body, as JSON text, with passwords, keys and secrets\ntaken out and sensitive values kept only as their size; the first\n64 KiB of it at most, a longer one cut and ended with `...[cut: N of M bytes\nkept]`. Absent when there was none, or for a secret.",
            "type": [
              "string",
              "null"
            ]
          },
          "client": {
            "description": "The address the request came from: the connection's, or, when that\nis one of the `trusted_proxies`, the address it forwarded. Absent\nfor a change the gateway made itself.",
            "type": [
              "string",
              "null"
            ]
          },
          "instance": {
            "description": "The gateway instance that made it.",
            "type": "string"
          },
          "outcome": {
            "$ref": "#/components/schemas/AuditOutcome",
            "description": "How far the change got: `started` (it may have happened: the entry was written before it, and not finished), `done` or\n`failed`. Entries from before outcomes were kept are `done`."
          },
          "request_id": {
            "description": "The id of the admin API request that made it (its `X-Request-Id`).\nAbsent for a change the gateway made itself.",
            "type": [
              "string",
              "null"
            ]
          },
          "seq": {
            "description": "Its number in the trail, higher for every later entry.",
            "format": "int64",
            "type": "integer"
          },
          "status": {
            "description": "The HTTP status the request was answered with, once it was; absent for one still `started`, and for a change the\ngateway made itself.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "summary": {
            "description": "What it did, in a few words: \"sink 'payroll' added\".",
            "type": "string"
          },
          "tenant": {
            "description": "The tenant the request named in its path (`/api/tenants/<t>/...` or\n`/api/attendance/tenants/<t>/...`). Absent for an install-level\nchange and for the engine's own.",
            "type": [
              "string",
              "null"
            ]
          },
          "user": {
            "description": "Who made it: the admin login's user name, `token:<name>` for an API\ntoken, or `local` when no login is configured.",
            "type": "string"
          }
        },
        "required": [
          "seq",
          "at",
          "instance",
          "user",
          "action",
          "summary",
          "outcome"
        ],
        "type": "object"
      },
      "AuditOutcome": {
        "description": "How far an audited change got (`AuditEntry::outcome`).",
        "enum": [
          "started",
          "done",
          "failed"
        ],
        "type": "string"
      },
      "AuditPage": {
        "description": "A page of the audit trail.",
        "properties": {
          "entries": {
            "description": "The entries, oldest first.",
            "items": {
              "$ref": "#/components/schemas/AuditEntry"
            },
            "type": "array"
          },
          "next": {
            "description": "The `seq` of the last entry on the page, or the `after` asked for\nwhen the page is empty: pass it as `after` for the next page.",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "entries",
          "next"
        ],
        "type": "object"
      },
      "Authority": {
        "description": "Who is the source of authority for a domain's data.",
        "enum": [
          "group",
          "shared"
        ],
        "type": "string"
      },
      "BTreeMap": {
        "additionalProperties": {
          "type": "string"
        },
        "propertyNames": {
          "type": "string"
        },
        "type": "object"
      },
      "BalanceChange": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Delta"
          },
          {
            "properties": {
              "category": {
                "description": "The accrual category.",
                "type": "string"
              }
            },
            "required": [
              "category"
            ],
            "type": "object"
          }
        ],
        "description": "An accrual balance at the period's end, as a duration, before and after."
      },
      "Batch": {
        "additionalProperties": false,
        "description": "Changes to make in one transaction: 1 to 10000 in all.",
        "properties": {
          "delete": {
            "description": "Rows to delete, after the upserts. Default: none.",
            "items": {
              "$ref": "#/components/schemas/BatchDelete"
            },
            "type": "array"
          },
          "upsert": {
            "description": "Rows to add or change, in order. Default: none.",
            "items": {
              "$ref": "#/components/schemas/BatchUpsert"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "BatchDelete": {
        "additionalProperties": false,
        "description": "A row to delete in a batch.",
        "properties": {
          "domain": {
            "description": "The row's domain: people, access, lists or settings.",
            "type": "string"
          },
          "if_version": {
            "description": "Delete only if the row is still at this version; otherwise the\nwhole batch is refused.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "key": {
            "description": "The row's key, as for an upsert.",
            "type": "string"
          },
          "kind": {
            "description": "The row's kind, as for an upsert.",
            "type": "string"
          }
        },
        "required": [
          "domain",
          "kind",
          "key"
        ],
        "type": "object"
      },
      "BatchUpsert": {
        "additionalProperties": false,
        "description": "A row to add or change in a batch.",
        "properties": {
          "domain": {
            "description": "The row's domain: people, access, lists or settings.",
            "type": "string"
          },
          "fields": {
            "description": "The row's fields: those given are set, `null` clears one, those left\nout stay as they are. Default: none.",
            "type": "object"
          },
          "if_version": {
            "description": "Write only if the row is still at this version (0: only if the\nregistry has no such row); otherwise the whole batch is refused.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "key": {
            "description": "The row's key: a person's user id, an access row's or list item's\nkey, or for a setting `<class>/<name>`. At most 128 characters: a\nrow's key is indexed, and a longer one is refused (400).",
            "type": "string"
          },
          "kind": {
            "description": "The row's kind: `person` for people, `setting` for settings, a kind\nof access row (schedule, holiday, access_group, zone) or a list\n(work_code, job_code, tip_code, message).",
            "type": "string"
          },
          "secrets": {
            "description": "A person's secrets (`keypad_pin`, `password`): write-only, `null`\nclears one.",
            "type": [
              "object",
              "null"
            ]
          }
        },
        "required": [
          "domain",
          "kind",
          "key"
        ],
        "type": "object"
      },
      "BiometricsSet": {
        "description": "What setting a person's biometrics flag did.",
        "properties": {
          "allow_biometrics": {
            "description": "Whether the person may have biometrics now.",
            "type": "boolean"
          },
          "user_id": {
            "description": "The person's user id.",
            "type": "string"
          },
          "withdrawn": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Withdrawn",
                "description": "Present when this withdrew them (allowed before, not now): what\nwent, and the deletes queued on the group's devices."
              }
            ]
          }
        },
        "required": [
          "user_id",
          "allow_biometrics"
        ],
        "type": "object"
      },
      "BiometricsView": {
        "description": "A person's biometrics flag in a group.",
        "properties": {
          "allow_biometrics": {
            "description": "`false`: refused. A person the group has no flag for is allowed.",
            "type": "boolean"
          },
          "user_id": {
            "description": "The person's user id.",
            "type": "string"
          }
        },
        "required": [
          "user_id",
          "allow_biometrics"
        ],
        "type": "object"
      },
      "CallerLane": {
        "description": "The lanes an API caller may ask for: `interactive` (the default: what\nan operator or an API caller asked for) or `bulk` (large fills such as\nbackfill, inventory or resync, which go after everything else).\n`urgent` and `sync` are the gateway's own: the sync engine queues in\nthem, and a request that names one is refused.",
        "enum": [
          "interactive",
          "bulk"
        ],
        "type": "string"
      },
      "CategoryTotal": {
        "description": "The time of a pay category.",
        "properties": {
          "category": {
            "type": "string"
          },
          "code": {
            "description": "The code payroll knows it by, where the setup names one.",
            "type": [
              "string",
              "null"
            ]
          },
          "hours": {
            "description": "Its decimal hours: the sum of its lines'.",
            "example": "8.00",
            "type": "string"
          },
          "paid": {
            "description": "Whether its time is paid. Absent where the category is not known\n(a total of lines kept before the setup named it): paid.",
            "type": "boolean"
          },
          "time": {
            "description": "Its exact time.",
            "example": "8h",
            "type": "string"
          },
          "worked": {
            "description": "Whether its time counts as worked.",
            "type": "boolean"
          }
        },
        "required": [
          "category",
          "hours",
          "time",
          "paid",
          "worked"
        ],
        "type": "object"
      },
      "ChangeId": {
        "additionalProperties": false,
        "properties": {
          "allow_reenroll": {
            "description": "Go ahead on members that may hold templates the group does not\nhave (they would have to be enrolled again). Without it the change\nis refused on those members, and the old user stays.",
            "type": "boolean"
          },
          "new_user_id": {
            "description": "The id the person is to have: not empty, and not the id they have.",
            "example": "1101",
            "type": "string"
          }
        },
        "required": [
          "new_user_id"
        ],
        "type": "object"
      },
      "ClockBody": {
        "additionalProperties": false,
        "description": "A clock to make, or what to change of one.",
        "properties": {
          "external_ids": {
            "type": [
              "object",
              "null"
            ]
          },
          "id": {
            "description": "Its id (to make one; a change keeps it).",
            "type": [
              "string",
              "null"
            ]
          },
          "labels": {
            "type": [
              "object",
              "null"
            ]
          },
          "location": {
            "description": "null takes it away.",
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "type": [
              "object",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "values": {
            "description": "Given, they replace all it had.",
            "type": [
              "object",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "ClockShiftBody": {
        "additionalProperties": false,
        "description": "What a shift asks.",
        "properties": {
          "by_seconds": {
            "description": "By how many seconds to move each punch (later if positive, earlier if negative). Give this or `undo`.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "from": {
            "description": "The first instant: a time (RFC 3339), or a date, the start of that day in the zone of the clock's location\n(a clock with no location takes a time only).",
            "type": "string"
          },
          "id": {
            "description": "A name for this request (letters, digits and `-`, at most 64): part of each of its corrections' ids, and what a\nlater request names to take it back. A request asked again with the same id changes nothing it did already, so\nthe runs of one shift (see `complete`) give it the same id. One is made up when it is left out.",
            "type": [
              "string",
              "null"
            ]
          },
          "reason": {
            "description": "Why, for the audit trail and each punch's correction.",
            "type": [
              "string",
              "null"
            ]
          },
          "to": {
            "description": "The end of the range, not included: a time or a date as `from`.",
            "type": "string"
          },
          "undo": {
            "description": "The id of a shift to take back: each punch it moved goes to the instant it was made, unless another correction\nhas moved it since. Give this or `by_seconds`.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "from",
          "to"
        ],
        "type": "object"
      },
      "ClockShiftView": {
        "description": "What a shift did, or, previewed, would do.",
        "properties": {
          "by_seconds": {
            "description": "By how many seconds each punch was moved; none when a shift was taken back.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "clock": {
            "description": "The clock's device id.",
            "type": "string"
          },
          "complete": {
            "description": "False when one run's most was reached: ask again, with the same `id`, for the rest.",
            "type": "boolean"
          },
          "done_before": {
            "description": "Those this very request moved in an earlier run (the next run of a long shift, or the request asked again).",
            "minimum": 0,
            "type": "integer"
          },
          "first": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "from": {
            "example": "2026-03-09T00:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "The request's id (in its corrections' ids); none for a preview.",
            "type": [
              "string",
              "null"
            ]
          },
          "last": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "left": {
            "description": "Those left as they are: another correction had moved or voided them, or the shift to take back was not the\nlast thing done to them.",
            "minimum": 0,
            "type": "integer"
          },
          "looked_at": {
            "description": "The clock's punches in the range that were looked at.",
            "minimum": 0,
            "type": "integer"
          },
          "people": {
            "description": "The persons they are kept under, worked out again from the punch's workday.",
            "minimum": 0,
            "type": "integer"
          },
          "preview": {
            "description": "True for a preview: nothing was changed.",
            "type": "boolean"
          },
          "shifted": {
            "description": "Those moved (or that would be).",
            "minimum": 0,
            "type": "integer"
          },
          "to": {
            "example": "2026-03-14T00:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "undo": {
            "description": "The shift that was taken back.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "clock",
          "from",
          "to",
          "preview",
          "looked_at",
          "shifted",
          "done_before",
          "left",
          "people",
          "complete"
        ],
        "type": "object"
      },
      "ClockView": {
        "description": "A clock record.",
        "properties": {
          "created": {
            "example": "2026-10-01T14:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "external_ids": {
            "type": "object"
          },
          "id": {
            "description": "The device id its punches carry: 1 to 64 characters.",
            "type": "string"
          },
          "labels": {
            "type": "object"
          },
          "location": {
            "description": "The id of the work location it hangs at.",
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "type": "object"
          },
          "name": {
            "type": "string"
          },
          "values": {
            "description": "The labor context values work punched here takes where the person keyed none.",
            "type": "object"
          }
        },
        "required": [
          "id",
          "name",
          "values",
          "labels",
          "external_ids",
          "metadata",
          "created"
        ],
        "type": "object"
      },
      "Command": {
        "description": "A command: one message the package builds for a device, queued, handed\nout and answered. Parameters the package marks sensitive are shown as\n`<redacted N bytes>`, and so is the payload that carries them.",
        "properties": {
          "action": {
            "description": "The package command it is (its key among the package's commands).",
            "type": "string"
          },
          "action_id": {
            "description": "The action it is a step of, if it is one.",
            "format": "int64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "completed_at": {
            "description": "When it finished (answered, cancelled or skipped); null until then.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "description": "When it was queued.",
            "format": "date-time",
            "type": "string"
          },
          "expires_at": {
            "description": "Not handed out by then, it never is.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "gate": {
            "description": "A gate of its action: handed out on its own, and the steps after it\nwait for it to succeed.",
            "type": "boolean"
          },
          "id": {
            "description": "The command's id, unique across the gateway.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "lane": {
            "$ref": "#/components/schemas/Lane",
            "description": "The lane it queues in."
          },
          "params": {
            "description": "Its parameters, by name, sensitive values redacted.",
            "type": "object"
          },
          "payload": {
            "description": "What the device is handed, as text (\"\" when it is not text).",
            "type": "string"
          },
          "payload_base64": {
            "description": "What the device is handed, base64-encoded, when it is not text.",
            "type": [
              "string",
              "null"
            ]
          },
          "result": {
            "description": "What the device answered, as text; null until it answers.",
            "type": [
              "string",
              "null"
            ]
          },
          "result_base64": {
            "description": "The result, base64-encoded, when the device returned something that\nis not text.",
            "type": [
              "string",
              "null"
            ]
          },
          "result_code": {
            "description": "The code the device answered with, as the package reads it; null\nuntil it answers.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "retry_at": {
            "description": "Parked until then: the device answered \"not yet, ask again\".",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "sent_at": {
            "description": "When it was handed to the device; null until then.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "$ref": "#/components/schemas/CommandStatus"
          },
          "tries": {
            "description": "How many times it has been handed to the device (more than once\nwhen the device answered \"not yet, ask again\").",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "id",
          "action",
          "params",
          "payload",
          "status",
          "created_at",
          "lane"
        ],
        "type": "object"
      },
      "CommandInfo": {
        "description": "A command the package declares: what it does, the parameters it takes,\nand what it writes on the device.",
        "properties": {
          "description": {
            "description": "What it does.",
            "type": "string"
          },
          "implements": {
            "description": "The standard action this command is, if it is one: it takes the\nstandard parameters (`GET /api/tenants/{tenant}/actions`).",
            "type": [
              "string",
              "null"
            ]
          },
          "internal": {
            "description": "Only a step of the package's own actions: never sent by name.",
            "type": "boolean"
          },
          "key": {
            "description": "Its name: what an action names to send it.",
            "type": "string"
          },
          "params": {
            "description": "The parameters it takes, typed.",
            "items": {
              "$ref": "#/components/schemas/Param"
            },
            "type": "array"
          },
          "quick": {
            "description": "Worth a one-click button: a hint for user interfaces.",
            "type": "boolean"
          },
          "sensitive_result": {
            "description": "What the device answers may be sensitive (a file holding every\nuser, say): once the `command.result` event carrying it is stored,\nthe command keeps only its size.",
            "type": "boolean"
          },
          "success": {
            "$ref": "#/components/schemas/Success",
            "description": "Which result codes mean the command succeeded, unless the package\nsays so itself."
          },
          "title": {
            "description": "A short name for people.",
            "type": "string"
          },
          "writes": {
            "description": "The sync domains it writes on the device (`people`, `access`,\n`lists`, `settings`, `punches`); empty for reads and device\noperations. A command that implements a standard action writes what\nthat action writes.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "key",
          "title",
          "description",
          "params",
          "writes",
          "quick",
          "success",
          "sensitive_result"
        ],
        "type": "object"
      },
      "CommandStatus": {
        "description": "Where a command stands: `queued` (waiting to be handed to the device),\n`offered` (written into a reply to the device, no result yet), `succeeded`, `failed`,\n`unanswered` (offered, then lost: the device answered a command handed out after it, and\nit had been handed out twice; a result that comes later still completes it),\n`cancelled` (taken back before it was handed out: its action was\ncancelled or expired), `skipped` (an earlier step of its action failed\nbefore it was handed out) or `parked` (waiting behind a gate of its\naction that has not passed, or asked to be sent again later:\n`retry_at`).",
        "enum": [
          "queued",
          "offered",
          "succeeded",
          "failed",
          "unanswered",
          "cancelled",
          "skipped",
          "parked"
        ],
        "type": "string"
      },
      "Commands": {
        "additionalProperties": false,
        "description": "`[commands]` in package.toml: how a device answers the commands it is handed. The gateway decides nothing from how long\nan answer takes; it concludes only what the package says an answer means.",
        "properties": {
          "missed_hand": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/MissedHand",
                "description": "What `M.missed` is given as `in_hand` for a message that carries results, when the package needs less than the whole\nhand: the slice it declares. A message on a `missed_on` route, and every message of a package that declares nothing,\ngets the whole hand. The package says the slice is enough; the engine does not know what \"missed\" means."
              }
            ]
          },
          "missed_on": {
            "description": "The routes whose requests the package's `M.missed(req, in_hand, answered)` is asked about even when they carry\nno result, while commands are in the device's hand: a request that means the device lost what it held (it\nrestarted). A message that carries results is asked about whichever its route. Any other message costs nothing.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "reply": {
            "$ref": "#/components/schemas/ReplyLimits",
            "description": "What one reply to the device may carry of its commands. Declared, the gateway queues no more commands for a\ndevice than a reply carries (a device that is away holds that many waiting, never more), and `queue.pending` cuts\na reply at these numbers when the package gives none of its own."
          },
          "resend": {
            "$ref": "#/components/schemas/Resend",
            "description": "Which commands the gateway may hand out once more when one is lost."
          },
          "resend_times": {
            "description": "How many times a lost command that `resend` allows is handed out again, at most; one handed out again that many times\nand lost once more ends unanswered. Declared with `resend = \"writes\"`, and only with it.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "CostView": {
        "description": "What the shifts would add to one person's pay.",
        "properties": {
          "added": {
            "description": "Why: the ledger lines the shifts add and take away (time an earlier\nline had in one category and has in another now: the overtime they\ntip a week into), each with what the policy's steps did to it.",
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "added_quantities": {
            "description": "The counts and money lines they add and take away (a premium paid\nas money, the pay for the hours).",
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "error": {
            "description": "Why they cannot be estimated (no zone set up for them, a policy\nstep failing); the rest is then absent.",
            "type": [
              "string",
              "null"
            ]
          },
          "exceptions": {
            "description": "The exceptions they would raise.",
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "hours": {
            "additionalProperties": {
              "type": "string"
            },
            "description": "The decimal hours each pay category changes by (negative: fewer),\nonly those that change; `paid_hours`, those in paid categories in all.",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "money": {
            "description": "The money each category changes by; absent where the person has no\nrates set up: only time is said.",
            "items": {
              "$ref": "#/components/schemas/MoneyView"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "paid_hours": {
            "type": "string"
          },
          "person": {
            "type": "string"
          },
          "refused": {
            "description": "The leave requests they would have the policy refuse.",
            "items": {
              "$ref": "#/components/schemas/RefusedView"
            },
            "type": "array"
          },
          "removed": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "removed_quantities": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "total_money": {
            "items": {
              "$ref": "#/components/schemas/MoneyView"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "worked": {
            "description": "The time in categories that count as worked.",
            "type": "string"
          }
        },
        "required": [
          "person"
        ],
        "type": "object"
      },
      "Counts": {
        "description": "How many devices of a job are in each state.",
        "properties": {
          "cancelled": {
            "description": "Devices cancelled: with the job, or their action was cancelled.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "failed": {
            "description": "Devices whose action failed or could not be started.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "queued": {
            "description": "Devices whose wave has not started, or that wait for room.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "running": {
            "description": "Devices whose action is started.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "succeeded": {
            "description": "Devices whose action succeeded.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "timed_out": {
            "description": "Devices whose action did not finish within the job's timeout.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "waiting_window": {
            "description": "Devices whose turn it is, waiting for their window to open.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "queued",
          "waiting_window",
          "running",
          "succeeded",
          "failed",
          "timed_out",
          "cancelled"
        ],
        "type": "object"
      },
      "Coverage": {
        "description": "Which of a package's routes (inbound messages), commands (outbound) and\nstandard actions are exercised by a passing, asserted scenario step.",
        "properties": {
          "actions": {
            "description": "Every action it offers.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "actions_covered": {
            "description": "The actions whose commands a passing step asserted.",
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": true
          },
          "commands": {
            "description": "Every command it declares.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "commands_covered": {
            "description": "The commands a passing step asserted the output of.",
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": true
          },
          "package": {
            "description": "The package, \"name@version\".",
            "type": "string"
          },
          "routes": {
            "description": "Every route it declares.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "routes_covered": {
            "description": "The routes a passing, asserted step exercised.",
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": true
          },
          "sync": {
            "description": "What the package's `M.sync` declares that a scenario must show:\neach domain (`domain people`) and each event type its `report`\nentries promise (`event user.deleted`).",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "sync_covered": {
            "description": "The entries of `sync` a passing scenario showed.",
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": [
          "package",
          "routes",
          "routes_covered",
          "commands",
          "commands_covered",
          "actions",
          "actions_covered",
          "sync",
          "sync_covered"
        ],
        "type": "object"
      },
      "CreatedToken": {
        "allOf": [
          {
            "description": "A named admin API token, as kept: never the token itself, only its\nSHA-256.",
            "properties": {
              "created_at": {
                "description": "When it was made.",
                "format": "date-time",
                "type": "string"
              },
              "created_by": {
                "description": "Who made it: the admin login's user name, `token:<name>` for another\ntoken, or `local` without a login.",
                "type": "string"
              },
              "last_used_at": {
                "description": "When it was last used, written at most once a minute per instance;\nnull if it never was.",
                "format": "date-time",
                "type": [
                  "string",
                  "null"
                ]
              },
              "name": {
                "description": "Its name, unique: what it is for.",
                "type": "string"
              },
              "revoked": {
                "description": "Whether it was revoked: a revoked token is refused wherever it is\npresented, and is kept, with its name, so that the audit trail's\n`token:<name>` still says which token it was.",
                "type": "boolean"
              },
              "revoked_at": {
                "description": "When it was revoked.",
                "format": "date-time",
                "type": [
                  "string",
                  "null"
                ]
              },
              "revoked_by": {
                "description": "Who revoked it, as `created_by` says.",
                "type": [
                  "string",
                  "null"
                ]
              },
              "scope": {
                "description": "What it reaches: empty for the whole install (an install token);\n`connect:<tenant>` for one Connect tenant's routes only\n(`/api/tenants/<tenant>/...`); `attend:<tenant>` for one Time and\nAttendance tenant's only (`/api/attendance/tenants/<tenant>/...`).",
                "type": "string"
              }
            },
            "required": [
              "name",
              "created_at",
              "created_by"
            ],
            "type": "object"
          },
          {
            "properties": {
              "token": {
                "description": "The secret, to send as `Authorization: Bearer <token>`: `hadv_` and\n43 more characters. It cannot be shown again: only its hash is kept.",
                "type": "string"
              }
            },
            "required": [
              "token"
            ],
            "type": "object"
          }
        ],
        "description": "A token just made: the only time its secret is shown."
      },
      "DayView": {
        "description": "One day.",
        "properties": {
          "date": {
            "example": "2026-10-05",
            "type": "string"
          },
          "exceptions": {
            "description": "The exceptions about it, each as the ledger keeps it: `kind`, `at`,\n`about`, `detail`, and how it was followed up.",
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "holidays": {
            "items": {
              "$ref": "#/components/schemas/HolidayView"
            },
            "type": "array"
          },
          "kept": {
            "description": "Its period's ledger is kept: false, the day is as scheduled, with no\ntime (it is ahead, or not worked out yet).",
            "type": "boolean"
          },
          "leave": {
            "description": "The leave asked for on it, with where each request stands.",
            "items": {
              "$ref": "#/components/schemas/LeaveDayView"
            },
            "type": "array"
          },
          "lines": {
            "description": "Its lines, in the order they are paid.",
            "items": {
              "$ref": "#/components/schemas/LineView"
            },
            "type": "array"
          },
          "off": {
            "description": "off, leave or holiday, where a schedule override took the day off.",
            "type": [
              "string",
              "null"
            ]
          },
          "period": {
            "$ref": "#/components/schemas/PeriodSpan",
            "description": "The pay period it is in."
          },
          "punches": {
            "description": "The punches whose workday it is, in the order punched.",
            "items": {
              "$ref": "#/components/schemas/PunchView"
            },
            "type": "array"
          },
          "quantities": {
            "items": {
              "$ref": "#/components/schemas/QuantityView"
            },
            "type": "array"
          },
          "recorded_after_close": {
            "description": "Facts about the day stored after its period was closed, where it is:\nthe day above is as the close kept it, so these are not among its\npunches or in its lines. Each was a late change, taken in the period\nopen when it was stored (`stored_workday`), as an adjustment line on\nthat day or a `late_change_refused` exception about it, by the\npolicy's `close.late_changes`. Absent where there are none.",
            "items": {
              "$ref": "#/components/schemas/LateFactView"
            },
            "type": "array"
          },
          "shifts": {
            "description": "The shifts scheduled to start in it.",
            "items": {
              "$ref": "#/components/schemas/ShiftView"
            },
            "type": "array"
          },
          "totals": {
            "$ref": "#/components/schemas/Totals"
          },
          "zone": {
            "description": "The time zone its times are in (its IANA name).",
            "example": "America/Chicago",
            "type": "string"
          }
        },
        "required": [
          "date",
          "zone",
          "period",
          "kept",
          "shifts",
          "holidays",
          "leave",
          "lines",
          "quantities",
          "punches",
          "exceptions",
          "totals"
        ],
        "type": "object"
      },
      "DaysPage": {
        "description": "A page of people's days.",
        "properties": {
          "from": {
            "example": "2026-10-01",
            "type": "string"
          },
          "next": {
            "description": "Pass as `after` for the next page; null: there is none.",
            "type": [
              "string",
              "null"
            ]
          },
          "people": {
            "description": "Each person's, by person.",
            "items": {
              "$ref": "#/components/schemas/PersonDays"
            },
            "type": "array"
          },
          "side": {
            "type": "string"
          },
          "to": {
            "example": "2026-10-31",
            "type": "string"
          }
        },
        "required": [
          "side",
          "from",
          "to",
          "people"
        ],
        "type": "object"
      },
      "DaysView": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PersonDays"
          },
          {
            "properties": {
              "from": {
                "example": "2026-10-01",
                "type": "string"
              },
              "side": {
                "type": "string"
              },
              "to": {
                "example": "2026-10-31",
                "type": "string"
              }
            },
            "required": [
              "side",
              "from",
              "to"
            ],
            "type": "object"
          }
        ],
        "description": "A person's days from `from` through `to`."
      },
      "Deleted": {
        "description": "What deleting a tenant did.",
        "properties": {
          "removed": {
            "$ref": "#/components/schemas/Purged",
            "description": "What of its was removed."
          },
          "revoked_tokens": {
            "description": "The names of the tokens scoped to it (`connect:<tenant>`), revoked.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "tenant": {
            "$ref": "#/components/schemas/TenantConfig",
            "description": "The tenant, as it was."
          }
        },
        "required": [
          "tenant",
          "removed",
          "revoked_tokens"
        ],
        "type": "object"
      },
      "Delivered": {
        "description": "What a delivery came to.",
        "properties": {
          "punches": {
            "description": "The readable punches in it, each recorded (or kept as it was, sent\nbefore). A punch that cannot be read, kept aside, is not counted.",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "punches"
        ],
        "type": "object"
      },
      "Delivery": {
        "description": "What happens to a message whose events could not be delivered to a\nsink: `ack` (the device retries until acknowledged: the message is\nrefused, and nothing it changed is kept), `cursor` (the device does not\nretry: the reply goes out, but cursor writes are dropped so the package\nfetches the same data again) or `none` (best effort: the events are\nlost and everything else proceeds).",
        "enum": [
          "ack",
          "cursor",
          "none"
        ],
        "type": "string"
      },
      "DeliveryKeyView": {
        "description": "A delivery key, as listed: never its secret.",
        "properties": {
          "created": {
            "example": "2026-10-07T14:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "created_by": {
            "description": "Who issued it.",
            "type": "string"
          },
          "id": {
            "description": "Its id within the tenant, to revoke it by.",
            "example": "3f9a0c21d4e8",
            "type": "string"
          },
          "label": {
            "description": "What it is for: the sender it was given to.",
            "example": "dealer-north connect",
            "type": "string"
          },
          "last_used": {
            "description": "When it last delivered (written at most once a minute); null if\nit never has.",
            "example": "2026-10-07T14:05:12Z",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "revoked": {
            "description": "Whether it was revoked: a revoked key proves nothing and is kept in\nthe list, so the audit trail can say which key it was.",
            "type": "boolean"
          },
          "revoked_at": {
            "description": "When it was revoked.",
            "example": "2026-10-08T09:00:00Z",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "revoked_by": {
            "description": "Who revoked it, as `created_by` says.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "label",
          "created",
          "created_by",
          "revoked"
        ],
        "type": "object"
      },
      "Delta": {
        "description": "A value as it is, as it would be, and the difference.",
        "properties": {
          "after": {
            "type": "string"
          },
          "before": {
            "type": "string"
          },
          "change": {
            "type": "string"
          }
        },
        "required": [
          "before",
          "after",
          "change"
        ],
        "type": "object"
      },
      "DeviceCatalog": {
        "description": "What a device takes (`GET /api/tenants/{tenant}/devices/{endpoint}/{device}/catalog`).",
        "properties": {
          "actions": {
            "description": "The actions the device takes, as the package judges from what the\ndevice reported.",
            "items": {
              "$ref": "#/components/schemas/ActionInfo"
            },
            "type": "array"
          },
          "commands": {
            "description": "The package's commands the device takes.",
            "items": {
              "$ref": "#/components/schemas/CommandInfo"
            },
            "type": "array"
          },
          "device": {
            "description": "The device's id.",
            "type": "string"
          },
          "endpoint": {
            "description": "The device's endpoint.",
            "type": "string"
          },
          "package": {
            "description": "The package that runs it, \"name@version\".",
            "type": "string"
          },
          "revision": {
            "description": "The revision of the package; null when it runs from a folder\n(`hourd dev`).",
            "format": "int32",
            "type": [
              "integer",
              "null"
            ]
          },
          "settings": {
            "description": "The settings the device has (set with the `set_settings` action).",
            "items": {
              "$ref": "#/components/schemas/Setting"
            },
            "type": "array"
          }
        },
        "required": [
          "endpoint",
          "device",
          "package",
          "actions",
          "commands",
          "settings"
        ],
        "type": "object"
      },
      "DeviceChanged": {
        "description": "A device and the commands queued for it by the change.",
        "properties": {
          "commands": {
            "description": "The commands queued to give the device its new key; empty when the\nkey did not change.",
            "items": {
              "$ref": "#/components/schemas/Command"
            },
            "type": "array"
          },
          "device": {
            "$ref": "#/components/schemas/LabelledDevice",
            "description": "The device as it is now."
          }
        },
        "required": [
          "device",
          "commands"
        ],
        "type": "object"
      },
      "DeviceCommandCounts": {
        "description": "What a device's commands add up to: how many wait to go out, how many it holds without having answered, and how many\nended unanswered.",
        "properties": {
          "in_hand": {
            "description": "Commands offered to the device (written into a reply) that it has not answered and that no rule has ended (a\nlater answer in order, the package's restart rule, a give-up).",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "unanswered": {
            "description": "Commands that ended unanswered and are still kept (finished commands are kept for their retention). A result\nthat arrives later still completes one.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "waiting": {
            "description": "Commands queued for the device and not yet offered to it. An upper bound: one past its expiry waits here until the\nsweep cancels it.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "waiting",
          "in_hand",
          "unanswered"
        ],
        "type": "object"
      },
      "DeviceDetail": {
        "description": "A device, its keys, and what its package offers it.",
        "properties": {
          "available_actions": {
            "description": "The actions this device takes, by name, as the package judges from\nwhat the device reported (the package's `actions` say how). Empty\nwhen its endpoint is not served.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "available_commands": {
            "description": "The commands its package offers to be sent by name: every one but\nthose only the package's own actions use. Empty when its endpoint is\nnot served.",
            "items": {
              "$ref": "#/components/schemas/CommandInfo"
            },
            "type": "array"
          },
          "commands": {
            "$ref": "#/components/schemas/DeviceCommandCounts",
            "description": "What its commands add up to: waiting, in its hand, and ended unanswered."
          },
          "device": {
            "$ref": "#/components/schemas/LabelledDevice",
            "description": "The device."
          },
          "keys": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Keys",
                "description": "Its keys: the only place they are shown. Null if the device was\nremoved in the meantime."
              }
            ]
          }
        },
        "required": [
          "device",
          "available_commands",
          "available_actions",
          "commands"
        ],
        "type": "object"
      },
      "DeviceHealth": {
        "description": "How a device's messages have gone. Each instance counts what it handles\nand writes the count with the device's record every 5 minutes (at once\nafter an error); the device views add what every running instance has\ncounted since.",
        "properties": {
          "errors": {
            "description": "Of those, the ones that failed: the package failed, no route matched,\nor what it changed could not be stored.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "last_error": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/DeviceLastError",
                "description": "Its latest failed message; absent when none has failed."
              }
            ]
          },
          "messages": {
            "description": "Messages that got past its key: taken in, or refused for its status.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "messages",
          "errors"
        ],
        "type": "object"
      },
      "DeviceHold": {
        "description": "Why a device's outgoing queue is held, and since when. Released by\nhand (`POST /api/tenants/{tenant}/devices/{endpoint}/{device}/release`), with or without\nwhat waits for it.",
        "properties": {
          "action_id": {
            "description": "The action whose gate failed.",
            "format": "int64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "held_at": {
            "description": "When the hold was taken.",
            "format": "date-time",
            "type": "string"
          },
          "reason": {
            "description": "Why: the gate that did not pass and what became of it.",
            "type": "string"
          },
          "step": {
            "description": "The gate's step in that action, counted from 1.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "held_at",
          "reason"
        ],
        "type": "object"
      },
      "DeviceLastError": {
        "description": "A device's latest failed message.",
        "properties": {
          "at": {
            "description": "When it failed.",
            "format": "date-time",
            "type": "string"
          },
          "reason": {
            "description": "Why it failed, at most 500 characters.",
            "type": "string"
          },
          "route": {
            "description": "The package route it took, if one matched.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "at",
          "reason"
        ],
        "type": "object"
      },
      "DeviceReleased": {
        "description": "What releasing a device did.",
        "properties": {
          "cancelled_commands": {
            "description": "The commands not of an action cancelled (with `drop_queued`).",
            "items": {
              "format": "int64",
              "minimum": 0,
              "type": "integer"
            },
            "type": "array"
          },
          "device": {
            "description": "The device's id.",
            "type": "string"
          },
          "drop_queued": {
            "description": "Whether what waited for the device was cancelled.",
            "type": "boolean"
          },
          "dropped_actions": {
            "description": "The actions cancelled (with `drop_queued`).",
            "items": {
              "format": "int64",
              "minimum": 0,
              "type": "integer"
            },
            "type": "array"
          },
          "endpoint": {
            "description": "The device's endpoint.",
            "type": "string"
          },
          "released": {
            "$ref": "#/components/schemas/DeviceHold",
            "description": "The hold taken off."
          }
        },
        "required": [
          "endpoint",
          "device",
          "released",
          "drop_queued",
          "dropped_actions",
          "cancelled_commands"
        ],
        "type": "object"
      },
      "DeviceStatus": {
        "description": "Whether a device may talk to the gateway: `pending` (known, waiting\nfor someone to allow or block it; its messages are refused meanwhile),\n`allowed` (its messages are taken in) or `blocked` (its messages are\nrefused until someone allows it).",
        "enum": [
          "pending",
          "allowed",
          "blocked"
        ],
        "type": "string"
      },
      "DomainPolicy": {
        "additionalProperties": false,
        "description": "`lists` and `settings`: who decides.",
        "properties": {
          "authority": {
            "$ref": "#/components/schemas/Authority",
            "description": "Who decides the domain's data: `group` (the default) or `shared`."
          }
        },
        "type": "object"
      },
      "EmployerBody": {
        "additionalProperties": false,
        "description": "An employer to make, or what to change of one.",
        "properties": {
          "external_ids": {
            "description": "In place of all it had.",
            "type": [
              "object",
              "null"
            ]
          },
          "id": {
            "description": "Its id (to make one; a change keeps it).",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "EmployerView": {
        "description": "An employer: a legal entity inside the tenant.",
        "properties": {
          "created": {
            "example": "2026-10-01T14:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "external_ids": {
            "description": "Its id in each other system, under a name the builder chooses (an\nEIN, a PAYE reference, a Business Number, a payroll company code).",
            "type": "object"
          },
          "id": {
            "description": "Its id within the tenant: 1 to 64 letters, digits, '-' or '_'.",
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "external_ids",
          "created"
        ],
        "type": "object"
      },
      "EmploymentView": {
        "description": "A person's employment on a day.",
        "properties": {
          "day": {
            "example": "2026-10-07",
            "type": "string"
          },
          "employment": {
            "description": "`employed`, `hired`, `first_hired`, `terminated`, `on_leave_since`,\n`days_employed`, and the `attributes` in force.",
            "type": "object"
          },
          "person": {
            "type": "string"
          }
        },
        "required": [
          "person",
          "day",
          "employment"
        ],
        "type": "object"
      },
      "EndpointConfig": {
        "additionalProperties": false,
        "description": "An endpoint: a group of devices that reach a listener on one path (http)\nor topic (mqtt), run by one package, whose events go to the same sinks.",
        "properties": {
          "allow_from": {
            "description": "http: client addresses let in, as addresses or CIDR ranges, after\nthe listener's own lists. Set, every other address is refused (403).",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "back_after_minutes": {
            "description": "A device heard from again after more than this many minutes away\nhas come back: `device.back` is stored, and the policy's `back` hook\ncalled. Absent: never.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "deny_from": {
            "description": "http: client addresses refused (403), whatever `allow_from` says.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "id": {
            "description": "Its id, as devices are known by (`<endpoint>/<device>`): 1 to 64\nletters, digits, '-' or '_'. It cannot be changed.",
            "type": "string"
          },
          "labels": {
            "$ref": "#/components/schemas/BTreeMap",
            "description": "Labels every device of the endpoint has (a device's own labels are\nput over them): what a sync group's placement rules pick members by."
          },
          "listener": {
            "description": "The id of the listener its devices reach.",
            "type": "string"
          },
          "metadata": {
            "description": "Free-form data from other systems (a site's cost center), kept as\ngiven: never read by Connect, never sent with events.",
            "type": "object"
          },
          "new_devices": {
            "$ref": "#/components/schemas/NewDevices",
            "description": "What becomes of a device nobody has registered: \"allow\", \"hold\"\n(the default) or \"refuse\"."
          },
          "options": {
            "description": "Free-form options handed to the package as `ctx.options`.",
            "type": "object"
          },
          "package": {
            "description": "Package name, optionally pinned to a version prefix: \"acme\" or \"acme@2.1\".",
            "type": "string"
          },
          "path": {
            "description": "http: path prefix template, e.g. \"/office\" or \"/site/{site}\". Omit to\nclaim the whole listener, which it must then have to itself. A\nrequest goes to the endpoint whose path is the longest prefix of its\npath; of those as long, to the more specific, whatever the order\nthey are listed in: compared segment by segment from the left, a\nliteral segment beats a `{placeholder}` at the first place they\ndiffer (\"/a/b\" before \"/a/{x}\", \"/a/{x}\" before \"/{y}/b\"). Two\nendpoints of a listener with paths of the same shape (the same\nliterals, ignoring case, and placeholders in the same places) are\nrefused.",
            "type": [
              "string",
              "null"
            ]
          },
          "policy": {
            "description": "The tenant's policy package its devices' moments and punches are\ndecided by (its hooks), by name, optionally pinned to a version\nprefix: \"clocks\" or \"clocks@1\". Absent: no hook is called (a punch\nwith several routes is unrouted, an enrolled person is kept).",
            "type": [
              "string",
              "null"
            ]
          },
          "reply_topic": {
            "description": "mqtt: topic template for replies and commands, e.g.\n\"clocks/{device}/commands\". May use the topic's placeholders and {device} (the\ndevice's id; {sn} is taken too).",
            "type": [
              "string",
              "null"
            ]
          },
          "routes": {
            "description": "Default routes for the punches of its devices, over its sync\ngroup's (`routes`): each names a receiving system and a tenant in\nit, never a person.",
            "items": {
              "$ref": "#/components/schemas/Route"
            },
            "type": "array"
          },
          "sinks": {
            "description": "Sink ids that are sent this endpoint's events. With none, the events\nare still stored and can be read from the admin API.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "sync_group": {
            "description": "The sync group its allowed devices are members of. Absent: a group\nof its own, named after the endpoint, that keeps nothing.",
            "type": [
              "string",
              "null"
            ]
          },
          "topic": {
            "description": "mqtt: topic template devices publish to, e.g. \"clocks/{device}/events\".\nA message goes to the most specific endpoint whose topic matches\nit whole, as paths are chosen; two endpoints of a listener with\ntopics of the same shape are refused.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "listener",
          "package"
        ],
        "type": "object"
      },
      "EndpointInfo": {
        "description": "An endpoint as the admin API shows it: its settings, the package it\nresolved to, and whether it was stopped by hand.",
        "properties": {
          "allow_from": {
            "description": "Client addresses let in (after the listener's lists); set, every\nother address is refused.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "back_after_minutes": {
            "description": "Minutes away after which a device heard from again has come back.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "delivery": {
            "$ref": "#/components/schemas/Delivery"
          },
          "deny_from": {
            "description": "Client addresses refused, whatever `allow_from` says.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "id": {
            "type": "string"
          },
          "labels": {
            "$ref": "#/components/schemas/BTreeMap",
            "description": "Labels every device of the endpoint has (placement)."
          },
          "listener": {
            "type": "string"
          },
          "metadata": {
            "description": "Free-form data from other systems, as given.",
            "type": "object"
          },
          "new_devices": {
            "$ref": "#/components/schemas/NewDevices"
          },
          "options": {
            "type": "object"
          },
          "package": {
            "description": "As configured: \"acme\" or \"acme@2\".",
            "type": "string"
          },
          "package_id": {
            "description": "The package in use: \"acme@2.1.0\".",
            "type": "string"
          },
          "path": {
            "type": [
              "string",
              "null"
            ]
          },
          "policy": {
            "description": "Its policy package, as configured: \"clocks\" or \"clocks@1\".",
            "type": [
              "string",
              "null"
            ]
          },
          "policy_id": {
            "description": "The policy package in use: \"clocks@1.0.0\". Absent with no policy, or\none this instance does not run.",
            "type": [
              "string",
              "null"
            ]
          },
          "reply_topic": {
            "type": [
              "string",
              "null"
            ]
          },
          "routes": {
            "description": "Default routes for its devices' punches, over its group's.",
            "items": {
              "$ref": "#/components/schemas/Route"
            },
            "type": "array"
          },
          "sinks": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "stopped": {
            "description": "Stopped by hand: its devices are told to come back later.",
            "type": "boolean"
          },
          "sync_group": {
            "description": "The sync group its allowed devices are members of.",
            "type": [
              "string",
              "null"
            ]
          },
          "topic": {
            "type": [
              "string",
              "null"
            ]
          },
          "unavailable": {
            "description": "Why this instance does not serve it (its package is not one it\nruns, or no longer fits it); absent when it does.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "listener",
          "package",
          "package_id",
          "delivery",
          "sinks",
          "new_devices",
          "options",
          "stopped"
        ],
        "type": "object"
      },
      "Error": {
        "description": "A refusal, and why.",
        "properties": {
          "error": {
            "description": "Why the request was refused, in a sentence.",
            "type": "string"
          },
          "fields": {
            "description": "For a request whose parameters do not fit (422): what is wrong with\neach field. Absent otherwise.",
            "items": {
              "$ref": "#/components/schemas/FieldError"
            },
            "type": "array"
          },
          "request_id": {
            "description": "The request's id, as its `X-Request-Id` header gives it: what to\nquote when asking what happened to it.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "Event": {
        "description": "Every event, whatever its type. `data` is described by the schema named after `type` (punch.json, user.json, ...). Consumers must ignore fields they do not know: fields are added within a schema version.",
        "properties": {
          "data": {
            "description": "The type's fields.",
            "type": "object"
          },
          "device": {
            "description": "The device's id: whatever its package identifies it by (a serial number, a MAC address, a cloud id); \"\" for an event about a whole job (job.*, but not job.execution.*) or a sync group; for an event a system posted, what it is about, as posted (\"\" when it named nothing); for Time and Attendance's own, the person or timecard it is about.",
            "type": "string"
          },
          "endpoint": {
            "description": "The endpoint the device belongs to, by its id within the tenant; \"sync:<group>\" for a sync group's own events; \"source:<source>\" for an event the system <source> posted into the tenant; \"attendance\" for Time and Attendance's own events.",
            "type": "string"
          },
          "group": {
            "description": "The sync group of the endpoint (every endpoint is in one, its own unless it names one), by its id within the tenant; for a group's own events, that group. Absent for an endpoint no longer configured, and for events of another engine.",
            "type": "string"
          },
          "id": {
            "description": "Stable idempotency key, 32 hex digits: the same device record always gets the same id, and an event a system posted (endpoint \"source:<source>\") the same id whenever it is posted from the same source with the same id. Deduplicate on it.",
            "pattern": "^[0-9a-f]{32}$",
            "type": "string"
          },
          "package": {
            "description": "The package that read it, \"name@version\"; for the gateway's own events about a device, that device's package; \"houradvantage-connect\" for a job's or sync group's own events; for an event a system posted, its source; \"houradvantage-attend\" for Time and Attendance's own.",
            "type": "string"
          },
          "person": {
            "description": "Connect's own id of the person the event is about (data.user_id) in its group: opaque, and kept when the person's user id changes. Present when the group keeps people and has the person.",
            "type": "string"
          },
          "person_id": {
            "description": "To a sink with person_id only: the id, in the system the sink names, of the person the event is about (data.user_id), from the person's external_ids; absent when they have none there.",
            "type": "string"
          },
          "received_at": {
            "description": "When the gateway received it (for the gateway's own events, when it made them), RFC 3339 UTC.",
            "format": "date-time",
            "type": "string"
          },
          "request": {
            "description": "The admin API request that caused the event, made while it ran: a change made through the API, an event posted through it. Absent for an event no request caused: a device's message, a job's waves, Time and Attendance working a ledger out. A request id is a correlation id only: the caller may have chosen it.",
            "properties": {
              "id": {
                "description": "The request's id: the X-Request-Id it was answered with, and that its audit trail entry and log lines carry.",
                "type": "string"
              },
              "idempotency_key": {
                "description": "The Idempotency-Key it was sent with, if any.",
                "type": "string"
              },
              "user": {
                "description": "Who made the request, as the server named them from its login or token, never as the caller says: the login's user, or token:<name> for an API token's. Absent when the caller was not known.",
                "type": "string"
              }
            },
            "required": [
              "id"
            ],
            "type": "object"
          },
          "schema": {
            "const": 3,
            "description": "The version of this contract the event follows."
          },
          "tenant": {
            "description": "The tenant the event belongs to: in Connect's events, the Connect tenant its endpoint is of (or that it was posted into); in Time and Attendance's, the Time and Attendance tenant. Events of the source \"attendance\" in Connect's log say \"default\" but are no Connect tenant's: only install-level sinks that name the source are sent them, and they stay in the log until those sinks have taken them, then retention removes them as any event. Time and Attendance keeps its own events in a log of its own.",
            "type": "string"
          },
          "type": {
            "description": "The event type; the event reference describes each.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "schema",
          "type",
          "tenant",
          "endpoint",
          "device",
          "package",
          "received_at",
          "data"
        ],
        "title": "Hour Advantage event",
        "type": "object"
      },
      "EventsPage": {
        "description": "A page of stored events.",
        "properties": {
          "events": {
            "description": "The events, oldest first.",
            "items": {
              "$ref": "#/components/schemas/StoredEvent"
            },
            "type": "array"
          },
          "next": {
            "description": "The `seq` of the last event on the page, or the `after` asked for\nwhen the page is empty: pass it as `after` for the next page.",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "events",
          "next"
        ],
        "type": "object"
      },
      "ExceptionChange": {
        "description": "An exception that would be raised, or go.",
        "properties": {
          "about": {
            "type": "string"
          },
          "at": {
            "example": "2026-10-05T13:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "day": {
            "description": "The workday it is on, and the instant it is about.",
            "example": "2026-10-05",
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "exception": {
            "description": "Its kind: one the engine finds (missing_out...) or a policy step's.",
            "type": "string"
          },
          "id": {
            "description": "Its id, as the ledger and the follow-up list name it.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "exception",
          "day",
          "at",
          "about",
          "detail"
        ],
        "type": "object"
      },
      "ExceptionView": {
        "description": "An exception, as the follow-up list shows it.",
        "properties": {
          "about": {
            "type": "string"
          },
          "at": {
            "example": "2026-10-05T13:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "comment": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "exception": {
            "description": "Its kind: one the engine finds (missing_out...) or a policy step's.",
            "type": "string"
          },
          "id": {
            "description": "Its id: the same each time the ledger is worked out.",
            "type": "string"
          },
          "noted_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "noted_by": {
            "description": "Who noted it last, when, and what they wrote.",
            "type": [
              "string",
              "null"
            ]
          },
          "period": {
            "description": "The first day of the pay period it is in.",
            "example": "2026-10-05",
            "type": "string"
          },
          "person": {
            "type": "string"
          },
          "state": {
            "description": "open, acknowledged or excused.",
            "type": "string"
          },
          "unlinked": {
            "description": "Whether the person is an unlinked person (`GET .../unlinked`).",
            "type": "boolean"
          }
        },
        "required": [
          "person",
          "period",
          "id",
          "exception",
          "at",
          "about",
          "detail",
          "state"
        ],
        "type": "object"
      },
      "ExceptionsPage": {
        "description": "A page of exceptions.",
        "properties": {
          "exceptions": {
            "items": {
              "$ref": "#/components/schemas/ExceptionView"
            },
            "type": "array"
          },
          "next": {
            "description": "Pass as `after` for the next page; null: there is none.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "exceptions"
        ],
        "type": "object"
      },
      "ExecState": {
        "description": "Where one device stands in a job: `queued` (its wave has not started,\nor there is no room yet under `max_concurrent`), `waiting_window` (its\nturn, but the window is closed where it is), `running` (its action is\nstarted), `succeeded`, `failed` (its action failed, a step went\nunanswered, or it could not be started), `timed_out` (its action did\nnot finish within the job's timeout) or `cancelled` (the job was\ncancelled, or its action was).",
        "enum": [
          "queued",
          "waiting_window",
          "running",
          "succeeded",
          "failed",
          "timed_out",
          "cancelled"
        ],
        "type": "string"
      },
      "Execution": {
        "description": "One device's part in a job.",
        "properties": {
          "action_id": {
            "description": "The action started on it (the latest attempt's).",
            "format": "int64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "attempt": {
            "description": "1, then one more for each `retry-failed` that took it again.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "detail": {
            "description": "What went wrong, for one that failed, timed out or was cancelled\n(the step its action stopped at, counted from 1); what it waits\nfor, for one waiting for its window (\"waiting for window (opens\n2026-10-04 22:00 America/Chicago)\").",
            "type": [
              "string",
              "null"
            ]
          },
          "device": {
            "description": "The device's id.",
            "type": "string"
          },
          "endpoint": {
            "description": "The device's endpoint.",
            "type": "string"
          },
          "finished_at": {
            "description": "When it finished (the latest attempt).",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "held": {
            "description": "Shown, not kept: the device is held (a gate of an action did not\npass, and its outgoing queue waits for a release).",
            "type": "boolean"
          },
          "seq": {
            "description": "Its place among the job's devices, from 0.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "started_at": {
            "description": "When its action was started (the latest attempt's).",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "$ref": "#/components/schemas/ExecState"
          },
          "wave": {
            "description": "Its wave, from 0.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "zone": {
            "description": "The zone its window is read in: its endpoint's `timezone` option,\nelse its sync group's timezone setting. Absent: it has none, and UTC\nis used.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "seq",
          "endpoint",
          "device",
          "wave",
          "state",
          "attempt"
        ],
        "type": "object"
      },
      "Export": {
        "description": "A setup, secrets left out: the install's (`GET /api/export`: its settings,\nlog level, tenants and install-level sinks) or a tenant's\n(`GET /api/tenants/{tenant}/export`: its listeners, endpoints, sinks and\nsync groups). What it takes to set up another gateway the same way, but\nfor the mqtt passwords and the sinks' signing secrets.",
        "properties": {
          "endpoints": {
            "description": "Every endpoint, as configured (a tenant's).",
            "items": {
              "$ref": "#/components/schemas/EndpointConfig"
            },
            "type": "array"
          },
          "listeners": {
            "description": "Every listener, its password only as `password_set` (a tenant's).",
            "items": {
              "$ref": "#/components/schemas/ListenerView"
            },
            "type": "array"
          },
          "logs": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ExportLogs",
                "description": "The install's log level. Absent from a tenant's export."
              }
            ]
          },
          "settings": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/SettingsView",
                "description": "The install's: the limits, the retention and the trusted proxies.\nAbsent from a tenant's export."
              }
            ]
          },
          "sinks": {
            "description": "Every sink, its secret only as `secret_set`: a tenant's, or the\ninstall-level sinks.",
            "items": {
              "$ref": "#/components/schemas/SinkView"
            },
            "type": "array"
          },
          "sync_groups": {
            "description": "Every sync group, as configured (a tenant's).",
            "items": {
              "$ref": "#/components/schemas/SyncGroupConfig"
            },
            "type": "array"
          },
          "tenants": {
            "description": "The install's tenants. Absent from a tenant's export.",
            "items": {
              "$ref": "#/components/schemas/TenantConfig"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "ExportLogs": {
        "description": "The logging every instance uses.",
        "properties": {
          "level": {
            "description": "The log level kept in the settings, in `RUST_LOG` syntax.",
            "type": "string"
          }
        },
        "required": [
          "level"
        ],
        "type": "object"
      },
      "ExportView": {
        "description": "An export made.",
        "properties": {
          "by": {
            "type": "string"
          },
          "changed": {
            "description": "With one export read: the people whose ledger of the period is no\nlonger the one it wrote (changed since, or gone).",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "created": {
            "format": "date-time",
            "type": "string"
          },
          "employer": {
            "description": "The employer whose people it wrote; absent: every employer's.",
            "type": [
              "string",
              "null"
            ]
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "exporter": {
            "type": "string"
          },
          "finished": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "string"
          },
          "only": {
            "type": "string"
          },
          "people": {
            "description": "How many people it wrote.",
            "format": "int64",
            "type": "integer"
          },
          "period": {
            "example": "2026-10-05",
            "type": "string"
          },
          "side": {
            "type": "string"
          },
          "state": {
            "description": "running, done or failed (a download that stopped before the file\nwas written is failed).",
            "type": "string"
          }
        },
        "required": [
          "id",
          "exporter",
          "side",
          "period",
          "only",
          "by",
          "created",
          "state",
          "people"
        ],
        "type": "object"
      },
      "FactsView": {
        "description": "A person's facts.",
        "properties": {
          "facts": {
            "description": "Each fact, as `{\"<kind>\": {...}}`: punch, correction, labor,\napproval, close, accrual_adjustment, schedule_override,\nemployment, exception_note, leave_request, attestation.",
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "person": {
            "type": "string"
          }
        },
        "required": [
          "person",
          "facts"
        ],
        "type": "object"
      },
      "Failure": {
        "description": "One failed device message.",
        "properties": {
          "at": {
            "description": "When the message was handled.",
            "format": "date-time",
            "type": "string"
          },
          "device": {
            "description": "The device it came from, by id.",
            "type": "string"
          },
          "endpoint": {
            "description": "The endpoint it came in on.",
            "type": "string"
          },
          "error": {
            "description": "What went wrong, cut to 500 characters.",
            "type": "string"
          },
          "id": {
            "description": "Its id, given when it was stored. Pass the last one of a page as\n`before` for the next page.",
            "format": "int64",
            "type": "integer"
          },
          "instance": {
            "description": "The gateway instance that handled the message.",
            "type": "string"
          },
          "kind": {
            "$ref": "#/components/schemas/FailureKind",
            "description": "What kind of failure it was."
          },
          "request": {
            "description": "The request's method and path (no query, no body).",
            "type": "string"
          },
          "route": {
            "description": "The package route that took the message, if one matched (a package\nthat fails before it picks one has none); absent otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "source": {
            "description": "Where in the package it failed (\"main.lua:42\"), when the error says;\nabsent otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "description": "What the device was answered.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "id",
          "at",
          "endpoint",
          "device",
          "request",
          "kind",
          "status",
          "error",
          "instance"
        ],
        "type": "object"
      },
      "FailureKind": {
        "description": "What kind of failure it was.",
        "enum": [
          "lua_error",
          "timeout",
          "memory_limit",
          "no_route",
          "server_error"
        ],
        "type": "string"
      },
      "FailuresPage": {
        "description": "A page of failures, newest first, and the `before` of the next page\n(none: this is the last).",
        "properties": {
          "failures": {
            "description": "The failures, newest first.",
            "items": {
              "$ref": "#/components/schemas/Failure"
            },
            "type": "array"
          },
          "next": {
            "description": "When the page is full, the id to pass as `before` for the next page;\nnull when there are no more.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "failures"
        ],
        "type": "object"
      },
      "FieldError": {
        "description": "What is wrong with one field of a request.",
        "properties": {
          "field": {
            "description": "The parameter, as the request names it (`values.volume` for a\nsetting inside `values`).",
            "type": "string"
          },
          "message": {
            "description": "What is wrong with it.",
            "type": "string"
          }
        },
        "required": [
          "field",
          "message"
        ],
        "type": "object"
      },
      "HandActions": {
        "description": "Which commands of the hand a `MissedHand` takes.",
        "oneOf": [
          {
            "$ref": "#/components/schemas/HandKind",
            "description": "`\"all\"` or `\"writes\"`."
          },
          {
            "description": "The commands of these names.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        ]
      },
      "HandKind": {
        "description": "The kinds of command a `MissedHand` takes without naming them.",
        "enum": [
          "all",
          "writes"
        ],
        "type": "string"
      },
      "Health": {
        "description": "How an instance is doing, and which it is (`GET /api/instance`, behind\nthe login).",
        "properties": {
          "database": {
            "description": "The database answered within 2 seconds.",
            "type": "boolean"
          },
          "environment": {
            "description": "The cluster's environment, as `HOURADVANTAGE_ENVIRONMENT` names it\n(\"production\", \"test\"); absent when it is not named.",
            "type": "string"
          },
          "instance": {
            "description": "The instance's name, as the logs, the audit trail and\n`GET /api/peers` name it.",
            "type": "string"
          },
          "ok": {
            "description": "It takes work (`ready`) and its database answers (`database`).",
            "type": "boolean"
          },
          "production": {
            "description": "True when the cluster is production (`HOURADVANTAGE_PRODUCTION`);\nabsent when it is not.",
            "type": "boolean"
          },
          "ready": {
            "description": "It takes work: what `GET /api/ready` answers 200 for.",
            "type": "boolean"
          },
          "starting": {
            "description": "True while the instance starts (reaches its database, migrates it,\nloads its devices); absent once it has started.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "tzdb": {
            "description": "The release of the time zone database built into the gateway\n(\"2026a\"): the zone rules it converts times with.",
            "type": "string"
          },
          "version": {
            "description": "The gateway's version. Absent from what a gateway says to anyone\n(`GET /api/health`), which is all one still starting can say.",
            "type": "string"
          }
        },
        "required": [
          "ok"
        ],
        "type": "object"
      },
      "HierarchyBody": {
        "additionalProperties": false,
        "description": "A hierarchy to make, or its new name.",
        "properties": {
          "id": {
            "description": "Its id (to make one; a change keeps it).",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "type": "object"
      },
      "HierarchyView": {
        "description": "A hierarchy: a tree of organizations.",
        "properties": {
          "created": {
            "example": "2026-10-01T14:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "Its id within the tenant: 1 to 64 letters, digits, '-' or '_'.",
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "created"
        ],
        "type": "object"
      },
      "HolidayView": {
        "description": "A holiday observed on a day.",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name"
        ],
        "type": "object"
      },
      "HoursChange": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Delta"
          },
          {
            "properties": {
              "category": {
                "type": "string"
              }
            },
            "required": [
              "category"
            ],
            "type": "object"
          }
        ],
        "description": "The hours of a pay category, before and after."
      },
      "InForce": {
        "description": "A version in force from a day.",
        "properties": {
          "from": {
            "type": [
              "string",
              "null"
            ]
          },
          "version": {
            "type": "string"
          }
        },
        "required": [
          "version"
        ],
        "type": "object"
      },
      "InPage": {
        "description": "A page of the people in now.",
        "properties": {
          "as_of": {
            "description": "The instant asked of.",
            "example": "2026-10-07T17:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "in": {
            "items": {
              "$ref": "#/components/schemas/InView"
            },
            "type": "array"
          },
          "next": {
            "description": "Pass as `after` for the next page; null: there is none.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "as_of",
          "in"
        ],
        "type": "object"
      },
      "InView": {
        "description": "A person in now, as their pay ledger was last worked out.",
        "properties": {
          "device": {
            "type": "string"
          },
          "kind": {
            "description": "What they are in: `work`, `lunch` or `break`.",
            "example": "work",
            "type": "string"
          },
          "pending": {
            "description": "They wait to be worked out again (something new was recorded for\nthem): this may be about to change.",
            "type": "boolean"
          },
          "period": {
            "description": "The first day of the pay period it started in.",
            "example": "2026-10-05",
            "type": "string"
          },
          "person": {
            "type": "string"
          },
          "punch": {
            "description": "That punch's id, and the device it was made on.",
            "type": "string"
          },
          "since": {
            "description": "The instant of the punch that started it.",
            "example": "2026-10-07T13:02:00Z",
            "format": "date-time",
            "type": "string"
          },
          "until": {
            "description": "When their shift reaches the longest the policy says a shift may be (its\n`longest_shift` step): from then they are not listed, taken as an out\nnever punched. Absent where the policy says none: they are in until a\npunch or a rule of the policy closes the stretch.",
            "example": "2026-10-08T05:02:00Z",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "values": {
            "description": "The labor context of the work.",
            "type": "object"
          }
        },
        "required": [
          "person",
          "kind",
          "since",
          "punch",
          "device",
          "values",
          "period",
          "pending"
        ],
        "type": "object"
      },
      "IssuedDeliveryKey": {
        "allOf": [
          {
            "$ref": "#/components/schemas/DeliveryKeyView"
          },
          {
            "properties": {
              "secret": {
                "description": "The secret: what the sender signs with (a webhook sink's `secret`),\nor carries (an in_process sink's `secret`). `hadk_` and 43 more\ncharacters.",
                "example": "hadk_Q2xvY2tFWEFNUExFb25seUVYQU1QTEVvbmx5RVhB",
                "type": "string"
              }
            },
            "required": [
              "secret"
            ],
            "type": "object"
          }
        ],
        "description": "A delivery key just issued, with its secret: shown this once."
      },
      "Job": {
        "description": "A job as it is kept.",
        "properties": {
          "abort_seen": {
            "description": "How many devices had failed when the abort threshold last paused it:\nonce resumed, it pauses again only on a new failure.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "created_at": {
            "description": "When it was created.",
            "format": "date-time",
            "type": "string"
          },
          "created_by": {
            "description": "Who created it: the admin login, `token:<name>` for an API token,\nor `local` when no login is configured.",
            "type": "string"
          },
          "finished_at": {
            "description": "When it was completed, or cancelled with nothing left running.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "description": "The job's id.",
            "format": "int64",
            "type": "integer"
          },
          "matched": {
            "description": "Devices the targets matched (each has an execution).",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "missing": {
            "description": "Devices listed in `targets.devices` that are not known or not allowed.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "reason": {
            "description": "Why it is as it is, when that is worth saying: what paused it, what\nit waits for.",
            "type": [
              "string",
              "null"
            ]
          },
          "spec": {
            "$ref": "#/components/schemas/JobSpec",
            "description": "The job as it was asked for, defaults filled in."
          },
          "state": {
            "$ref": "#/components/schemas/JobState"
          },
          "tenant": {
            "description": "The tenant it is of: it runs on that tenant's devices only.",
            "type": "string"
          },
          "updated_at": {
            "description": "When it last changed.",
            "format": "date-time",
            "type": "string"
          },
          "wave": {
            "description": "The current wave, from 0: devices of this wave and those before it\nmay start.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "waves": {
            "description": "How many waves it has.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "id",
          "spec",
          "state",
          "wave",
          "waves",
          "matched",
          "created_by",
          "created_at",
          "updated_at"
        ],
        "type": "object"
      },
      "JobSpec": {
        "additionalProperties": false,
        "description": "A job as asked for: the file `hourctl job create` reads, the body of\n`POST /api/tenants/{tenant}/jobs`, kept as it was given.",
        "properties": {
          "abort": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Abort",
                "description": "When too many devices fail, the job pauses. Absent: it never pauses\non its own."
              }
            ]
          },
          "action": {
            "description": "What each device runs: a standard action its package offers, or a\npackage action or command (firmware upgrades are package actions).",
            "type": "string"
          },
          "lane": {
            "$ref": "#/components/schemas/CallerLane",
            "description": "The lane each device's action queues in: `interactive` (the\ndefault) or `bulk`."
          },
          "name": {
            "description": "A name for people to know it by (not unique).",
            "type": "string"
          },
          "params": {
            "description": "The action's parameters, by name. None may be one the package marks\nsensitive: a job keeps its parameters to start each device's action.",
            "type": "object"
          },
          "rollout": {
            "$ref": "#/components/schemas/Rollout",
            "description": "How the devices are taken on. One wave of every device, advancing\non its own, unless said."
          },
          "targets": {
            "$ref": "#/components/schemas/Targets",
            "description": "Which devices it runs on."
          },
          "timeout": {
            "description": "How long each device has, from when its action is started, in\nseconds (a file or body may also say \"90s\", \"30m\", \"2h\", \"1d\"); any\npositive duration. At that instant its action expires: its steps not\nhanded out are cancelled, those in the device's hand are given up on\n(unanswered, each with its event), and the device is `timed_out`.\nAbsent: no deadline. The device's action waits until the device\nanswers, its commands are lost (by order, or a restart), or the\naction is cancelled or given up on.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "window": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Window",
                "description": "When devices may start. Absent: any time."
              }
            ]
          }
        },
        "required": [
          "action",
          "targets"
        ],
        "type": "object"
      },
      "JobState": {
        "description": "Where a job stands: `running` (devices are started as the rollout\nallows), `paused` (no device is started; those running go on to their\nend), `cancelled` (stopped for good: devices not started never will be)\nor `completed` (every device has finished).",
        "enum": [
          "running",
          "paused",
          "cancelled",
          "completed"
        ],
        "type": "string"
      },
      "JobView": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Job"
          },
          {
            "properties": {
              "counts": {
                "$ref": "#/components/schemas/Counts",
                "description": "How many of its devices are in each state."
              },
              "executions": {
                "description": "Every device of the job, in `seq` order. Absent in the list of jobs.",
                "items": {
                  "$ref": "#/components/schemas/Execution"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "no_zone": {
                "description": "How many of its devices have no zone of their own: their window is\nread in UTC. Always 0 in the list of jobs.",
                "format": "int32",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "counts"
            ],
            "type": "object"
          }
        ],
        "description": "A job as the API shows it: the job, how many of its devices are in\neach state, and, for one job, every device."
      },
      "KeptRevision": {
        "allOf": [
          {
            "description": "A package revision as kept (its bundle aside).",
            "properties": {
              "failed": {
                "description": "Its scenarios failed when it was pushed: what failed, a line each\n(`tests/door.toml: ...`). A failed revision is kept to be looked at\nand is never activated. Absent: they passed.",
                "items": {
                  "type": "string"
                },
                "type": [
                  "array",
                  "null"
                ]
              },
              "hash": {
                "description": "`sha256:<hex>` over its files.",
                "type": "string"
              },
              "host_api": {
                "description": "The host API it is written for.",
                "format": "int32",
                "type": "integer"
              },
              "line": {
                "description": "Its line: one revision of each line is active. A protocol or a\ntenant's package: its name and major.minor version (`zk-push@3.4`).\nA shared package: its name and whole version (`*:overtime@2.3.1`),\nso every version published stays there for whoever pins it.",
                "type": "string"
              },
              "name": {
                "description": "The package's name.",
                "type": "string"
              },
              "pushed_at": {
                "description": "When it was pushed.",
                "format": "date-time",
                "type": "string"
              },
              "pushed_by": {
                "description": "Who pushed it: the admin login's user name, `token:<name>` for an\nAPI token, or `local` without a login.",
                "type": "string"
              },
              "revision": {
                "description": "Counted per name from 1, in the order pushed.",
                "format": "int32",
                "type": "integer"
              },
              "size": {
                "description": "The bundle's size, in bytes.",
                "format": "int64",
                "type": "integer"
              },
              "version": {
                "description": "The package version it holds, from its manifest.",
                "type": "string"
              }
            },
            "required": [
              "name",
              "revision",
              "version",
              "line",
              "host_api",
              "hash",
              "size",
              "pushed_at",
              "pushed_by"
            ],
            "type": "object"
          },
          {
            "properties": {
              "active": {
                "description": "It is the active revision of its line.",
                "type": "boolean"
              }
            },
            "required": [
              "active"
            ],
            "type": "object"
          }
        ],
        "description": "A package revision kept, and whether it is the active one of its line."
      },
      "KeyState": {
        "description": "Where a device stands with its key.\n\nA device that presents a key other than its active one, or none, is\nrefused: its `key_refused_at` is set and `key_presented` says\n`unregistered` or `none`. To let it in again, either adopt the key it\npresents (`adopt_key: true`, which makes that key the active one) or\nremove its key (`key: null`, after which it is taken at its word).\n\nA device held (waiting to be allowed) with no key of its own keeps the\nfirst key it presents as the key it was held with (`key_held`), and\n`adopt_key` takes that one: the key seen when it was allowed. Another\nkey presented while it is held is a conflict (`key_conflict_at`), never\nadopted unless asked for in so many words (`adopt_presented_key`).\n\n`none`: the device has no key and is taken at its word, whatever it\npresents. `pending`: a new key is on its way to the device; the old\nkey (if any) is accepted until the device presents the new one, which\nthen becomes the active key. `active`: the device has a key, and a\nmessage without it is refused.",
        "enum": [
          "none",
          "pending",
          "active"
        ],
        "type": "string"
      },
      "Keys": {
        "description": "A device's keys themselves, shown only by the device's own view.",
        "properties": {
          "pending": {
            "description": "The new key on its way to the device; null when none is.",
            "type": [
              "string",
              "null"
            ]
          },
          "presented": {
            "description": "What the device's latest message carried. Saved with the device\nwhenever it changes, so it is kept across a restart.",
            "type": [
              "string",
              "null"
            ]
          },
          "registered": {
            "description": "The key the device has (enforced while its `key` is `active`); null\nwhen it has none.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "LabelledDevice": {
        "allOf": [
          {
            "description": "A device as the gateway knows it: who it is, whether it may talk to the\ngateway, where it stands with its key, and when and from where it was\nlast seen.",
            "properties": {
              "device": {
                "description": "The id the package identifies the device by: a serial number, a MAC\naddress, a cloud id.",
                "type": "string"
              },
              "endpoint": {
                "description": "The endpoint it belongs to.",
                "type": "string"
              },
              "first_seen": {
                "description": "None for a device that was registered and has not called in yet.",
                "format": "date-time",
                "type": [
                  "string",
                  "null"
                ]
              },
              "health": {
                "$ref": "#/components/schemas/DeviceHealth",
                "description": "How its messages have gone, counted by every instance that serves it."
              },
              "held": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/DeviceHold",
                    "description": "Present while the device is held (a gate of one of its actions did\nnot pass): nothing is handed to it until it is released, and what it\nsends is taken in as usual."
                  }
                ]
              },
              "id": {
                "description": "The device's number in the register.",
                "format": "int64",
                "minimum": 0,
                "type": "integer"
              },
              "info": {
                "description": "Facts the package reported: firmware, IP, user counts, capabilities.",
                "type": "object"
              },
              "key": {
                "$ref": "#/components/schemas/KeyState",
                "description": "Where it stands with its key."
              },
              "key_conflict_at": {
                "description": "When the device, while held, last presented a key other than the\none it was held with: someone else may be calling under its name.\nAdopting takes the key it was held with all the same;\n`adopt_presented_key` takes the latest instead. Cleared when its key\nis set, adopted or taken away.",
                "format": "date-time",
                "type": [
                  "string",
                  "null"
                ]
              },
              "key_held": {
                "description": "The device presented a key while it was held (waiting to be allowed,\nwith no key of its own), and the first such key is kept: adopting\nits key takes that one, the key it was held with, not a later one.",
                "type": "boolean"
              },
              "key_presented": {
                "$ref": "#/components/schemas/Presented",
                "description": "What its latest message carried for a key."
              },
              "key_refused_at": {
                "description": "When a message was last refused for carrying the wrong key, or none.",
                "format": "date-time",
                "type": [
                  "string",
                  "null"
                ]
              },
              "last_seen": {
                "description": "When its latest message came, as the instances that serve it know;\nnull until it calls in.",
                "format": "date-time",
                "type": [
                  "string",
                  "null"
                ]
              },
              "params": {
                "additionalProperties": {
                  "type": "string"
                },
                "description": "Values captured from the endpoint's path or topic template on the\nlatest message it was let in on (its first, until then); used to\naddress replies (e.g. MQTT reply topics).",
                "propertyNames": {
                  "type": "string"
                },
                "type": "object"
              },
              "remote_ip": {
                "description": "The address its latest message came from, of those it was let in\non (its first message, until it is let in; \"\" until it calls in). A\nmessage refused for the device's status or rate moves nothing.",
                "type": "string"
              },
              "status": {
                "$ref": "#/components/schemas/DeviceStatus"
              }
            },
            "required": [
              "id",
              "endpoint",
              "device",
              "status",
              "key",
              "key_presented",
              "remote_ip",
              "params",
              "info"
            ],
            "type": "object"
          },
          {
            "properties": {
              "external_ids": {
                "additionalProperties": {
                  "type": "string"
                },
                "description": "What other systems know the device by: system name to id.",
                "propertyNames": {
                  "type": "string"
                },
                "type": "object"
              },
              "labels": {
                "description": "The device's own labels, by name: what a sync group's placement\nrules pick members by, together with its endpoint's labels (the\ndevice's own win where both name one).",
                "type": "object"
              },
              "metadata": {
                "description": "Free-form data from other systems, kept as given.",
                "type": "object"
              }
            },
            "type": "object"
          }
        ],
        "description": "A device, with its own labels."
      },
      "Lane": {
        "description": "The queue a command waits in. Commands go out by lane, then oldest\nfirst: `urgent` (a person disabled, a credential taken away), then\n`interactive` (what an operator or an API caller asked for), then\n`sync` (keeping sync group members in step), then `bulk` (large fills:\nbackfill, inventory, resync).",
        "enum": [
          "urgent",
          "interactive",
          "sync",
          "bulk"
        ],
        "type": "string"
      },
      "LateFactView": {
        "description": "A fact stored after the close of the period of the day it is about.",
        "properties": {
          "fact": {
            "description": "The punch or correction as it was stored.",
            "type": "object"
          },
          "id": {
            "description": "The fact's id.",
            "type": "string"
          },
          "kind": {
            "description": "`punch`, or `correction`.",
            "example": "punch",
            "type": "string"
          },
          "stored": {
            "description": "When it was stored.",
            "example": "2026-10-12T15:29:08Z",
            "format": "date-time",
            "type": "string"
          },
          "stored_workday": {
            "description": "The workday it was stored on, in the policy's zone: where the open\nperiod took it.",
            "example": "2026-10-12",
            "type": "string"
          }
        },
        "required": [
          "kind",
          "id",
          "stored",
          "stored_workday",
          "fact"
        ],
        "type": "object"
      },
      "LeaveDayView": {
        "description": "Leave asked for on a day.",
        "properties": {
          "category": {
            "type": "string"
          },
          "request": {
            "description": "The leave request's id.",
            "type": "string"
          },
          "state": {
            "description": "approved, pending, rejected, refused...",
            "type": "string"
          },
          "time": {
            "example": "8h",
            "type": "string"
          }
        },
        "required": [
          "request",
          "category",
          "time",
          "state"
        ],
        "type": "object"
      },
      "LeaveDecision": {
        "description": "A decision on leave.",
        "properties": {
          "comment": {
            "type": "string"
          },
          "decision": {
            "description": "approve, reject or dispute.",
            "example": "approve",
            "type": "string"
          },
          "stage": {
            "description": "The stage of the approval rule for leave decided at (`approval`\nwhen the tenant has no rule for leave).",
            "type": "string"
          }
        },
        "required": [
          "stage",
          "decision"
        ],
        "type": "object"
      },
      "LeaveRecorded": {
        "description": "The request recorded.",
        "properties": {
          "id": {
            "type": "string"
          },
          "recorded": {
            "description": "new, or already (the same was recorded before).",
            "type": "string"
          }
        },
        "required": [
          "id",
          "recorded"
        ],
        "type": "object"
      },
      "LeaveView": {
        "description": "A leave request and where it stands.",
        "properties": {
          "approver": {
            "description": "Who the stage it waits for goes to, where the policy routed it\nelsewhere than the approval rule's approver.",
            "type": [
              "string",
              "null"
            ]
          },
          "by": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "comment": {
            "type": "string"
          },
          "days": {
            "description": "The time asked for on each day, as a duration (\"8h\").",
            "type": "object"
          },
          "fingerprint": {
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "organization": {
            "description": "The organization a decision at the stage it waits for waits on,\nwhere the stage is tied to a hierarchy.",
            "type": [
              "string",
              "null"
            ]
          },
          "recorded": {
            "example": "2026-10-01T14:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "refused": {
            "description": "Why the policy refused it, when it did.",
            "type": [
              "string",
              "null"
            ]
          },
          "replaces": {
            "type": [
              "string",
              "null"
            ]
          },
          "stage": {
            "description": "The stage it waits for (pending), or rejected at.",
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "description": "pending, approved, rejected, or refused (the policy's leave check\nrefused it: its approval cannot pass).",
            "type": "string"
          },
          "subject": {
            "description": "What its approval is of, and the fingerprint a decision names.",
            "type": "string"
          },
          "values": {
            "additionalProperties": {
              "type": "string"
            },
            "description": "What the policy reads of it beyond its days, by name.",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          }
        },
        "required": [
          "id",
          "category",
          "days",
          "by",
          "recorded",
          "comment",
          "state",
          "subject",
          "fingerprint"
        ],
        "type": "object"
      },
      "LedgerChange": {
        "description": "What one ledger would change by: only what differs is listed.",
        "properties": {
          "added": {
            "description": "Why: the ledger lines that would be added and taken away, each with\nwhat the policy's steps did to it (an adjustment for a closed\nperiod says which).",
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "approvals": {
            "description": "The approvals whose state would change, by subject.",
            "items": {
              "$ref": "#/components/schemas/StateChange"
            },
            "type": "array"
          },
          "balances": {
            "description": "The accrual balances at the period's end that would change.",
            "items": {
              "$ref": "#/components/schemas/BalanceChange"
            },
            "type": "array"
          },
          "exceptions_cleared": {
            "items": {
              "$ref": "#/components/schemas/ExceptionChange"
            },
            "type": "array"
          },
          "exceptions_raised": {
            "description": "The exceptions that would be raised, and those that would go.",
            "items": {
              "$ref": "#/components/schemas/ExceptionChange"
            },
            "type": "array"
          },
          "first": {
            "description": "The pay period's first and last day.",
            "example": "2026-10-05",
            "type": "string"
          },
          "hours": {
            "description": "The decimal hours of each pay category that would change.",
            "items": {
              "$ref": "#/components/schemas/HoursChange"
            },
            "type": "array"
          },
          "last": {
            "example": "2026-10-11",
            "type": "string"
          },
          "leave": {
            "description": "The leave requests whose state would change, by id.",
            "items": {
              "$ref": "#/components/schemas/StateChange"
            },
            "type": "array"
          },
          "money": {
            "description": "The money of each category and currency that would change; absent\nwhere the person has no rates set up.",
            "items": {
              "$ref": "#/components/schemas/MoneyChange"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "paid_hours": {
            "$ref": "#/components/schemas/Delta",
            "description": "The decimal hours in paid categories, and the time worked."
          },
          "removed": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "side": {
            "description": "pay or bill.",
            "type": "string"
          },
          "worked": {
            "$ref": "#/components/schemas/Delta"
          }
        },
        "required": [
          "side",
          "first",
          "last",
          "hours",
          "paid_hours",
          "worked",
          "balances",
          "exceptions_raised",
          "exceptions_cleared",
          "approvals",
          "leave",
          "added",
          "removed"
        ],
        "type": "object"
      },
      "LedgerView": {
        "description": "A person's ledger of one pay period, as last worked out.",
        "properties": {
          "first": {
            "description": "The pay period's first and last day.",
            "example": "2026-10-05",
            "type": "string"
          },
          "last": {
            "example": "2026-10-18",
            "type": "string"
          },
          "ledger": {
            "description": "The ledger: its days, each day's lines (time in a pay category\nagainst a labor context, with its decimal hours and what each policy\nstep did to it), exceptions, accruals and balances.",
            "type": "object"
          },
          "pending": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/PendingView",
                "description": "Set while the person is waiting to be worked out again: the ledger\nmay be about to change."
              }
            ]
          },
          "person": {
            "type": "string"
          },
          "recalculated": {
            "description": "How it was last worked out again, and why: what it was marked from,\nand each stage worked out again and from which workday (a stage not\nnamed was kept as it was).",
            "type": [
              "object",
              "null"
            ]
          },
          "side": {
            "description": "pay or bill.",
            "type": "string"
          }
        },
        "required": [
          "person",
          "side",
          "first",
          "last",
          "ledger"
        ],
        "type": "object"
      },
      "LimitsConfig": {
        "additionalProperties": false,
        "description": "Limits on what devices may do. Everything else is fixed, or sized from\nthe processors each instance may use.",
        "properties": {
          "max_body_bytes": {
            "default": 4194304,
            "description": "Largest device message body accepted, in bytes; a larger one is\nanswered 413. Greater than 0. Default 4194304 (4 MiB).",
            "minimum": 0,
            "type": "integer"
          },
          "max_pending_devices": {
            "default": 100,
            "description": "Devices waiting to be allowed, per endpoint. Strangers beyond this\nare refused (429) until some are allowed or removed, or stop calling\nfor a day and are forgotten. 0: no limit. Default 100.",
            "minimum": 0,
            "type": "integer"
          },
          "set_aside_days": {
            "default": 7,
            "description": "Days an MQTT message set aside is kept (one whose device waits to be\nallowed, registered or to present its key, that its package fails\non, or whose endpoint or tenant is stopped: the site's `/docs/mqtt/` page). Past\nit the message is dropped, and its device's tenant is told\n(`device.set_aside.expired`). Greater than 0. Default 7.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "tenants": {
            "default": {},
            "oneOf": [
              {
                "$ref": "#/components/schemas/TenantLimits",
                "description": "What each tenant may have and do unless it has limits of its own:\ndevices, devices waiting to be allowed, people, and device messages\na second. Absent or 0: no limit. Default: none."
              }
            ]
          },
          "traffic_body_bytes": {
            "default": 16384,
            "description": "Bytes of each request and response body kept in the traffic log\n(`GET /api/tenants/{tenant}/traffic`). 0 keeps no bodies (they can\ncontain credentials and biometric data). Default 16384 (16 KiB).",
            "minimum": 0,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "LineInstance": {
        "description": "What one instance runs of a package line.",
        "properties": {
          "error": {
            "description": "Why it does not run the wanted revision (it keeps the one it had);\nnull when nothing stops it.",
            "type": [
              "string",
              "null"
            ]
          },
          "idle": {
            "description": "True for a shared package's version no tenant takes: published,\nand not loaded on the instance until a tenant takes it.",
            "type": "boolean"
          },
          "instance": {
            "description": "The instance's name.",
            "type": "string"
          },
          "running": {
            "description": "The revision it runs; null when it runs none of the line, or does\nnot say.",
            "format": "int32",
            "type": [
              "integer",
              "null"
            ]
          },
          "wanted": {
            "description": "The revision it is to run: the line's active one, as far as it has\nread it. Null when it does not say.",
            "format": "int32",
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "instance"
        ],
        "type": "object"
      },
      "LineView": {
        "description": "A line: time in a pay category against a labor context.",
        "properties": {
          "category": {
            "type": "string"
          },
          "context": {
            "additionalProperties": {
              "type": "string"
            },
            "description": "Its labor context values, by dimension.",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "end": {
            "example": "2026-10-05T21:00:00Z",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "from": {
            "description": "Where its time came from, as the ledger says it, with every field\nit carries: `{\"segment\": {\"kind\": \"work\", \"punch\": \"p-1182\"}}` (the\npunch that started the work), `{\"entry\": {\"id\": ...}}`,\n`{\"leave\": {\"id\": ...}}`, `{\"policy\": {\"step\": ...}}`...",
            "type": "object"
          },
          "hours": {
            "example": "8.00",
            "type": "string"
          },
          "stamps": {
            "description": "What each policy step did to it, in order: `step`, `layers`, `did`.",
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "start": {
            "description": "When its time ran, as paid (after rounding); absent for a line of\ntime with no time of day (a labor entry of hours, leave).",
            "example": "2026-10-05T13:00:00Z",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "time": {
            "description": "Its exact time, and its decimal hours.",
            "example": "8h",
            "type": "string"
          }
        },
        "required": [
          "category",
          "time",
          "hours",
          "context",
          "from",
          "stamps"
        ],
        "type": "object"
      },
      "LinkBody": {
        "additionalProperties": false,
        "description": "Whom to link an unlinked person to.",
        "properties": {
          "person": {
            "description": "The person they are: an id the tenant knows them by (an employee\nid); null to unlink them.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "LinkView": {
        "description": "A link of an unlinked person.",
        "properties": {
          "by": {
            "type": "string"
          },
          "person": {
            "description": "From when it was stored, their punches are this person's; null:\ntheir own again.",
            "type": [
              "string",
              "null"
            ]
          },
          "seq": {
            "description": "Its place among the person's links, from 1.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "stored": {
            "example": "2026-10-07T15:00:00Z",
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "seq",
          "by",
          "stored"
        ],
        "type": "object"
      },
      "ListenerConfig": {
        "additionalProperties": false,
        "description": "A listener: where devices reach the gateway. An `http` listener binds\nan address and devices make requests to it; an `mqtt` listener connects\nto a broker and takes what devices publish there.",
        "properties": {
          "ack_wait_secs": {
            "description": "mqtt: seconds a message may hold back the acknowledgements of those\nthat came after it (acknowledgements go in the order messages came);\npast that, the listener starts no new message until it is done\nwith. Greater than 0. Default 30.",
            "format": "int64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "allow_from": {
            "description": "http: client addresses let in, as addresses or CIDR ranges. Set, every\nother address is refused (403). Checked before the endpoint's own.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "broker": {
            "description": "mqtt, required: the broker URL, mqtt://host:1883 or\nmqtts://host:8883 (TLS); the port defaults to 1883 or 8883. No login\nin the URL.",
            "type": [
              "string",
              "null"
            ]
          },
          "deny_from": {
            "description": "http: client addresses refused (403), whatever `allow_from` says.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "id": {
            "description": "Its id, as endpoints name it: 1 to 64 letters, digits, '-' or '_'.\nIt cannot be changed.",
            "type": "string"
          },
          "listen": {
            "description": "http, required: the socket address to bind, IP:port (\"0.0.0.0:8080\").",
            "type": [
              "string",
              "null"
            ]
          },
          "password": {
            "description": "mqtt: the broker password, with `username`. Kept in the database,\nnever shown.",
            "type": [
              "string",
              "null"
            ]
          },
          "proxy_protocol": {
            "description": "http: every connection starts with a PROXY protocol header (v1 or\nv2), as a layer 4 load balancer in front sends it, naming the\nclient. A connection without one is closed. The client the header\nnames is the request's address: `X-Forwarded-For` is not read. Only\nfor a listener that nothing but that load balancer can reach.",
            "type": "boolean"
          },
          "type": {
            "$ref": "#/components/schemas/ListenerKind",
            "description": "How devices reach it: `http` or `mqtt`."
          },
          "username": {
            "description": "mqtt: the user name to log in to the broker with.",
            "type": [
              "string",
              "null"
            ]
          },
          "window": {
            "description": "mqtt, required: how many messages the broker gives this client at once before it has acknowledged any: the broker's\nin-flight window for it (Mosquitto's `max_inflight_messages`, 20 unless set; a value above the broker's means\nnothing, one below it holds the listener to less). The listener holds no more unacknowledged messages than this,\nand starts every one it holds at once, so a device that publishes without pause has at most this many waiting.\n1 to 65535.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "type"
        ],
        "type": "object"
      },
      "ListenerInfo": {
        "description": "A listener as the admin API shows it: its settings (the password only\nas whether there is one) and how it is doing on the instance that\nanswers.",
        "properties": {
          "ack_wait_secs": {
            "description": "mqtt: seconds a message may hold back the acknowledgements of those\nafter it before no new message is started; absent: 30.",
            "format": "int64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "address": {
            "description": "http: the address bound while it runs (the port it was given when\n`listen` asks for port 0), else `listen`. mqtt: the broker.",
            "type": "string"
          },
          "allow_from": {
            "description": "http: client addresses let in; set, every other address is refused.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "broker": {
            "description": "mqtt: the broker it connects to.",
            "type": [
              "string",
              "null"
            ]
          },
          "connected_once": {
            "description": "mqtt: whether the listener has connected to its broker since it\nstarted on the instance that answers. The broker's persistent session\nfor a listener (which keeps a clock's messages while no instance is\nconnected) exists once any instance has connected; until one has, a\nbroker may acknowledge a clock's publishes with nobody subscribed.\nAbsent for http listeners.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "deny_from": {
            "description": "http: client addresses refused, whatever `allow_from` says.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "endpoints": {
            "description": "The ids of the endpoints on it that the instance that answers serves.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "error": {
            "description": "Why it is not running (or, for mqtt, not connected); null when\nnothing is wrong.",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "description": "The listener's id.",
            "type": "string"
          },
          "listen": {
            "description": "http: the address it is set to bind, IP:port.",
            "type": [
              "string",
              "null"
            ]
          },
          "password_set": {
            "description": "mqtt: whether a broker password is set. The password is never shown.",
            "type": "boolean"
          },
          "proxy_protocol": {
            "description": "http: connections start with a PROXY protocol header; absent when\nnot.",
            "type": "boolean"
          },
          "running": {
            "description": "It runs on the instance that answers.",
            "type": "boolean"
          },
          "stopped": {
            "description": "Stopped by hand: it stays stopped, across restarts too, until started.",
            "type": "boolean"
          },
          "type": {
            "$ref": "#/components/schemas/ListenerKind",
            "description": "How devices reach it: `http` or `mqtt`."
          },
          "username": {
            "description": "mqtt: the user name it logs in to the broker with.",
            "type": [
              "string",
              "null"
            ]
          },
          "window": {
            "description": "mqtt: how many unacknowledged messages its broker gives it at once (the broker's window).",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "password_set",
          "address",
          "running",
          "stopped",
          "endpoints"
        ],
        "type": "object"
      },
      "ListenerKind": {
        "description": "How devices reach the gateway. Packages declare which they support.",
        "enum": [
          "http",
          "mqtt"
        ],
        "type": "string"
      },
      "ListenerView": {
        "description": "A listener's settings as the export shows them: the mqtt password only\nas whether there is one.",
        "properties": {
          "ack_wait_secs": {
            "description": "mqtt: seconds a message may hold back the acknowledgements of those\nafter it before no new message is started; absent: 30.",
            "format": "int64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "allow_from": {
            "description": "http: the client addresses or CIDR ranges let in; absent: all.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "broker": {
            "description": "mqtt: the broker it connects to.",
            "type": [
              "string",
              "null"
            ]
          },
          "deny_from": {
            "description": "http: the client addresses or CIDR ranges refused.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "id": {
            "description": "The listener's id.",
            "type": "string"
          },
          "listen": {
            "description": "http: the address it binds, IP:port.",
            "type": [
              "string",
              "null"
            ]
          },
          "password_set": {
            "description": "mqtt: whether a broker password is set. The password is never shown.",
            "type": "boolean"
          },
          "proxy_protocol": {
            "description": "http: every connection starts with a PROXY protocol header; absent\nwhen not.",
            "type": "boolean"
          },
          "type": {
            "$ref": "#/components/schemas/ListenerKind",
            "description": "How devices reach it: `http` or `mqtt`."
          },
          "username": {
            "description": "mqtt: the user name it logs in to the broker with.",
            "type": [
              "string",
              "null"
            ]
          },
          "window": {
            "description": "mqtt: how many unacknowledged messages its broker gives it at once (the broker's window); it holds no more.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "password_set"
        ],
        "type": "object"
      },
      "LiveLine": {
        "description": "One line of a live view (`/api/tenants/{tenant}/wire/live`, `/api/tenants/{tenant}/stream`, the peer\nstreams).",
        "properties": {
          "data": {
            "description": "What the `kind` carries. `wire`: `at`, `conn`, `listener`,\n`endpoint`, `peer`, `dir`, `bytes`, `data`, `note`. `traffic`: a\ntraffic entry. `event`: an event. `device`: a device. `command`: a\ncommand. `peer`: `state` (`connected`, `unreachable`) and `error`.\n`dropped`: `records`. `end`: `reason` (`time`, `bytes`), `bytes`,\nand from the relay `instances` and `partial`.",
            "type": "object"
          },
          "instance": {
            "description": "The instance it came from.",
            "type": "string"
          },
          "kind": {
            "description": "What the line is: `wire` (a wire capture record), `traffic` (a\ndevice message), `event` (a stored event), `device` (a device whose\nrecord changed), `command` (a command queued or whose state changed);\nor `peer` (an instance connected, or could not be reached: the view\nis partial), `dropped` (records an instance dropped because they\ncame faster than they were read) and `end` (the view ended: its\nreason, and whether it was partial).",
            "type": "string"
          }
        },
        "required": [
          "kind",
          "instance",
          "data"
        ],
        "type": "object"
      },
      "LocationBody": {
        "additionalProperties": false,
        "description": "A location to make, or what to change of one.",
        "properties": {
          "external_ids": {
            "type": [
              "object",
              "null"
            ]
          },
          "id": {
            "description": "Its id (to make one; a change keeps it).",
            "type": [
              "string",
              "null"
            ]
          },
          "jurisdiction": {
            "description": "null takes it away.",
            "type": [
              "string",
              "null"
            ]
          },
          "labels": {
            "type": [
              "object",
              "null"
            ]
          },
          "metadata": {
            "type": [
              "object",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "values": {
            "description": "The labor context values work there takes; given, they replace all\nit had.",
            "type": [
              "object",
              "null"
            ]
          },
          "zone": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "LocationView": {
        "description": "A work location.",
        "properties": {
          "created": {
            "example": "2026-10-01T14:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "external_ids": {
            "type": "object"
          },
          "id": {
            "description": "Its id within the tenant: 1 to 64 letters, digits, '-' or '_'.",
            "type": "string"
          },
          "jurisdiction": {
            "description": "The jurisdiction, as the builder names it; never read by the engine.",
            "example": "us-ca",
            "type": [
              "string",
              "null"
            ]
          },
          "labels": {
            "type": "object"
          },
          "metadata": {
            "type": "object"
          },
          "name": {
            "type": "string"
          },
          "values": {
            "description": "The labor context values the work of a day there takes where the\npunches and the shift give none.",
            "type": "object"
          },
          "zone": {
            "description": "The time zone days there are worked out in.",
            "example": "America/Los_Angeles",
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "zone",
          "external_ids",
          "labels",
          "metadata",
          "created"
        ],
        "type": "object"
      },
      "LogFormat": {
        "description": "How each line is written.",
        "enum": [
          "text",
          "json"
        ],
        "type": "string"
      },
      "LogsView": {
        "description": "The log level, and the format the instance that answers writes in\n(`/api/logs`).",
        "properties": {
          "format": {
            "default": "text",
            "oneOf": [
              {
                "$ref": "#/components/schemas/LogFormat",
                "description": "How the instance that answers writes its log lines: `json` when its\nstandard output is not a terminal, `text` when it is. It cannot be\nchanged through the API."
              }
            ]
          },
          "level": {
            "default": "",
            "description": "What is logged, in `RUST_LOG` syntax (\"info\", \"warn,houradvantage=debug\"):\nthe level the instance that answers uses.",
            "type": "string"
          }
        },
        "type": "object"
      },
      "Manifest": {
        "additionalProperties": false,
        "description": "A package's manifest: `package.toml` as the package declares it.",
        "properties": {
          "commands": {
            "$ref": "#/components/schemas/Commands",
            "description": "How the vendor's devices answer the commands they are handed\n(`[commands]`): what the gateway may conclude from an answer. Nothing\nis concluded when it is not declared."
          },
          "delivery": {
            "$ref": "#/components/schemas/Delivery",
            "description": "What happens to a message whose events could not be delivered to a\nsink. `ack` unless declared."
          },
          "description": {
            "description": "What the package is for (\"\" when it does not say).",
            "type": "string"
          },
          "host_api": {
            "description": "The host API the package is written for: the functions it may call\nand the declarations it is read for. This build runs 1 and 2.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "kind": {
            "$ref": "#/components/schemas/PackageKind",
            "description": "What it is: `protocol` (how a device talks: the default) or\n`policy` (a tenant's decisions at fixed moments, its hooks)."
          },
          "name": {
            "description": "The package's name.",
            "type": "string"
          },
          "requires": {
            "$ref": "#/components/schemas/Requires",
            "description": "The vars and secrets it cannot run without (`[requires]`): it is\nnot activated in a cluster that lacks one. Absent when it needs none."
          },
          "transports": {
            "description": "Listener types the package can be bound to. `http` unless declared.\nA policy package is bound to none: it is not read.",
            "items": {
              "$ref": "#/components/schemas/ListenerKind"
            },
            "type": "array"
          },
          "vendor": {
            "description": "Who makes the devices it serves (\"\" when it does not say).",
            "type": "string"
          },
          "version": {
            "description": "Its version, dotted numbers (\"3.4.0\"); the first two make its line.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "version",
          "host_api"
        ],
        "type": "object"
      },
      "MissedHand": {
        "additionalProperties": false,
        "description": "`[commands.missed_hand]`: the slice of the device's hand `M.missed` is given for a message that carries results. The commands\nof `actions` and the ones the message answers, and, with `up_to_answered`, only those handed out at or before the newest of\nthe ones it answers. The hand is in the order it was handed out.",
        "properties": {
          "actions": {
            "$ref": "#/components/schemas/HandActions",
            "description": "Which commands: `\"all\"` (the default), `\"writes\"` (the commands the package says write something), or a list of\ncommand names."
          },
          "up_to_answered": {
            "description": "Only the commands handed out at or before the newest one the message answers.",
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "MoneyChange": {
        "description": "Money of a currency and pay category, in minor units, before and after.",
        "properties": {
          "after": {
            "format": "int64",
            "type": "integer"
          },
          "before": {
            "format": "int64",
            "type": "integer"
          },
          "category": {
            "type": "string"
          },
          "change": {
            "format": "int64",
            "type": "integer"
          },
          "currency": {
            "type": "string"
          }
        },
        "required": [
          "category",
          "currency",
          "before",
          "after",
          "change"
        ],
        "type": "object"
      },
      "MoneyView": {
        "description": "Money of one currency, in its minor units (cents).",
        "properties": {
          "amount": {
            "format": "int64",
            "type": "integer"
          },
          "category": {
            "description": "The pay category; absent for a total.",
            "type": [
              "string",
              "null"
            ]
          },
          "currency": {
            "type": "string"
          }
        },
        "required": [
          "currency",
          "amount"
        ],
        "type": "object"
      },
      "MoveBody": {
        "additionalProperties": false,
        "description": "A move: a new parent from a day.",
        "properties": {
          "from": {
            "description": "The day it is under the new parent from.",
            "example": "2026-10-12",
            "type": "string"
          },
          "parent": {
            "description": "The new parent; null: a root.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "from"
        ],
        "type": "object"
      },
      "NewDeliveryKey": {
        "additionalProperties": false,
        "description": "A delivery key to issue.",
        "properties": {
          "label": {
            "description": "What it is for: the sender it is given to. At most 200 characters.",
            "type": "string"
          }
        },
        "type": "object"
      },
      "NewDevices": {
        "description": "What an endpoint does with a device nobody has registered.",
        "enum": [
          "allow",
          "hold",
          "refuse"
        ],
        "type": "string"
      },
      "NewExport": {
        "description": "An export asked for.",
        "properties": {
          "employer": {
            "description": "Whose people: an employer's id, or `*` for every employer's (and\nthe unlinked people's). Without it, the tenant's employer, where it\nhas one only.",
            "type": [
              "string",
              "null"
            ]
          },
          "exporter": {
            "description": "The exporter: `<package>/<name>` (`standard/csv`).",
            "type": "string"
          },
          "only": {
            "description": "Whose ledgers it writes: all (default), closed or approved.",
            "type": [
              "string",
              "null"
            ]
          },
          "params": {
            "description": "The exporter's parameters.",
            "type": "object"
          },
          "period": {
            "description": "The pay period's first day.",
            "example": "2026-10-05",
            "type": "string"
          },
          "side": {
            "description": "The side: pay (default), or a bill side.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "exporter",
          "period"
        ],
        "type": "object"
      },
      "NewFacts": {
        "additionalProperties": false,
        "description": "Facts to record about a person.",
        "properties": {
          "facts": {
            "description": "Each as `{\"<kind>\": {...}}`, as `GET .../facts` shows them.",
            "items": {
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "facts"
        ],
        "type": "object"
      },
      "NewLeave": {
        "description": "Leave asked for.",
        "properties": {
          "category": {
            "description": "The pay category its time is in (vacation, sick...).",
            "type": "string"
          },
          "comment": {
            "type": "string"
          },
          "days": {
            "description": "The time asked for on each day: \"8h\", \"4h 30m\".",
            "type": "object"
          },
          "id": {
            "description": "The request's id, to send it again safely; one is made without it.",
            "type": [
              "string",
              "null"
            ]
          },
          "replaces": {
            "description": "The request this one replaces (a change: asked for, and approved,\nagain).",
            "type": [
              "string",
              "null"
            ]
          },
          "values": {
            "additionalProperties": {
              "type": "string"
            },
            "description": "What the tenant's policy reads of the request beyond its days, by\nname: the relationship of a bereavement (`{\"relationship\":\n\"spouse\"}`), the reason for family leave. Part of what an approval\nis of.",
            "example": {
              "relationship": "spouse"
            },
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          }
        },
        "required": [
          "category",
          "days"
        ],
        "type": "object"
      },
      "NewNote": {
        "description": "A note about an exception.",
        "properties": {
          "action": {
            "description": "acknowledge (seen, being dealt with: it still keeps approval back),\nexcuse (it stands, accepted as it is: it keeps nothing back), or\nreopen.",
            "example": "excuse",
            "type": "string"
          },
          "comment": {
            "type": "string"
          },
          "id": {
            "description": "The note's id, to send it again safely; one is made without it.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "action"
        ],
        "type": "object"
      },
      "NewTenant": {
        "additionalProperties": false,
        "description": "A tenant to create.",
        "properties": {
          "external_ids": {
            "type": "object"
          },
          "id": {
            "description": "Its id: 1 to 64 letters, digits, '-' or '_' (as Connect's ids, so\na token can be scoped to it); one is made without it.",
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "description": "At most 16 KiB as JSON, 16 levels deep.",
            "type": "object"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "description": "suspended to create it suspended (to load its data before anything\nis worked out); active by default.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "name"
        ],
        "type": "object"
      },
      "NewToken": {
        "additionalProperties": false,
        "description": "The token to make.",
        "properties": {
          "name": {
            "description": "What it is for, unique among the tokens: \"ci\", \"backup-job\". 1 to 64\nletters, digits, '.', '_' or '-'. Changes made with the token are\nrecorded as made by `token:<name>`.",
            "example": "backup-job",
            "type": "string"
          },
          "scope": {
            "description": "What it reaches: absent or empty, the whole install; `connect:<tenant>`,\none Connect tenant's routes only (`/api/tenants/<tenant>/...`);\n`attend:<tenant>`, one Time and Attendance tenant's only\n(`/api/attendance/tenants/<tenant>/...`). A scoped token reaches no\ninstall-level route.",
            "example": "connect:acme",
            "type": "string"
          }
        },
        "required": [
          "name"
        ],
        "type": "object"
      },
      "NewValue": {
        "additionalProperties": false,
        "description": "The value to set.",
        "properties": {
          "value": {
            "description": "Text, at most 64 KiB (65536 bytes).",
            "example": "HQ-01",
            "type": "string"
          }
        },
        "required": [
          "value"
        ],
        "type": "object"
      },
      "NoteView": {
        "description": "The note recorded.",
        "properties": {
          "id": {
            "type": "string"
          },
          "recorded": {
            "description": "new, or already (the same note was recorded before).",
            "type": "string"
          }
        },
        "required": [
          "id",
          "recorded"
        ],
        "type": "object"
      },
      "OptionInfo": {
        "description": "An endpoint option the package reads (set in the endpoint's `options`).",
        "properties": {
          "description": {
            "description": "What it does.",
            "type": "string"
          },
          "name": {
            "description": "The option's name.",
            "type": "string"
          },
          "required": {
            "description": "An endpoint of this package must set it.",
            "type": "boolean"
          },
          "type": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OptionType",
                "description": "What the value must be, if the package says."
              }
            ]
          }
        },
        "required": [
          "name",
          "required",
          "description"
        ],
        "type": "object"
      },
      "OptionType": {
        "description": "The kinds of value an option can be declared to take: `boolean`,\n`number`, `string` or `timezone` (a zone name such as\n\"America/Chicago\", or a fixed offset such as \"-05:00\").",
        "enum": [
          "boolean",
          "number",
          "string",
          "timezone"
        ],
        "type": "string"
      },
      "OrganizationBody": {
        "additionalProperties": false,
        "description": "An organization to make, or what to change of one.",
        "properties": {
          "external_ids": {
            "description": "In place of all it had.",
            "type": [
              "object",
              "null"
            ]
          },
          "id": {
            "description": "Its id (to make one; a change keeps it).",
            "type": [
              "string",
              "null"
            ]
          },
          "labels": {
            "description": "In place of all it had.",
            "type": [
              "object",
              "null"
            ]
          },
          "metadata": {
            "description": "In place of all it had: at most 16 KiB as JSON, 16 levels deep.",
            "type": [
              "object",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "parent": {
            "description": "Its parent from the beginning (to make one; a move changes it from a\nday).",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "OrganizationView": {
        "description": "An organization of a hierarchy.",
        "properties": {
          "created": {
            "example": "2026-10-01T14:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "external_ids": {
            "type": "object"
          },
          "hierarchy": {
            "type": "string"
          },
          "id": {
            "description": "Its id within the hierarchy: 1 to 64 letters, digits, '-' or '_'.",
            "type": "string"
          },
          "labels": {
            "description": "What selectors pick it by.",
            "type": "object"
          },
          "metadata": {
            "description": "Kept as given, never read by the engine: what policies read.",
            "type": "object"
          },
          "name": {
            "type": "string"
          },
          "parents": {
            "description": "Its parents, each from a day on, the first from the beginning: a\nmove is a parent from its day.",
            "items": {
              "$ref": "#/components/schemas/ParentView"
            },
            "type": "array"
          }
        },
        "required": [
          "hierarchy",
          "id",
          "name",
          "parents",
          "external_ids",
          "labels",
          "metadata",
          "created"
        ],
        "type": "object"
      },
      "OrganizationsPage": {
        "description": "A page of organizations.",
        "properties": {
          "next": {
            "description": "Pass as `after` for the next page; null: there is none.",
            "type": [
              "string",
              "null"
            ]
          },
          "organizations": {
            "items": {
              "$ref": "#/components/schemas/OrganizationView"
            },
            "type": "array"
          }
        },
        "required": [
          "organizations"
        ],
        "type": "object"
      },
      "PackageDetail": {
        "description": "A package by name (`GET /api/packages/{name}`).",
        "properties": {
          "catalog": {
            "description": "What the instance that answers runs of the package, line by line:\nthe full catalog (manifest, routes, commands, actions, settings,\noptions), every parameter typed.",
            "items": {
              "$ref": "#/components/schemas/PackageView"
            },
            "type": "array"
          },
          "lines": {
            "description": "Each active line: its revision and what every instance runs of it.",
            "items": {
              "$ref": "#/components/schemas/ActiveLine"
            },
            "type": "array"
          },
          "name": {
            "description": "The package's name.",
            "type": "string"
          },
          "revisions": {
            "description": "Every revision kept, oldest first, each saying whether it is active.",
            "items": {
              "$ref": "#/components/schemas/KeptRevision"
            },
            "type": "array"
          }
        },
        "required": [
          "name",
          "revisions",
          "lines",
          "catalog"
        ],
        "type": "object"
      },
      "PackageKind": {
        "description": "What a package is.",
        "enum": [
          "protocol",
          "policy"
        ],
        "type": "string"
      },
      "PackageLine": {
        "description": "A package line, as `GET /api/packages` lists it.",
        "properties": {
          "active": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ActiveRevision",
                "description": "The revision active for the line; null if none is."
              }
            ]
          },
          "line": {
            "description": "The line: the name and major.minor version (\"zk-push@3.4\"). One\nrevision of each line is active.",
            "type": "string"
          },
          "name": {
            "description": "The package's name.",
            "type": "string"
          },
          "revisions": {
            "description": "How many revisions of the package (every line of it) are kept.",
            "minimum": 0,
            "type": "integer"
          },
          "running": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/RunningPackage",
                "description": "What the instance that answers runs of the line; null if nothing."
              }
            ]
          }
        },
        "required": [
          "name",
          "line",
          "revisions"
        ],
        "type": "object"
      },
      "PackageRevision": {
        "description": "A package revision as kept (its bundle aside).",
        "properties": {
          "failed": {
            "description": "Its scenarios failed when it was pushed: what failed, a line each\n(`tests/door.toml: ...`). A failed revision is kept to be looked at\nand is never activated. Absent: they passed.",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "hash": {
            "description": "`sha256:<hex>` over its files.",
            "type": "string"
          },
          "host_api": {
            "description": "The host API it is written for.",
            "format": "int32",
            "type": "integer"
          },
          "line": {
            "description": "Its line: one revision of each line is active. A protocol or a\ntenant's package: its name and major.minor version (`zk-push@3.4`).\nA shared package: its name and whole version (`*:overtime@2.3.1`),\nso every version published stays there for whoever pins it.",
            "type": "string"
          },
          "name": {
            "description": "The package's name.",
            "type": "string"
          },
          "pushed_at": {
            "description": "When it was pushed.",
            "format": "date-time",
            "type": "string"
          },
          "pushed_by": {
            "description": "Who pushed it: the admin login's user name, `token:<name>` for an\nAPI token, or `local` without a login.",
            "type": "string"
          },
          "revision": {
            "description": "Counted per name from 1, in the order pushed.",
            "format": "int32",
            "type": "integer"
          },
          "size": {
            "description": "The bundle's size, in bytes.",
            "format": "int64",
            "type": "integer"
          },
          "version": {
            "description": "The package version it holds, from its manifest.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "revision",
          "version",
          "line",
          "host_api",
          "hash",
          "size",
          "pushed_at",
          "pushed_by"
        ],
        "type": "object"
      },
      "PackageView": {
        "description": "A loaded package: its whole catalog, as it declares it, every\nparameter typed.",
        "properties": {
          "actions": {
            "description": "The actions it offers, standard and its own.",
            "items": {
              "$ref": "#/components/schemas/ActionInfo"
            },
            "type": "array"
          },
          "commands": {
            "description": "The commands it can send to devices by name: every one but those\nonly its own actions use.",
            "items": {
              "$ref": "#/components/schemas/CommandInfo"
            },
            "type": "array"
          },
          "hash": {
            "description": "Its bundle's content hash, `sha256:<hex>`; null when it runs from a\nfolder.",
            "type": [
              "string",
              "null"
            ]
          },
          "hooks": {
            "description": "A policy package's hooks (`route`, `joined`, `moved`, `back`,\n`enrolled`); absent for a protocol package.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "id": {
            "description": "Its name and version, \"name@version\": \"zk-push@3.4.0\".",
            "type": "string"
          },
          "line": {
            "description": "Its line, the name and major.minor version: \"zk-push@3.4\".",
            "type": "string"
          },
          "manifest": {
            "$ref": "#/components/schemas/Manifest",
            "description": "Its manifest (package.toml)."
          },
          "options": {
            "description": "The endpoint options it reads (`options` of an endpoint).",
            "items": {
              "$ref": "#/components/schemas/OptionInfo"
            },
            "type": "array"
          },
          "revision": {
            "description": "The revision it was loaded from; null when it runs from a folder\n(`hourd dev`).",
            "format": "int32",
            "type": [
              "integer",
              "null"
            ]
          },
          "routes": {
            "description": "The device messages it handles, route by route.",
            "items": {
              "$ref": "#/components/schemas/RouteInfo"
            },
            "type": "array"
          },
          "settings": {
            "description": "Every device setting it can set or read.",
            "items": {
              "$ref": "#/components/schemas/Setting"
            },
            "type": "array"
          }
        },
        "required": [
          "id",
          "line",
          "manifest",
          "routes",
          "commands",
          "actions",
          "settings",
          "options"
        ],
        "type": "object"
      },
      "Param": {
        "description": "One parameter: its name, type and what narrows it.",
        "properties": {
          "description": {
            "description": "What it is. Absent when the package does not say.",
            "type": "string"
          },
          "items": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Param",
                "description": "`list`: what each item is (its name is the list's)."
              }
            ]
          },
          "max": {
            "description": "`integer`: the largest value.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "max_bytes": {
            "description": "`binary`: the most bytes, decoded.",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "max_items": {
            "description": "`list`, `cards`: the most items.",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "max_length": {
            "description": "`string`, `secret`: the most characters.",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "min": {
            "description": "`integer`: the smallest value.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "name": {
            "description": "The parameter's name, as a request gives it in `params`.",
            "type": "string"
          },
          "pattern": {
            "description": "`string`, `secret`: a regular expression the whole value matches.",
            "type": [
              "string",
              "null"
            ]
          },
          "required": {
            "description": "A request must give it. False unless said.",
            "type": "boolean"
          },
          "sensitive": {
            "description": "A secret or personal data (a password, a card number, a template, a\nphoto): it reaches the device in the payload and is kept and shown\nnowhere else, only as its size.",
            "type": "boolean"
          },
          "type": {
            "$ref": "#/components/schemas/ParamType",
            "description": "The kind of value it takes."
          },
          "values": {
            "description": "`enum`: the values it may be.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "name",
          "type"
        ],
        "type": "object"
      },
      "ParamType": {
        "description": "The kinds of value a parameter takes: `string` (text; `max_length` and\n`pattern` narrow it), `integer` (a whole number; `min` and `max` narrow\nit), `boolean` (true or false; \"true\"/\"false\", 1/0 and \"1\"/\"0\" are\ntaken too), `enum` (one of `values`), `secret` (text that is a secret,\nkept and shown only as its size), `binary` (bytes as base64 text;\n`max_bytes` narrows it), `wall_time` (wall-clock time on the device:\n\"2026-01-15\", \"2026-01-15 08:00\" or \"2026-01-15 08:00:00\", a \"T\" may\nstand for the space), `rfc3339` (an instant), `cards` (a list of cards,\neach `{number, format?, facility?}` or a plain card number),\n`biometrics` (a list of biometric templates; standard actions only),\n`object` (a JSON object the description explains; standard actions\nonly) or `list` (a list of `items`; text separated by commas is taken\ntoo; `max_items` narrows it).",
        "enum": [
          "string",
          "integer",
          "boolean",
          "enum",
          "secret",
          "binary",
          "wall_time",
          "rfc3339",
          "cards",
          "biometrics",
          "object",
          "list"
        ],
        "type": "string"
      },
      "ParentView": {
        "description": "An organization's parent from a day on.",
        "properties": {
          "from": {
            "description": "The day it is the parent from; absent: from the beginning.",
            "example": "2026-10-12",
            "type": [
              "string",
              "null"
            ]
          },
          "parent": {
            "description": "The parent; null: a root from then.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "PayPeriodView": {
        "description": "A pay period, and where it stands for the person.",
        "properties": {
          "approved": {
            "description": "Approved at every stage of the period's approval.",
            "type": "boolean"
          },
          "closed": {
            "description": "When it was closed; null: open.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "first": {
            "example": "2026-10-05",
            "type": "string"
          },
          "kept": {
            "description": "A ledger of it is kept; false: it is ahead, or not worked out yet.",
            "type": "boolean"
          },
          "last": {
            "example": "2026-10-18",
            "type": "string"
          },
          "pending": {
            "description": "The person waits to be worked out again from a day of it or before:\nwhat is kept of it is about to change.",
            "type": "boolean"
          }
        },
        "required": [
          "first",
          "last",
          "kept",
          "approved",
          "pending"
        ],
        "type": "object"
      },
      "PayPeriodsView": {
        "description": "A person's pay periods over a run of days.",
        "properties": {
          "periods": {
            "description": "Each period holding a day from `from` through `to`, the earliest\nfirst.",
            "items": {
              "$ref": "#/components/schemas/PayPeriodView"
            },
            "type": "array"
          },
          "person": {
            "type": "string"
          },
          "side": {
            "type": "string"
          }
        },
        "required": [
          "person",
          "side",
          "periods"
        ],
        "type": "object"
      },
      "Peer": {
        "description": "A running instance, as the instances' directory lists it.",
        "properties": {
          "address": {
            "description": "Where its admin API is reached (\"http://192.0.2.21:9090\"); null when\nthe others cannot reach it.",
            "type": [
              "string",
              "null"
            ]
          },
          "applied_version": {
            "description": "The config version it has fully put into use; null when it does not\nsay.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "config_error": {
            "description": "Why it could not put the newest config version into use (it stays\non `applied_version` and tries again); null when nothing stops it.",
            "type": [
              "string",
              "null"
            ]
          },
          "instance": {
            "description": "The instance's name.",
            "type": "string"
          },
          "packages": {
            "description": "What it runs of each active package line, by line: `{\"wanted\":\nrevision, \"running\": revision, \"error\": why it does not run the\nwanted one}`. Null when it does not say.",
            "type": [
              "object",
              "null"
            ]
          },
          "seen_at": {
            "description": "When it last said it was alive.",
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "instance",
          "seen_at"
        ],
        "type": "object"
      },
      "PeersView": {
        "description": "The instances running now (`GET /api/peers`).",
        "properties": {
          "config_version": {
            "description": "The config version now: what every instance is to reach.",
            "format": "int64",
            "type": "integer"
          },
          "environment": {
            "description": "The cluster's environment, as the instance that answered was given\nit (`HOURADVANTAGE_ENVIRONMENT`); absent when it is not named.",
            "type": "string"
          },
          "instance": {
            "description": "The instance that answered.",
            "type": "string"
          },
          "peers": {
            "description": "Each instance running, with the config version it has put into use\n(`applied_version`).",
            "items": {
              "$ref": "#/components/schemas/Peer"
            },
            "type": "array"
          },
          "production": {
            "description": "True when the cluster is production (`HOURADVANTAGE_PRODUCTION`); absent\nwhen it is not.",
            "type": "boolean"
          }
        },
        "required": [
          "instance",
          "config_version",
          "peers"
        ],
        "type": "object"
      },
      "PendingPage": {
        "description": "A page of those waiting to be worked out.",
        "properties": {
          "next": {
            "description": "Pass as `after` for the next page; null: there is none.",
            "type": [
              "string",
              "null"
            ]
          },
          "pending": {
            "items": {
              "$ref": "#/components/schemas/PendingView"
            },
            "type": "array"
          }
        },
        "required": [
          "pending"
        ],
        "type": "object"
      },
      "PendingView": {
        "description": "A person waiting to have their ledgers worked out again.",
        "properties": {
          "failed": {
            "description": "Why the last try failed, if it did: it is tried again later, or at\nonce when anything new is recorded for them.",
            "type": [
              "string",
              "null"
            ]
          },
          "person": {
            "type": "string"
          },
          "since_at": {
            "description": "Their ledgers are worked out again from the workday this instant is\non for them (a punch's, or when something was recorded)...",
            "example": "2026-10-05T13:02:00Z",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "since_day": {
            "description": "...or from this workday (one a change names), whichever is earlier.\n`0001-01-01` is every workday: a change that reaches everything they\nhave (a layer or an assignment with no `from`).",
            "example": "2026-10-05",
            "type": [
              "string",
              "null"
            ]
          },
          "unlinked": {
            "description": "Whether they are an unlinked person (`GET .../unlinked`).",
            "type": "boolean"
          }
        },
        "required": [
          "person"
        ],
        "type": "object"
      },
      "PeoplePage": {
        "description": "A page of people.",
        "properties": {
          "next": {
            "description": "Pass as `after` for the next page; null: there is none.",
            "type": [
              "string",
              "null"
            ]
          },
          "people": {
            "description": "Their ids.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "people"
        ],
        "type": "object"
      },
      "PeoplePolicy": {
        "additionalProperties": false,
        "description": "`people`: users and their credentials.",
        "properties": {
          "authority": {
            "$ref": "#/components/schemas/Authority",
            "description": "Who decides people: `group` (the default) or `shared`."
          },
          "biometrics": {
            "description": "Biometric templates and photos (face and display photos) move\nbetween members. They are sealed at rest, which needs\n`HOURADVANTAGE_SECRET_KEY`. Default false.",
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "PeriodSpan": {
        "description": "A pay period's first and last day.",
        "properties": {
          "first": {
            "example": "2026-10-05",
            "type": "string"
          },
          "last": {
            "example": "2026-10-18",
            "type": "string"
          }
        },
        "required": [
          "first",
          "last"
        ],
        "type": "object"
      },
      "PeriodSummary": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PayPeriodView"
          },
          {
            "properties": {
              "in_range": {
                "$ref": "#/components/schemas/Totals",
                "description": "The totals of its days from `from` through `to`."
              },
              "totals": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/Totals",
                    "description": "The whole period's totals, as its ledger has them; absent where no\nledger of it is kept."
                  }
                ]
              }
            },
            "required": [
              "in_range"
            ],
            "type": "object"
          }
        ],
        "description": "A pay period the days touch."
      },
      "PersonDays": {
        "description": "One person's days.",
        "properties": {
          "days": {
            "description": "Each day from `from` through `to`; absent where only totals are\nasked for.",
            "items": {
              "$ref": "#/components/schemas/DayView"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "error": {
            "description": "Why they cannot be read (no zone set up for them, a policy step\nfailing); the rest is then empty.",
            "type": [
              "string",
              "null"
            ]
          },
          "periods": {
            "description": "Each pay period holding a day from `from` through `to`, the\nearliest first.",
            "items": {
              "$ref": "#/components/schemas/PeriodSummary"
            },
            "type": "array"
          },
          "person": {
            "type": "string"
          },
          "totals": {
            "$ref": "#/components/schemas/Totals",
            "description": "The totals of every day from `from` through `to`."
          }
        },
        "required": [
          "person",
          "totals",
          "periods"
        ],
        "type": "object"
      },
      "PersonFieldsView": {
        "description": "A person's fields, as written under `fields` (each optional; null\nclears it).",
        "properties": {
          "access_groups": {
            "default": null,
            "description": "The keys of the access groups (access rows) the person is in.",
            "items": {},
            "type": [
              "array",
              "null"
            ]
          },
          "biometrics": {
            "default": null,
            "description": "false: the person's templates and photos are deleted, from members first.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "cards": {
            "default": null,
            "description": "`[{\"number\": \"12345\"}]`: replaces the person's cards. Each card has\na `number`, and may have a `format` (`raw`, `w26`, `w34`) and a\n`facility`; a card number belongs to one person of the group.",
            "items": {
              "type": "object"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "devices": {
            "default": null,
            "description": "`\"<endpoint>/<device>\"`: the members the person is placed on, instead\nof by the group's rules (an empty list: none).",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "enabled": {
            "default": null,
            "description": "false: the person is kept, but switched off on the devices.",
            "type": [
              "boolean",
              "null"
            ]
          },
          "external_ids": {
            "description": "`{\"payroll\": \"104552\"}`: replaces the ids other systems know the person\nby, one per system, each held by one person of the group. Never sent\nto a device; a sink whose `person_id`\nnames a system is sent that id with each event about the person.",
            "type": [
              "object",
              "null"
            ]
          },
          "labels": {
            "description": "The person's labels, which the group's placement rules pick people by.",
            "type": [
              "object",
              "null"
            ]
          },
          "metadata": {
            "description": "Free-form data from other systems: an object of at most 16 KiB,\nnever read by Connect nor sent to a device.",
            "type": [
              "object",
              "null"
            ]
          },
          "name": {
            "default": null,
            "description": "The person's name.",
            "type": [
              "string",
              "null"
            ]
          },
          "role": {
            "default": null,
            "description": "The person's role on the devices, as their packages name it\n(`user`, `enroller`, `admin` on ZKTeco clocks).",
            "type": [
              "string",
              "null"
            ]
          },
          "routes": {
            "default": null,
            "description": "The person's own routes: where their punches can go. Each replaces\nthe endpoint's and the group's default routes to the same system;\none that names a `person_id` links the person.",
            "items": {
              "$ref": "#/components/schemas/Route"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "valid_from": {
            "default": null,
            "description": "When the person becomes valid, as the members' packages take it.",
            "type": [
              "string",
              "null"
            ]
          },
          "valid_to": {
            "default": null,
            "description": "When the person stops being valid, as the members' packages take it.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "PersonRoutesView": {
        "description": "Where a person's punches can go: the defaults (the endpoint's over the\ngroup's), their own routes, and the candidates those make.",
        "properties": {
          "candidates": {
            "default": [],
            "description": "Exactly one: a punch goes there. None: unrouted where routing is in\nuse. Several: the endpoint's policy decides.",
            "items": {
              "$ref": "#/components/schemas/Route"
            },
            "type": "array"
          },
          "defaults": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/Route"
            },
            "type": "array"
          },
          "own": {
            "default": [],
            "items": {
              "$ref": "#/components/schemas/Route"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "PersonSecretsView": {
        "description": "A person's secrets, as written under `secrets`: write-only, null clears.",
        "properties": {
          "keypad_pin": {
            "default": null,
            "description": "The PIN the person types on the keypad.",
            "type": [
              "string",
              "null"
            ]
          },
          "password": {
            "default": null,
            "description": "The person's password on the device.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "PersonView": {
        "description": "A person (`person.deleted`: deleted, shown until every member confirmed\nit), their credentials (deleted ones too, flagged so), and where every\nmember of the group is with them.",
        "properties": {
          "credentials": {
            "default": [],
            "description": "The person's credentials, without their bytes (`sha256` instead);\ndeleted ones flagged `deleted` until every member confirmed them.",
            "items": {
              "$ref": "#/components/schemas/SyncRowView"
            },
            "type": "array"
          },
          "id_changes": {
            "default": [],
            "description": "Each member's part in the change that gave the person this id.",
            "items": {
              "$ref": "#/components/schemas/SyncIdChangeView"
            },
            "type": "array"
          },
          "members": {
            "default": [],
            "description": "Every member: `state` in_sync, pending (not looked at yet, or being\nsent: `action`), not_placed, unsupported (`reason`), failed\n(`error`, `attempts`), not_applicable; what it leaves\nout in `omitted`. For a deleted person, where it is with the delete:\npending until it confirmed it, then deleted.",
            "items": {
              "$ref": "#/components/schemas/SyncPersonMemberView"
            },
            "type": "array"
          },
          "person": {
            "default": {
              "changed_at": "1970-01-01T00:00:00Z",
              "changed_by": "",
              "deleted": false,
              "domain": "",
              "fields": {},
              "key": "",
              "kind": "",
              "version": 0
            },
            "oneOf": [
              {
                "$ref": "#/components/schemas/SyncRowView",
                "description": "The person's registry row (secrets only by name, in `secrets_set`)."
              }
            ]
          }
        },
        "type": "object"
      },
      "PlacementRule": {
        "additionalProperties": false,
        "description": "One placement rule of a group: the people its `people` selector picks\nare placed on the members its `devices` selector picks.",
        "properties": {
          "devices": {
            "description": "A selector over a member's labels (its endpoint's, with the\ndevice's own put over them): `region ^= west/nevada`. Absent: every\nmember.",
            "example": "region ^= west/nevada",
            "type": [
              "string",
              "null"
            ]
          },
          "people": {
            "description": "A selector over a person's `labels` (`role in (lead, manager)`).\nAbsent: every person.",
            "example": "role in (lead, manager)",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "PositionBody": {
        "additionalProperties": false,
        "description": "Where to move a sink: `{\"seq\": n}` (the next event it is sent is the\nfirst after n: lower than where it is to send events again, higher to\nskip them) or `{\"seq\": \"latest\"}` (skip everything stored so far).",
        "properties": {
          "seq": {
            "$ref": "#/components/schemas/SeqOrLatest",
            "description": "A sequence number, 0 or more, at most the newest event's: the sink\nis sent the events after it. Or \"latest\": past every event stored\nso far."
          }
        },
        "required": [
          "seq"
        ],
        "type": "object"
      },
      "PostedEvent": {
        "additionalProperties": false,
        "description": "One event posted.",
        "properties": {
          "data": {
            "description": "What it says: a JSON object of at most 16 KiB.",
            "type": "object"
          },
          "device": {
            "description": "What it is about, as its source knows it (a person's id, a\ndocument's): the envelope's `device`. At most 256 characters.",
            "example": "104552",
            "type": "string"
          },
          "id": {
            "description": "The event's id, which its source never gives another event: 1 to\n128 characters, no spaces or control characters. Posted again (a\nretry), with the same source, it is taken once. The event's `id` as\nthe sinks are sent it is made from it and the source.",
            "example": "erp-hire-20391",
            "type": "string"
          },
          "source": {
            "description": "The system that sends it: 1 to 64 letters, digits, '-' or '_'. A\ntenant's sink is sent the events of the sources it names in its\n`sources`.",
            "example": "erp",
            "type": "string"
          },
          "type": {
            "description": "Its type: 1 to 64 letters, digits, '.', '_' or '-'.",
            "example": "employee.hired",
            "type": "string"
          }
        },
        "required": [
          "id",
          "source",
          "type",
          "data"
        ],
        "type": "object"
      },
      "PostedEvents": {
        "additionalProperties": false,
        "description": "A post: the events, in the order they are to be kept.",
        "properties": {
          "events": {
            "description": "1 to 100 events, kept all together or not at all.",
            "items": {
              "$ref": "#/components/schemas/PostedEvent"
            },
            "type": "array"
          }
        },
        "required": [
          "events"
        ],
        "type": "object"
      },
      "PostedView": {
        "description": "What a post came to.",
        "properties": {
          "duplicates": {
            "description": "The ids, as posted, of those posted before with the same source:\nnot kept again.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "stored": {
            "description": "The ids of the events kept, as posted, in the order posted.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "stored",
          "duplicates"
        ],
        "type": "object"
      },
      "Presented": {
        "description": "What the device's latest message carried for a key: `none` (no key; a\ndevice with an active key is refused for that), `registered` (the\ndevice's key, or the new one on its way to it) or `unregistered` (a key\nthe gateway does not hold for the device; a device with an active key\nis refused for it, and adopting the key makes it the active one).",
        "enum": [
          "none",
          "registered",
          "unregistered"
        ],
        "type": "string"
      },
      "PreviewView": {
        "description": "What the write would do, recording nothing.",
        "properties": {
          "facts": {
            "description": "The facts it would record, in order.",
            "items": {
              "$ref": "#/components/schemas/ProposedView"
            },
            "type": "array"
          },
          "ledgers": {
            "description": "Each of the person's ledgers that would change, by period, then\nside; none: nothing would.",
            "items": {
              "$ref": "#/components/schemas/LedgerChange"
            },
            "type": "array"
          },
          "not_worked_out": {
            "description": "Why the person's ledgers cannot be worked out (no zone set up for\nthem, a policy step failing): the write would still be taken.",
            "type": [
              "string",
              "null"
            ]
          },
          "person": {
            "type": "string"
          }
        },
        "required": [
          "person",
          "facts",
          "ledgers"
        ],
        "type": "object"
      },
      "ProposedShift": {
        "description": "A shift proposed.",
        "properties": {
          "finish": {
            "example": "2026-10-10T20:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "start": {
            "description": "When it starts and finishes (RFC 3339); at most 24 hours long.",
            "example": "2026-10-10T12:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "values": {
            "additionalProperties": {
              "type": "string"
            },
            "description": "The labor context values it is worked with, as a punch carries\nthem: an assignment, a cost center, a job.",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          }
        },
        "required": [
          "start",
          "finish"
        ],
        "type": "object"
      },
      "ProposedView": {
        "description": "A fact the write would record, and what the write would say of it.",
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "recorded": {
            "description": "new, or already (recorded before: it changes nothing).",
            "type": "string"
          }
        },
        "required": [
          "kind",
          "id",
          "recorded"
        ],
        "type": "object"
      },
      "PublishedView": {
        "description": "A revision pushed or activated, and the tenants it updated.",
        "properties": {
          "held": {
            "description": "The tenants following it that lack what it needs: each stays on the\nversion it has, told by `package.held`, and moves on once it sets\nup what is missing.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "new": {
            "description": "Whether it is new (false: the same was kept already, or active).",
            "type": "boolean"
          },
          "published": {
            "description": "The revision as kept (`state`: `pushed`, `active`, or `failed` with\nthe scenarios' `results`).",
            "type": "object"
          },
          "updated": {
            "description": "The tenants whose followed version it changed, each told by\n`package.updated`.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "published",
          "new",
          "updated"
        ],
        "type": "object"
      },
      "PunchView": {
        "description": "A punch as it is taken, after its corrections.",
        "properties": {
          "corrections": {
            "description": "The corrections that made it what it is, in order.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "original": {
            "description": "The punch as it came, where a correction changed it; absent for one\nas punched or one a correction added.",
            "type": [
              "object",
              "null"
            ]
          },
          "punch": {
            "description": "The punch as taken, with every field it carries: `id`, `at`, `kind`,\n`values`, `recorded`, `stored`...",
            "type": "object"
          },
          "restamped": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/RestampedView",
                "description": "Where its clock stamp (`punch.clock`) came from, when it is not the\none the punch arrived with: the re-stamp that gave it (`original`\nhas the one it came with)."
              }
            ]
          }
        },
        "required": [
          "punch",
          "corrections"
        ],
        "type": "object"
      },
      "PunchesPolicy": {
        "additionalProperties": false,
        "description": "`punches`: recent punches shared across members.",
        "properties": {
          "lockout_minutes": {
            "description": "A punch within this many minutes of the person's previous one is\nmarked within the lock-out. 0 (the default): off. Not negative.",
            "format": "int64",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "Purged": {
        "description": "What deleting a tenant removed.",
        "properties": {
          "devices": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "events": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "jobs": {
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "rows": {
            "description": "Sync group rows (people, access, lists, settings).",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "devices",
          "events",
          "rows",
          "jobs"
        ],
        "type": "object"
      },
      "Pushed": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PackageRevision"
          },
          {
            "properties": {
              "activated": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/Activated",
                    "description": "What activating it did, when the push asked for that (`activate`);\nabsent otherwise."
                  }
                ]
              },
              "new": {
                "description": "False when the same content had been pushed before: the revision it was.",
                "type": "boolean"
              },
              "scenarios": {
                "description": "The scenarios run against it on this instance, all passing.",
                "minimum": 0,
                "type": "integer"
              }
            },
            "required": [
              "new",
              "scenarios"
            ],
            "type": "object"
          }
        ],
        "description": "What a push did."
      },
      "PutBiometrics": {
        "additionalProperties": false,
        "properties": {
          "allow": {
            "description": "`false`: the person's templates and photos are refused, wherever\nthey come from (and, if they were allowed, withdrawn); `true`:\nallowed.",
            "type": "boolean"
          }
        },
        "required": [
          "allow"
        ],
        "type": "object"
      },
      "PutCredential": {
        "additionalProperties": false,
        "properties": {
          "attrs": {
            "description": "What the template is, as the device reported it or the vendor names\nit (duress, quality, hand...). Default: none.",
            "type": "object"
          },
          "data_base64": {
            "description": "The template or photo, base64 (standard alphabet).",
            "example": "SGVsbG8gdGVtcGxhdGU=",
            "type": "string"
          },
          "format": {
            "description": "The format tag, which says how the bytes are encoded and which\ndevices take them: `zk:fingerprint:10`, `jpeg`. A credential is kept\nper kind, slot and format: writing another format adds a row.",
            "example": "zk:fingerprint:10",
            "type": "string"
          }
        },
        "required": [
          "format",
          "data_base64"
        ],
        "type": "object"
      },
      "PutPerson": {
        "description": "A person write: `{\"fields\": {...}, \"secrets\": {...}, \"if_version\"}`,\nthe shape of every registry write (access and list rows, batches).",
        "properties": {
          "fields": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/PersonFieldsView",
                "description": "Given: set; null: cleared; left out: as they are."
              }
            ]
          },
          "if_version": {
            "description": "Only if the person is still at this version (409 if not).",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          },
          "secrets": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/PersonSecretsView",
                "description": "Write-only: never shown, only which are set (`secrets_set`)."
              }
            ]
          }
        },
        "type": "object"
      },
      "PutRow": {
        "additionalProperties": false,
        "properties": {
          "fields": {
            "description": "The row's fields: those given are set, `null` clears one, those\nleft out stay as they are.",
            "type": "object"
          },
          "if_version": {
            "description": "Write only if the row is still at this version (0: only if the\nregistry has no such row); 409 if not.",
            "format": "int64",
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "fields"
        ],
        "type": "object"
      },
      "PutSettings": {
        "additionalProperties": false,
        "properties": {
          "values": {
            "description": "Setting name to value, at least one. `null` takes the group's value\naway: members keep what they have.",
            "type": "object"
          }
        },
        "required": [
          "values"
        ],
        "type": "object"
      },
      "QuantityTotal": {
        "description": "The sum of a measure's counts or money in a pay category, in the\nmeasure's unit (money in its currency's minor units).",
        "properties": {
          "category": {
            "type": "string"
          },
          "measure": {
            "type": "string"
          },
          "quantity": {
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "measure",
          "category",
          "quantity"
        ],
        "type": "object"
      },
      "QuantityView": {
        "description": "A count or money line.",
        "properties": {
          "category": {
            "type": "string"
          },
          "context": {
            "additionalProperties": {
              "type": "string"
            },
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "from": {
            "description": "The labor entry it came from, or the step that made it.",
            "type": "string"
          },
          "measure": {
            "type": "string"
          },
          "quantity": {
            "description": "In the measure's unit (money in its currency's minor units).",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "measure",
          "quantity",
          "category",
          "context",
          "from"
        ],
        "type": "object"
      },
      "QueuedDelete": {
        "description": "A delete queued on a device.",
        "properties": {
          "action": {
            "description": "`delete_biometrics` or `delete_user_photo`.",
            "type": "string"
          },
          "action_id": {
            "description": "The action queued; absent when it could not be (`error`).",
            "format": "int64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "device": {
            "description": "The device's id.",
            "type": "string"
          },
          "endpoint": {
            "description": "The device's endpoint.",
            "type": "string"
          },
          "error": {
            "description": "Why the delete could not be queued; absent when it was.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "endpoint",
          "device",
          "action"
        ],
        "type": "object"
      },
      "Ready": {
        "description": "Whether an instance takes work (`GET /api/ready`).",
        "properties": {
          "config_version": {
            "description": "The config version this instance has put into use.",
            "format": "int64",
            "type": "integer"
          },
          "database": {
            "description": "Whether the database answered this instance's last read of the\nconfig version (it reads it once a second). It does not decide\nreadiness.",
            "type": "boolean"
          },
          "ready": {
            "description": "It takes work: answered with 200, else 503.",
            "type": "boolean"
          },
          "why": {
            "description": "Why it does not take work, one reason each; empty when it does.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "ready",
          "config_version",
          "why",
          "database"
        ],
        "type": "object"
      },
      "RecalculateBody": {
        "additionalProperties": false,
        "description": "What to work out again keeping nothing.",
        "properties": {
          "people": {
            "description": "The people to work out again (their ids in this tenant); everyone of the tenant when left out. A person the\ntenant does not have is not counted.",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "reason": {
            "description": "Why, for the audit trail and the events the work out again tells of its changes.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "RecalculateView": {
        "description": "Who was marked.",
        "properties": {
          "marked": {
            "description": "How many people were marked to be worked out again: those named that the tenant has, or everyone of it.",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "marked"
        ],
        "type": "object"
      },
      "RecordBody": {
        "additionalProperties": false,
        "description": "A record to make, or what to change of one.",
        "properties": {
          "employer": {
            "description": "The employer: the record is made of it; one of another employer is\nrefused (409). Without it: the record there is, or one of the\ntenant's first employer.",
            "type": [
              "string",
              "null"
            ]
          },
          "worker": {
            "description": "The worker; null takes it away; absent leaves it. At most 256\ncharacters (a worker's id is indexed, and a longer one is refused, 400).",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "RecordView": {
        "description": "An employee record: one person, one employment.",
        "properties": {
          "employer": {
            "description": "The employer whose employee they are, for good; null for an\nunlinked person.",
            "type": [
              "string",
              "null"
            ]
          },
          "person": {
            "type": "string"
          },
          "worker": {
            "description": "The worker (the one human) whose records this is one of.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "person"
        ],
        "type": "object"
      },
      "RecordedView": {
        "description": "What came of recording each fact.",
        "properties": {
          "recorded": {
            "description": "For each fact, in order: `new`, or `already` (the same fact was\nrecorded before; nothing changed).",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "recorded"
        ],
        "type": "object"
      },
      "RefusedView": {
        "description": "A leave request the shifts would have the policy refuse.",
        "properties": {
          "leave": {
            "type": "string"
          },
          "why": {
            "type": "string"
          }
        },
        "required": [
          "leave",
          "why"
        ],
        "type": "object"
      },
      "RegisterDevice": {
        "additionalProperties": false,
        "description": "A device to register.",
        "properties": {
          "device": {
            "description": "The device's id, as its package identifies it: 1 to 64 printable\nASCII characters, none of them `/`, `+` or `#`. `sn` is taken too.",
            "type": "string"
          },
          "endpoint": {
            "description": "The endpoint it belongs to.",
            "type": "string"
          },
          "external_ids": {
            "$ref": "#/components/schemas/BTreeMap",
            "description": "What other systems know the device by: system name to id."
          },
          "key": {
            "description": "The key it is to present: 1 to 128 characters, none of them control\ncharacters. The package is asked for the commands that give the\ndevice the key. Absent: it has no key and is taken at its word.",
            "type": [
              "string",
              "null"
            ]
          },
          "metadata": {
            "description": "Free-form data from other systems, kept as given.",
            "type": "object"
          },
          "status": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/DeviceStatus",
                "description": "Its status: `allowed` unless given (registering a device is how it\nis let in), `pending` or `blocked`."
              }
            ]
          }
        },
        "required": [
          "endpoint",
          "device"
        ],
        "type": "object"
      },
      "ReleaseDevice": {
        "additionalProperties": false,
        "description": "How to release a device.",
        "properties": {
          "drop_queued": {
            "description": "Cancel every action and command still waiting for the device (each\naction says why); otherwise they go out again, in order. False\nunless given.",
            "type": "boolean"
          },
          "reason": {
            "description": "Why it is released, for its `device.released` event. \"released by\nhand\" unless given.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "ReplyLimits": {
        "additionalProperties": false,
        "description": "`[commands] reply`: the most one reply carries. Each key is optional; one left out is no limit from the manifest.",
        "properties": {
          "bytes_option": {
            "description": "The endpoint option (a whole number) that sets `max_bytes` for one endpoint instead.",
            "type": [
              "string",
              "null"
            ]
          },
          "max_bytes": {
            "description": "The most bytes of command text in one reply.",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "max_count": {
            "description": "The most commands in one reply.",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "Report": {
        "description": "What one scenario did.",
        "properties": {
          "actions": {
            "description": "Standard actions whose commands a passing step asserted.",
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": true
          },
          "commands": {
            "description": "Commands whose output a passing step asserted.",
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": true
          },
          "description": {
            "description": "What it says it tests.",
            "type": "string"
          },
          "failures": {
            "description": "What went wrong, one line each; empty when it passed.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "file": {
            "description": "Its file: \"tests/attlog.toml\".",
            "type": "string"
          },
          "package": {
            "description": "The package it tests, \"name@version\".",
            "type": "string"
          },
          "routes": {
            "description": "Routes that handled a message in a passing step with assertions.",
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": true
          },
          "steps": {
            "description": "How many steps it has.",
            "minimum": 0,
            "type": "integer"
          },
          "sync_domains": {
            "description": "Sync domains (`[sync] domains`) of a passing scenario whose steps\nchecked what the group holds (`expect.sync`).",
            "items": {
              "type": "string"
            },
            "type": "array",
            "uniqueItems": true
          }
        },
        "required": [
          "package",
          "file",
          "description",
          "steps",
          "failures",
          "commands",
          "actions",
          "routes",
          "sync_domains"
        ],
        "type": "object"
      },
      "RequestInHand": {
        "description": "A device message an instance is handling now, and what it is doing (`GET /api/requests`).",
        "properties": {
          "clock_seconds": {
            "description": "How long it has been in hand on the instance's clock, in seconds: on virtual time (a harness) it stands still\nwhile the instance is not moved on.",
            "format": "double",
            "type": "number"
          },
          "device": {
            "description": "The device it is from, once known (empty before).",
            "type": "string"
          },
          "doing": {
            "description": "What it is doing at this moment, by phase name (`pool_wait`, `mailbox_wait`, `package_run`, `store_writes`...);\n`none` before it began on one.",
            "type": "string"
          },
          "endpoint": {
            "description": "The endpoint the message came to.",
            "type": "string"
          },
          "real_seconds": {
            "description": "How long it has been in hand, in real seconds.",
            "format": "double",
            "type": "number"
          },
          "route": {
            "description": "The route the package chose, `unknown` before it did.",
            "type": "string"
          }
        },
        "required": [
          "endpoint",
          "device",
          "route",
          "doing",
          "real_seconds",
          "clock_seconds"
        ],
        "type": "object"
      },
      "Requires": {
        "additionalProperties": false,
        "description": "`[requires]` in package.toml: the vars and secrets, by name, a package\ncannot run without. Either scope satisfies one: the tenant's, or one\nset for the package by name.",
        "properties": {
          "secrets": {
            "description": "The secrets it needs, by name.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "vars": {
            "description": "The vars it needs, by name.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "Rerouted": {
        "description": "What became of a punch set aside.",
        "properties": {
          "candidates": {
            "description": "Its candidates.",
            "items": {
              "$ref": "#/components/schemas/Route"
            },
            "type": "array"
          },
          "id": {
            "description": "The punch's id (its event's).",
            "type": "string"
          },
          "reason": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Unrouted",
                "description": "Why it is still unrouted."
              }
            ]
          },
          "route": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Route",
                "description": "Where it went, when routed."
              }
            ]
          },
          "routing": {
            "description": "`routed`, `passed` (its candidates passed on) or `unrouted`.",
            "type": "string"
          },
          "user_id": {
            "description": "The person's user id.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "user_id",
          "routing",
          "candidates"
        ],
        "type": "object"
      },
      "ReroutedTotals": {
        "description": "What became of all the punches set aside that were worked out again, in\ntotal: a group may have many thousands.",
        "properties": {
          "passed": {
            "description": "Of them, passed on with their candidates.",
            "minimum": 0,
            "type": "integer"
          },
          "reasons": {
            "additionalProperties": {
              "minimum": 0,
              "type": "integer"
            },
            "description": "Why the unrouted are, by reason (`no_route`, `ambiguous`, `policy`,\n`policy_failed`, `unknown_person`, `deciding`).",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "routed": {
            "description": "Of them, routed to one route.",
            "minimum": 0,
            "type": "integer"
          },
          "total": {
            "description": "Punches worked out again.",
            "minimum": 0,
            "type": "integer"
          },
          "unrouted": {
            "description": "Of them, still unrouted.",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "total",
          "routed",
          "passed",
          "unrouted",
          "reasons"
        ],
        "type": "object"
      },
      "Resend": {
        "description": "Which lost commands are handed out once more (a command is lost when its package says so: `M.missed`).",
        "enum": [
          "never",
          "writes"
        ],
        "type": "string"
      },
      "RestampBody": {
        "additionalProperties": false,
        "description": "What a re-stamp asks.",
        "properties": {
          "from": {
            "description": "The first instant: a time (RFC 3339), or a date, the start of that day in the zone of the clock's location\n(a clock with no location takes a time only).",
            "type": "string"
          },
          "reason": {
            "description": "Why, for the audit trail and each punch's correction.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "from"
        ],
        "type": "object"
      },
      "RestampView": {
        "description": "What a re-stamp did, or, previewed, would do.",
        "properties": {
          "clock": {
            "description": "The clock's device id.",
            "type": "string"
          },
          "complete": {
            "description": "False when one run's most was reached: ask again for the rest.",
            "type": "boolean"
          },
          "first": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "from": {
            "example": "2026-10-05T00:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "The re-stamp's id (in its corrections' ids); none for a preview.",
            "type": [
              "string",
              "null"
            ]
          },
          "last": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "looked_at": {
            "description": "Its punches from then on that were looked at.",
            "minimum": 0,
            "type": "integer"
          },
          "people": {
            "description": "The persons they are kept under, worked out again from the punch's workday.",
            "minimum": 0,
            "type": "integer"
          },
          "preview": {
            "description": "True for a preview: nothing was changed.",
            "type": "boolean"
          },
          "restamped": {
            "description": "Those given the clock's record as it is now (or that would be); the rest carry it already.",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "clock",
          "from",
          "preview",
          "looked_at",
          "restamped",
          "people",
          "complete"
        ],
        "type": "object"
      },
      "RestampedView": {
        "description": "A clock re-stamp that gave a punch its stamp.",
        "properties": {
          "at": {
            "description": "When it was stored.",
            "example": "2026-10-12T15:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "correction": {
            "description": "The correction that did it.",
            "type": "string"
          },
          "reason": {
            "type": "string"
          },
          "via": {
            "description": "Who asked, as the server saw it (`user:<name>`).",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "correction",
          "at",
          "reason"
        ],
        "type": "object"
      },
      "Resync": {
        "additionalProperties": false,
        "properties": {
          "domain": {
            "description": "Only this domain's rows: people, access, lists or settings. Left\nout: every domain.",
            "example": "people",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "RevisionView": {
        "description": "The revision a setup change made.",
        "properties": {
          "revision": {
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "revision"
        ],
        "type": "object"
      },
      "Rollout": {
        "additionalProperties": false,
        "description": "How the devices are taken on: in waves, so a bad action is found on a\nfew before it reaches them all.",
        "properties": {
          "advance": {
            "$ref": "#/components/schemas/Advance",
            "description": "`auto` (the default): the next wave starts once every device of the\ncurrent one succeeded. `manual`: only when told\n(`POST /api/tenants/{tenant}/jobs/{id}/advance`)."
          },
          "max_concurrent": {
            "description": "Devices running at once, at most (1 or more). Absent: no limit\nbeyond the wave.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "waves": {
            "description": "The size of each wave, in order: a count (5) or a share of all the\ndevices (\"10%\", rounded up). Devices left over after the last make\none more wave. Absent: one wave of every device.",
            "items": {
              "$ref": "#/components/schemas/WaveSize"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "Route": {
        "additionalProperties": false,
        "description": "One route: a receiving system, a tenant in it, the person's id there,\nand codes for the receiver.",
        "properties": {
          "codes": {
            "additionalProperties": {
              "type": "string"
            },
            "description": "Codes the receiver reads with the punch (`{\"cost_center\": \"410\"}`),\nkept as given.",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "person_id": {
            "description": "The person's id in that system. Only a person's own route names\none; on a default route it is the person's external id in the\nsystem, when they have one.",
            "example": "4471",
            "type": [
              "string",
              "null"
            ]
          },
          "system": {
            "description": "The receiving system, as a sink names the system it speaks for:\n1 to 64 letters, digits, '-' or '_'.",
            "example": "attendance",
            "type": "string"
          },
          "tenant": {
            "description": "The tenant in that system the punches go to: its id there, opaque.",
            "example": "acme",
            "type": "string"
          }
        },
        "required": [
          "system",
          "tenant"
        ],
        "type": "object"
      },
      "RouteBody": {
        "additionalProperties": false,
        "description": "How a punch is routed by hand.",
        "properties": {
          "candidates": {
            "description": "Pass these candidates on, as they are, to a receiver that resolves\nthem itself: all of one system.",
            "items": {
              "$ref": "#/components/schemas/Route"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "route": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/Route",
                "description": "Send it to this route."
              }
            ]
          }
        },
        "type": "object"
      },
      "RouteInfo": {
        "description": "A kind of message from a device that the package handles.",
        "properties": {
          "description": {
            "description": "What the message is and what the package does with it.",
            "type": "string"
          },
          "lookup": {
            "description": "It asks the sync group something before it answers. Absent when\nfalse.",
            "type": "boolean"
          },
          "name": {
            "description": "The route's name.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "description"
        ],
        "type": "object"
      },
      "RunScenarios": {
        "description": "Which scenarios to run.",
        "properties": {
          "filter": {
            "description": "Only the scenarios whose package id and file (\"zk-push@3.4.0\ntests/attlog.toml\") contain this text. Absent: every scenario, and\nthe coverage of every package.",
            "example": "zk-push",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "RunningPackage": {
        "description": "What the instance that answers runs of a package line.",
        "properties": {
          "id": {
            "description": "The package and version it runs, \"name@version\".",
            "type": "string"
          },
          "revision": {
            "description": "The revision it runs; null when it runs the package from a folder\n(`hourd dev`).",
            "format": "int32",
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "id"
        ],
        "type": "object"
      },
      "ScenarioRun": {
        "description": "What a scenario run did.",
        "properties": {
          "coverage": {
            "description": "What each package's passing scenarios exercise; empty when a filter\nwas given.",
            "items": {
              "$ref": "#/components/schemas/Coverage"
            },
            "type": "array"
          },
          "failed": {
            "description": "How many scenarios failed.",
            "minimum": 0,
            "type": "integer"
          },
          "passed": {
            "description": "No scenario failed.",
            "type": "boolean"
          },
          "reports": {
            "description": "What each scenario did, package by package.",
            "items": {
              "$ref": "#/components/schemas/Report"
            },
            "type": "array"
          }
        },
        "required": [
          "passed",
          "failed",
          "reports",
          "coverage"
        ],
        "type": "object"
      },
      "SecretView": {
        "description": "A secret as listed: its name and dates, never its value.",
        "properties": {
          "name": {
            "description": "Its name: 1 to 64 letters, digits, '_', '-' or '.'.",
            "type": "string"
          },
          "package": {
            "description": "The package it is for, by name (every version of it); absent: the\ntenant's, for every package. A package's own value of a name is read\nbefore the tenant's.",
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "description": "When it was last set.",
            "format": "date-time",
            "type": "string"
          },
          "updated_by": {
            "description": "Who set it last: the admin login's user name, `token:<name>` for an\nAPI token, or `local` without a login.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "updated_at",
          "updated_by"
        ],
        "type": "object"
      },
      "SeenAsk": {
        "description": "The devices to tell of (`/api/peer/seen`).",
        "properties": {
          "devices": {
            "description": "The devices, each as \"<endpoint>/<device>\".",
            "example": [
              "office/CG0001",
              "office/CG0002"
            ],
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "devices"
        ],
        "type": "object"
      },
      "SenderView": {
        "description": "The sender's ids of an unlinked person.",
        "properties": {
          "device": {
            "description": "The device they last punched at.",
            "type": "string"
          },
          "endpoint": {
            "type": "string"
          },
          "group": {
            "description": "The sync group that keeps the person, where the sender has one.",
            "type": [
              "string",
              "null"
            ]
          },
          "person": {
            "description": "Connect's own id of the person: opaque.",
            "type": "string"
          },
          "tenant": {
            "description": "The Connect tenant.",
            "type": "string"
          },
          "user_id": {
            "description": "The user's id on the device.",
            "type": "string"
          }
        },
        "required": [
          "tenant",
          "endpoint",
          "person",
          "user_id",
          "device"
        ],
        "type": "object"
      },
      "SeqOrLatest": {
        "description": "A sequence number (0 or more), or \"latest\".",
        "oneOf": [
          {
            "format": "int64",
            "type": "integer"
          },
          {
            "type": "string"
          }
        ]
      },
      "Setting": {
        "description": "A device setting the package registers: what `set_settings` and\n`read_settings` take, by its neutral name.",
        "properties": {
          "access": {
            "description": "rw (the default), w (set only) or r (read only).",
            "type": "string"
          },
          "depends_on_device": {
            "description": "Whether a device has it depends on what the device reported\n(firmware, capabilities): the package's `applies(info)`, or values\nthat are functions of `info`. A device's own list says.",
            "type": "boolean"
          },
          "description": {
            "description": "What it does.",
            "type": "string"
          },
          "max": {
            "description": "`integer`, `number`: the largest value.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "max_length": {
            "description": "`string`: the most characters.",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "min": {
            "description": "`integer`, `number`: the smallest value.",
            "format": "double",
            "type": [
              "number",
              "null"
            ]
          },
          "name": {
            "description": "The neutral name callers use (snake_case).",
            "type": "string"
          },
          "native": {
            "description": "The name the device knows it by.",
            "type": "string"
          },
          "needs_reboot": {
            "description": "The device takes it only after a restart.",
            "type": "boolean"
          },
          "pattern": {
            "description": "`string`: a regular expression the value must match.",
            "type": [
              "string",
              "null"
            ]
          },
          "sensitive": {
            "description": "Kept sealed and shown only as its size.",
            "type": "boolean"
          },
          "standard": {
            "description": "The standard setting it is (`volume`), if it is one.",
            "type": [
              "string",
              "null"
            ]
          },
          "title": {
            "description": "A short name for people. Absent when the package does not say.",
            "type": "string"
          },
          "type": {
            "description": "boolean, integer, number, string, enum or table.",
            "type": "string"
          },
          "values": {
            "description": "`enum`: the values it may be.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "name",
          "description",
          "type",
          "access",
          "sensitive",
          "needs_reboot",
          "native"
        ],
        "type": "object"
      },
      "SettingsView": {
        "additionalProperties": false,
        "description": "The settings every instance uses besides listeners, endpoints, sinks and\nsync groups (`/api/settings`): the limits, the retention and the trusted\nproxies.",
        "properties": {
          "audit_retention_days": {
            "description": "Days an audit entry is kept, tidied apart from `retention_days`.\nGreater than 0. Absent or null: entries are kept for ever (the\ndefault).",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "limits": {
            "$ref": "#/components/schemas/LimitsConfig",
            "description": "Limits on what devices may send."
          },
          "retention_days": {
            "description": "Days a finished command, a delivered event, a failed device message\nor a sync group's deleted row is kept. An event a\nsink has not taken is kept until it does, however old; a sink still\nbehind after this long is told of (`sink.behind`). Greater than 0.\nDefault 30.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          "tenant_destinations": {
            "description": "Internal addresses tenants' webhook sinks and MQTT brokers may\nreach, as addresses, CIDR ranges or host names (\"10.20.0.0/16\",\n\"payroll.internal\"). Every other loopback, link-local, private,\nunique-local or unspecified address is refused to them, checked on\nthe address each connection is made to. The install's own sinks\nare not filtered. Empty: tenants reach public addresses only.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "trusted_proxies": {
            "description": "Proxies (load balancers) in front of the device listeners, as\naddresses or CIDR ranges (\"10.0.0.0/8\", \"192.0.2.7\"). A request from\none of them is taken to come from the address it names in\n`X-Forwarded-For`, and only they may send PROXY protocol headers. On\na `proxy_protocol` listener the PROXY header names the client and\n`X-Forwarded-For` is never read.\nEmpty: every request comes from its peer.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "retention_days"
        ],
        "type": "object"
      },
      "SetupView": {
        "description": "Setup items in force.",
        "properties": {
          "person": {
            "description": "The person's own, over the tenant's (with `?person=`).",
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "tenant": {
            "description": "The tenant's, each as `{\"<kind>\": {...}}`.",
            "items": {
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "tenant",
          "person"
        ],
        "type": "object"
      },
      "ShiftCostAsk": {
        "description": "Whom to estimate, and the shifts each would work.",
        "properties": {
          "people": {
            "description": "The people, 1 to 100: each is estimated working every shift.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "shifts": {
            "description": "The shifts, 1 to 31: one to compare people for, or a draft schedule.",
            "items": {
              "$ref": "#/components/schemas/ProposedShift"
            },
            "type": "array"
          }
        },
        "required": [
          "people",
          "shifts"
        ],
        "type": "object"
      },
      "ShiftCosts": {
        "description": "Each person's estimate, in the order asked.",
        "properties": {
          "estimates": {
            "items": {
              "$ref": "#/components/schemas/CostView"
            },
            "type": "array"
          }
        },
        "required": [
          "estimates"
        ],
        "type": "object"
      },
      "ShiftView": {
        "description": "A scheduled shift.",
        "properties": {
          "end": {
            "example": "2026-10-05T21:30:00Z",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "type": "string"
          },
          "start": {
            "example": "2026-10-05T13:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "values": {
            "additionalProperties": {
              "type": "string"
            },
            "description": "The labor context its work takes where the punches do not say.",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          }
        },
        "required": [
          "id",
          "start",
          "end",
          "values"
        ],
        "type": "object"
      },
      "ShownRowState": {
        "description": "A member's state for a row, as shown: where the member is with the row, and\n`deleted` for a delete the member confirmed (a row the group keeps as a\ntombstone until every member did).",
        "enum": [
          "pending",
          "in_sync",
          "failed",
          "unsupported",
          "diverged",
          "not_applicable",
          "needs_reboot",
          "not_placed",
          "deleted"
        ],
        "type": "string"
      },
      "Sighting": {
        "description": "What one instance knows from memory of when a device was last seen and\nrefused: the part of a device's record written to the database only\nevery 5 minutes. The device views gather it from every instance.",
        "properties": {
          "device": {
            "description": "The device's id.",
            "type": "string"
          },
          "endpoint": {
            "description": "The device's endpoint.",
            "type": "string"
          },
          "health": {
            "$ref": "#/components/schemas/DeviceHealth",
            "description": "What the instance has counted of the device's messages and not\nwritten yet."
          },
          "key_refused_at": {
            "description": "When the instance last refused it for the key it carried.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "last_seen": {
            "description": "When the instance last had a message from it.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "params": {
            "additionalProperties": {
              "type": "string"
            },
            "description": "Values captured from the endpoint's path or topic template on that\nmessage.",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "remote_ip": {
            "description": "The address that message came from.",
            "type": "string"
          }
        },
        "required": [
          "endpoint",
          "device",
          "remote_ip",
          "params"
        ],
        "type": "object"
      },
      "SinkConfig": {
        "additionalProperties": false,
        "description": "A sink: where the events of the endpoints and sync groups that name it\nare sent.",
        "properties": {
          "batch": {
            "description": "At most this many events in one delivery, at least 1. Absent: as\nmany as fit in `batch_bytes`.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "batch_bytes": {
            "description": "At most this many bytes of event data in one delivery, at least 1;\nan event larger than it is sent alone. Absent: 1 MiB.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "events": {
            "description": "Only these event types are sent (\"punch\", \"user\", ...). Empty or\nabsent: what an outside system acts on or keeps up to date with:\nevery type but the detailed ones sent only when named here (the\nsteps beneath actions and jobs, operations logs, biometric data,\nphotos and identity cards)\nand sync-group changes made through the API.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "id": {
            "description": "Its id, as endpoints and sync groups name it: 1 to 64 letters,\ndigits, '-' or '_', and not `status`. It cannot be changed.",
            "type": "string"
          },
          "latest_only": {
            "description": "Event types that state the latest of something (`device.options`):\nof those waiting about the same subject (the event's `device`, at its\nendpoint, of its tenant: for a source's events, the tenant their data\nnames), only the latest is sent.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "match": {
            "additionalProperties": {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "description": "Only events whose data has one of these values in each field named\n(`{\"exception\": [\"missing_out\"]}`: only missing outs).\nEmpty or absent: every event.",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "max_per_second": {
            "description": "At most this many events a second; the rest wait their turn.\nAbsent: as fast as it takes them.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "receiver": {
            "description": "in_process, required: the receiver the events are given to\n(`attendance`). Until one by that name runs on an instance, the\nevents wait.",
            "type": [
              "string",
              "null"
            ]
          },
          "secret": {
            "description": "webhook: the HMAC-SHA256 signing secret; with it, each post carries\nan `x-houradvantage-signature`. in_process: the key the receiver\nchecks; for the attendance engine, a delivery key the tenant issued\n(required: without one of its keys, deliveries are refused and the\nevents wait). Kept in the database, never shown.",
            "type": [
              "string",
              "null"
            ]
          },
          "sources": {
            "description": "Sources whose events it is sent besides the endpoints and sync\ngroups that name it. A tenant's sink: the systems whose events\nposted into its tenant it is sent (`POST .../events`, `source`). An\ninstall-level sink, which is sent every tenant's events, posted ones\nincluded: `attendance`, to be sent the events of that source that\nConnect's log holds (`SOURCES`).",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "system": {
            "description": "The system this sink speaks for (`\"attendance\"`, `\"payroll\"`): it is\nsent the punches routed to it (to `tenant` in it, when it names\none) and no others, and each event about a person carries\n`person_id`, their id in it from their routes (`routes`), when they\nhave one. Absent: every punch, and no `person_id`.",
            "type": [
              "string",
              "null"
            ]
          },
          "tenant": {
            "description": "in_process: the tenant the receiver keeps the events for. For the\nattendance engine, required: the Time and Attendance tenant the\npunches are of; one sink feeds one tenant. While that tenant does\nnot exist, does not know the sink's `secret` as one of its delivery\nkeys, or is suspended, its deliveries are refused and the events\nwait. With `system`, whatever the sink: the tenant in that system\nwhose punches it is sent (those routed to it).",
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "$ref": "#/components/schemas/SinkKind",
            "description": "What it is: `webhook`, or `in_process` (a receiver in the same\nprogram, such as the attendance engine)."
          },
          "url": {
            "description": "webhook, required: the http or https URL events are posted to.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "type"
        ],
        "type": "object"
      },
      "SinkDropped": {
        "description": "The shape of a sink status's `dropped`, which is always null (events\nare kept until the sink takes them): when, how many, and up to which\nsequence number.",
        "properties": {
          "at": {
            "description": "When events were last removed before the sink took them.",
            "format": "date-time",
            "type": "string"
          },
          "events": {
            "description": "How many events have been removed in all since the sink was last\nmoved by hand.",
            "format": "int64",
            "type": "integer"
          },
          "through": {
            "description": "The sequence number of the last event removed.",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "at",
          "events",
          "through"
        ],
        "type": "object"
      },
      "SinkKind": {
        "description": "What a sink is: `webhook` or `in_process` in the settings.",
        "enum": [
          "webhook",
          "in_process",
          "memory"
        ],
        "type": "string"
      },
      "SinkMovedView": {
        "description": "A sink moved along the events.",
        "properties": {
          "from": {
            "description": "The sequence number it was after: the last event it had.",
            "format": "int64",
            "type": "integer"
          },
          "sink": {
            "description": "The sink's id.",
            "type": "string"
          },
          "to": {
            "description": "The sequence number it is after now: the next event it is sent is\nthe first after this one.",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "sink",
          "from",
          "to"
        ],
        "type": "object"
      },
      "SinkStatus": {
        "description": "How a sink is getting on.",
        "properties": {
          "behind": {
            "description": "How many events of the log are after the sink's position, up to the\nnewest stored: the distance between them, not a count of the events\nthe sink is fed (the log is every tenant's, and a number a transaction\nthat kept nothing took counts too). 0 when the sink has taken everything\nthere is, whatever its feed leaves out.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "delivered_at": {
            "description": "When it last accepted events; null if it never has.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "dropped": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/SinkDropped",
                "description": "Always null: events are kept until the sink takes them, or is\nmoved past them by hand (`sink.moved`). Part of the answer so that\ncallers reading it keep working."
              }
            ]
          },
          "error": {
            "description": "What it answered when it last refused; null while it takes them.",
            "type": [
              "string",
              "null"
            ]
          },
          "failing_since": {
            "description": "Since when it has been refusing deliveries; null while it takes them.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "oldest_waiting_at": {
            "description": "When the oldest event waiting for it was received; null when none\nwaits.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "position": {
            "description": "The sequence number of the last event the sink has, or was moved past.",
            "format": "int64",
            "type": "integer"
          },
          "sink": {
            "description": "The sink's id.",
            "type": "string"
          },
          "unreadable": {
            "description": "For a sink feeding Time and Attendance (an `in_process` sink naming\nits tenant): the punches the tenant could not read, which are kept\nfor someone to put right (`GET /api/attendance/tenants/{tenant}/unreadable`),\ncounted up to 1000. Delivered, they are not waiting: this is where\nthey show. Absent when none.",
            "minimum": 0,
            "type": "integer"
          },
          "unrouted": {
            "description": "For a sink that speaks for a system (`system`): the punches of the\nsync groups feeding it that no route sends anywhere yet\n(`GET .../sync/{group}/unrouted`), counted up to 1000. Absent when\nnone.",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "sink",
          "behind",
          "position"
        ],
        "type": "object"
      },
      "SinkView": {
        "description": "A sink as the API shows it: the signing secret only as whether there is\none.",
        "properties": {
          "batch": {
            "description": "At most this many events in one delivery.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "batch_bytes": {
            "description": "At most this many bytes of event data in one delivery.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "events": {
            "description": "The event types it is sent; empty: the default set (every type but\nthe detailed ones sent only when named).",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "id": {
            "description": "The sink's id, as endpoints and sync groups name it in their `sinks`.",
            "type": "string"
          },
          "latest_only": {
            "description": "Event types of which only the latest about each subject is sent.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "match": {
            "additionalProperties": {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "description": "Only events whose data has one of these values in each field named.",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "max_per_second": {
            "description": "At most this many events a second.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "receiver": {
            "description": "in_process: the receiver its events are given to.",
            "type": [
              "string",
              "null"
            ]
          },
          "secret_set": {
            "description": "Whether a secret is set: a webhook's posts are then signed; an\nin_process sink gives it to its receiver (the attendance engine's\ndelivery key). The secret is never shown.",
            "type": "boolean"
          },
          "sources": {
            "description": "Sources whose events it is sent besides the endpoints and sync\ngroups that name it: for a tenant's sink, the systems whose events\nposted into the tenant it is sent; for an install-level sink,\n`attendance`.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "system": {
            "description": "The system it speaks for: it is sent the punches routed to it, and\nits events carry the person's id in it as `person_id`.",
            "type": [
              "string",
              "null"
            ]
          },
          "tenant": {
            "description": "in_process: the tenant the receiver keeps them for.",
            "type": [
              "string",
              "null"
            ]
          },
          "type": {
            "$ref": "#/components/schemas/SinkKind",
            "description": "What it is: `webhook` or `in_process`."
          },
          "url": {
            "description": "webhook: the URL events are posted to.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "type",
          "secret_set",
          "events"
        ],
        "type": "object"
      },
      "StandardAction": {
        "description": "A standard action: what it means on any device, and its parameters.",
        "properties": {
          "description": {
            "description": "What it means on any device.",
            "type": "string"
          },
          "domain": {
            "description": "What it is about: people, punches, device, lists, access or\nsettings (how the catalog page is laid out).",
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "params": {
            "items": {
              "$ref": "#/components/schemas/StandardParam"
            },
            "type": "array"
          },
          "title": {
            "type": "string"
          },
          "writes": {
            "description": "The sync domains it writes on a device; none for reads and device\noperations.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "name",
          "title",
          "description",
          "domain",
          "writes",
          "params"
        ],
        "type": "object"
      },
      "StandardParam": {
        "description": "A standard action's parameter.",
        "properties": {
          "description": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "required": {
            "type": "boolean"
          },
          "sensitive": {
            "description": "A secret or personal data: packages mark the parameter it becomes\nsensitive, so it is kept and shown only as its size.",
            "type": "boolean"
          },
          "type": {
            "$ref": "#/components/schemas/ParamType"
          },
          "values": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "name",
          "type",
          "required",
          "sensitive",
          "description"
        ],
        "type": "object"
      },
      "StandingView": {
        "description": "Where an approval or a leave request stands.",
        "properties": {
          "stage": {
            "description": "The stage it waits for, was approved at before a change, or was\nrejected or disputed at.",
            "type": [
              "string",
              "null"
            ]
          },
          "state": {
            "description": "pending, needs_reapproval, rejected, disputed, blocked, refused or\napproved.",
            "type": "string"
          },
          "why": {
            "description": "Why, where it is refused (a leave request the policy refused) or an\napprove step blocked it.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "state"
        ],
        "type": "object"
      },
      "StartAction": {
        "additionalProperties": false,
        "description": "An action to queue.",
        "properties": {
          "action": {
            "description": "What to do: a standard action or a package action the device's\npackage offers (`available_actions` on the device), or one of its\ncommands (`available_commands`), which is an action of one step.\nNot given when `steps` is.",
            "type": [
              "string",
              "null"
            ]
          },
          "expires_at": {
            "description": "Steps not handed to the device by then (RFC 3339) never go: they are\ncancelled, and the action ends `timed_out`.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "key": {
            "description": "The caller's own id for this request, to make it safe to send again:\nthe same key for the same device returns the action it queued the\nfirst time, and queues nothing. At most 255 characters, as an\n`Idempotency-Key`: it is indexed, and a longer one is refused (400).",
            "type": [
              "string",
              "null"
            ]
          },
          "lane": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/CallerLane",
                "description": "Where its steps queue: `interactive` unless given, or `bulk` for\nlarge fills that may wait behind everything else."
              }
            ]
          },
          "params": {
            "description": "Its parameters, by name, as the action or command declares them\n(the device's catalog lists them, typed)."
          },
          "steps": {
            "description": "The steps of the action, listed by the caller instead of named: each is `{ \"action\", \"params\" }` as `action`\nand `params` would be on their own, and is judged as it would be alone. They are queued in order as one\naction, with one status and one result; if any is refused, nothing is queued. Not given with `action`.",
            "items": {
              "$ref": "#/components/schemas/StartStep"
            },
            "type": [
              "array",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "StartStep": {
        "additionalProperties": false,
        "description": "One of an action's `steps`.",
        "properties": {
          "action": {
            "description": "A standard action, a package action or one of the package's commands, as `action` takes it.",
            "type": "string"
          },
          "params": {
            "description": "Its parameters, as `params` takes them."
          }
        },
        "required": [
          "action"
        ],
        "type": "object"
      },
      "StateChange": {
        "description": "An approval or leave request whose state would change; absent before\nor after: there is none then.",
        "properties": {
          "after": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/StandingView"
              }
            ]
          },
          "before": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/StandingView"
              }
            ]
          },
          "id": {
            "description": "The approval's subject, or the leave request's id.",
            "type": "string"
          }
        },
        "required": [
          "id"
        ],
        "type": "object"
      },
      "StoredEvent": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Event"
          },
          {
            "properties": {
              "seq": {
                "description": "The sequence number it was stored under, one order across the whole\ninstall. Read on from it with `after`.",
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "seq"
            ],
            "type": "object"
          }
        ],
        "description": "An event as it is kept: with the sequence number it was stored under."
      },
      "Success": {
        "description": "Which result codes mean success, for a package that does not say:\n`zero` (0, the default), `non_negative` (anything not negative: the\ndevice answers with a size or count) or `positive` (anything above 0:\nnothing found is a failure).",
        "enum": [
          "zero",
          "non_negative",
          "positive"
        ],
        "type": "string"
      },
      "SyncChangesPage": {
        "description": "A page of registry rows, in version order.",
        "properties": {
          "changes": {
            "default": [],
            "description": "The rows, oldest change first.",
            "items": {
              "$ref": "#/components/schemas/SyncRowView"
            },
            "type": "array"
          },
          "next": {
            "default": 0,
            "description": "Pass as `after` for the next page: the newest version on this page,\nor the `after` asked for when it is empty.",
            "format": "int64",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "SyncDomainStatus": {
        "description": "How a group stands with one domain.",
        "properties": {
          "members": {
            "description": "Member rows by state (pending, in_sync, failed, unsupported,\ndiverged, not_applicable, needs_reboot, not_placed),\nsummed over the members. A state no row is in is left out.",
            "type": "object"
          },
          "rows": {
            "default": 0,
            "description": "Rows the group keeps (tombstones not counted).",
            "format": "int64",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "SyncForgottenView": {
        "description": "A member that left, forgotten.",
        "properties": {
          "forgotten": {
            "default": false,
            "description": "Always true: the member that left is forgotten.",
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "SyncGroupConfig": {
        "additionalProperties": false,
        "description": "A sync group, as kept with the settings (`[[sync_groups]]`).",
        "properties": {
          "domains": {
            "description": "The data kept the same: people, access, lists, settings, punches,\neach at most once. Anything not listed is left to whatever else\nmanages it. Default: none (the group keeps nothing the same).",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "external_ids": {
            "$ref": "#/components/schemas/BTreeMap",
            "description": "What other systems know the group by: system name to id\n(`{\"payroll\": \"site-12\"}`). Events about its devices and people\ncarry the group's id; these are for whoever maps it to theirs."
          },
          "id": {
            "description": "The group's id: 1-64 letters, digits, '-' or '_'. Endpoints name\nthe group by it (`sync_group`).",
            "type": "string"
          },
          "lists": {
            "$ref": "#/components/schemas/DomainPolicy",
            "description": "Who decides list items."
          },
          "metadata": {
            "description": "Free-form data from other systems (the group's work codes, job\ncodes), kept as given: never read by Connect, never sent with events.",
            "type": "object"
          },
          "people": {
            "$ref": "#/components/schemas/PeoplePolicy",
            "description": "How the group keeps people."
          },
          "placement": {
            "description": "Where people go, inside the group: a person is placed on a member\nwhen any rule's `people` selector picks the person and its `devices`\nselector picks the member (selectors: `docs/selectors.md`). None:\neveryone on every member. A person's own `devices` list is used\ninstead of the rules. At most 100 rules.",
            "items": {
              "$ref": "#/components/schemas/PlacementRule"
            },
            "type": "array"
          },
          "punches": {
            "$ref": "#/components/schemas/PunchesPolicy",
            "description": "How the group shares punches."
          },
          "routes": {
            "description": "Default routes for the punches of its people: each names a\nreceiving system and a tenant in it, never a person. An endpoint's\nown replace these to the same system, and a person's own replace\nboth (`routes`).",
            "items": {
              "$ref": "#/components/schemas/Route"
            },
            "type": "array"
          },
          "settings": {
            "$ref": "#/components/schemas/DomainPolicy",
            "description": "Who decides setting values."
          },
          "sinks": {
            "description": "The sinks the group's own events go to (person.*, access.*, list.*,\nsetting.*, sync.*); each must exist. Default: none.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "id"
        ],
        "type": "object"
      },
      "SyncGroupDetail": {
        "allOf": [
          {
            "description": "A sync group as the API lists it: its settings, the endpoints whose\ndevices are its members, and how many members it has resolved.",
            "properties": {
              "domains": {
                "default": [],
                "description": "The data it keeps the same: people, access, lists, settings, punches.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "endpoints": {
                "default": [],
                "description": "The endpoints that name the group: their devices are its members.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "external_ids": {
                "additionalProperties": {
                  "type": "string"
                },
                "default": {},
                "description": "What other systems know the group by.",
                "propertyNames": {
                  "type": "string"
                },
                "type": "object"
              },
              "id": {
                "default": "",
                "description": "The group's id.",
                "type": "string"
              },
              "lists": {
                "default": {
                  "authority": "group"
                },
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/DomainPolicy",
                    "description": "Who decides list items."
                  }
                ]
              },
              "members": {
                "default": 0,
                "description": "How many members it has (devices that left not counted).",
                "minimum": 0,
                "type": "integer"
              },
              "metadata": {
                "description": "Free-form data from other systems, as given.",
                "type": "object"
              },
              "people": {
                "default": {
                  "authority": "group",
                  "biometrics": false
                },
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/PeoplePolicy",
                    "description": "How it keeps people."
                  }
                ]
              },
              "placement": {
                "default": [],
                "description": "Where people go, inside the group (left out: everyone on every member).",
                "items": {
                  "$ref": "#/components/schemas/PlacementRule"
                },
                "type": "array"
              },
              "punches": {
                "default": {
                  "lockout_minutes": 0
                },
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/PunchesPolicy",
                    "description": "How it shares punches."
                  }
                ]
              },
              "routes": {
                "default": [],
                "description": "Default routes for the punches of its people.",
                "items": {
                  "$ref": "#/components/schemas/Route"
                },
                "type": "array"
              },
              "settings": {
                "default": {
                  "authority": "group"
                },
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/DomainPolicy",
                    "description": "Who decides setting values."
                  }
                ]
              },
              "sinks": {
                "default": [],
                "description": "The sinks its own events (person.*, access.*, list.*, setting.*,\nsync.*) go to.",
                "items": {
                  "type": "string"
                },
                "type": "array"
              }
            },
            "type": "object"
          },
          {
            "properties": {
              "status": {
                "additionalProperties": {
                  "$ref": "#/components/schemas/SyncDomainStatus"
                },
                "description": "For each domain the group keeps: its rows, and its members' rows by\nstate.",
                "propertyNames": {
                  "type": "string"
                },
                "type": "object"
              }
            },
            "type": "object"
          }
        ],
        "description": "One sync group, with per domain its rows and its members' rows by state."
      },
      "SyncGroupView": {
        "description": "A sync group as the API lists it: its settings, the endpoints whose\ndevices are its members, and how many members it has resolved.",
        "properties": {
          "domains": {
            "default": [],
            "description": "The data it keeps the same: people, access, lists, settings, punches.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "endpoints": {
            "default": [],
            "description": "The endpoints that name the group: their devices are its members.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "external_ids": {
            "additionalProperties": {
              "type": "string"
            },
            "default": {},
            "description": "What other systems know the group by.",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "id": {
            "default": "",
            "description": "The group's id.",
            "type": "string"
          },
          "lists": {
            "default": {
              "authority": "group"
            },
            "oneOf": [
              {
                "$ref": "#/components/schemas/DomainPolicy",
                "description": "Who decides list items."
              }
            ]
          },
          "members": {
            "default": 0,
            "description": "How many members it has (devices that left not counted).",
            "minimum": 0,
            "type": "integer"
          },
          "metadata": {
            "description": "Free-form data from other systems, as given.",
            "type": "object"
          },
          "people": {
            "default": {
              "authority": "group",
              "biometrics": false
            },
            "oneOf": [
              {
                "$ref": "#/components/schemas/PeoplePolicy",
                "description": "How it keeps people."
              }
            ]
          },
          "placement": {
            "default": [],
            "description": "Where people go, inside the group (left out: everyone on every member).",
            "items": {
              "$ref": "#/components/schemas/PlacementRule"
            },
            "type": "array"
          },
          "punches": {
            "default": {
              "lockout_minutes": 0
            },
            "oneOf": [
              {
                "$ref": "#/components/schemas/PunchesPolicy",
                "description": "How it shares punches."
              }
            ]
          },
          "routes": {
            "default": [],
            "description": "Default routes for the punches of its people.",
            "items": {
              "$ref": "#/components/schemas/Route"
            },
            "type": "array"
          },
          "settings": {
            "default": {
              "authority": "group"
            },
            "oneOf": [
              {
                "$ref": "#/components/schemas/DomainPolicy",
                "description": "Who decides setting values."
              }
            ]
          },
          "sinks": {
            "default": [],
            "description": "The sinks its own events (person.*, access.*, list.*, setting.*,\nsync.*) go to.",
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "SyncIdChangeView": {
        "description": "A member's part in a user id change.",
        "properties": {
          "device": {
            "default": "",
            "description": "The member's device id.",
            "type": "string"
          },
          "endpoint": {
            "default": "",
            "description": "The member's endpoint.",
            "type": "string"
          },
          "error": {
            "default": null,
            "description": "Why it failed or was refused; null otherwise.",
            "type": [
              "string",
              "null"
            ]
          },
          "new_user_id": {
            "default": "",
            "description": "The id the person has now. At most 128 characters: a user id is indexed, and a longer one is refused (400).",
            "type": "string"
          },
          "old_user_id": {
            "default": "",
            "description": "The id the person had.",
            "type": "string"
          },
          "started_at": {
            "default": "1970-01-01T00:00:00Z",
            "description": "When the change started on the member.",
            "format": "date-time",
            "type": "string"
          },
          "state": {
            "default": "",
            "description": "running, done, failed (the old user is kept; retry carries on from\nthe step), refused (it could lose templates; retry to go ahead).",
            "type": "string"
          },
          "step": {
            "default": "",
            "description": "Where it is: settle, create, verify_new, delete_old, verify_old\n(a member that renames: delete_old is the rename).",
            "type": "string"
          },
          "step_at": {
            "default": "1970-01-01T00:00:00Z",
            "description": "When it reached its step.",
            "format": "date-time",
            "type": "string"
          }
        },
        "type": "object"
      },
      "SyncMemberRowView": {
        "allOf": [
          {
            "default": {
              "applied_version": 0,
              "attempts": 0,
              "state": "pending"
            },
            "oneOf": [
              {
                "description": "A member's state for a row.",
                "properties": {
                  "action": {
                    "default": null,
                    "oneOf": [
                      {
                        "type": "null"
                      },
                      {
                        "$ref": "#/components/schemas/SyncRowActionView",
                        "description": "A row being sent: the action carrying it."
                      }
                    ]
                  },
                  "applied_hash": {
                    "default": null,
                    "description": "What the member was last sent of the row, hashed as the member\ntakes it. Left out when nothing was.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "applied_version": {
                    "default": 0,
                    "description": "The row's version the member has (or was found not to take). 0: none yet.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "attempts": {
                    "default": 0,
                    "description": "Sends that failed, or went unanswered, in a row.",
                    "format": "int32",
                    "type": "integer"
                  },
                  "error": {
                    "default": null,
                    "description": "A failed row: why the last send failed; for one whose command was given up on, \"the clock never answered\n<kind> <id>, sent at <time>\".",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "last_command": {
                    "default": null,
                    "description": "The id of the action carrying it.",
                    "format": "int64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "omitted": {
                    "description": "What the member's projection leaves out (a second card), and why.",
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "reason": {
                    "default": null,
                    "description": "Why it is unsupported or not applicable; for a row being sent whose command is in the device's hand, what it waits\nfor (\"waiting for the clock to answer <kind> <id>, sent at <time>\": state, not failure: it ends when the device\nanswers, or when the action is given up on).",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "reported": {
                    "description": "What the device last reported for a row of someone the group does\nnot have (its fields, never secrets).",
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "reported_at": {
                    "default": null,
                    "description": "When the device last reported the row.",
                    "format": "date-time",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "reported_hash": {
                    "default": null,
                    "description": "What the device last reported of the row, hashed. Left out when it\nhas not reported it.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "sending_hash": {
                    "default": null,
                    "description": "What is being sent, hashed as the member takes it.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "sending_version": {
                    "default": null,
                    "description": "The version being sent, or that failed.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "state": {
                    "default": "pending",
                    "oneOf": [
                      {
                        "$ref": "#/components/schemas/ShownRowState",
                        "description": "Where the member is with the row."
                      }
                    ]
                  }
                },
                "type": "object"
              }
            ]
          },
          {
            "properties": {
              "deleted": {
                "default": false,
                "description": "The row is deleted (a tombstone the group keeps until every member\nconfirmed the delete); `state` is then where the member is with the\ndelete. Left out otherwise.",
                "type": "boolean"
              },
              "domain": {
                "default": "",
                "description": "The row's domain: people, access, lists or settings.",
                "type": "string"
              },
              "key": {
                "default": "",
                "description": "The row's key: a user id, `<user_id>/<kind>/<slot>/<format>` for a\ncredential, `<class>/<name>` for a setting, or the row's own key.",
                "type": "string"
              },
              "kind": {
                "default": "",
                "description": "The row's kind: person, credential, schedule, work_code, setting...",
                "type": "string"
              }
            },
            "type": "object"
          }
        ],
        "description": "Where a member is with one row."
      },
      "SyncMemberView": {
        "description": "A member of a sync group, or a device that was one and left.",
        "properties": {
          "counts": {
            "description": "Its rows by domain, then by state.",
            "type": "object"
          },
          "declaration": {
            "description": "What the device takes and reports, as its package declares it,\nresolved for what the device says about itself.",
            "type": "object"
          },
          "deletes_waiting": {
            "default": null,
            "description": "One that left: how many deletes (tombstones) still wait for it to\nconfirm them. Null for a member.",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "device": {
            "default": "",
            "description": "The member's device id.",
            "type": "string"
          },
          "endpoint": {
            "default": "",
            "description": "The member's endpoint.",
            "type": "string"
          },
          "id_changes": {
            "default": [],
            "description": "User id changes under way on it, failed or refused.",
            "items": {
              "$ref": "#/components/schemas/SyncIdChangeView"
            },
            "type": "array"
          },
          "inventory": {
            "default": "",
            "description": "The action that makes it upload every user, or \"none\": then what it\nholds is known only from what it was sent.",
            "type": "string"
          },
          "inventory_at": {
            "default": null,
            "description": "When it last took inventory (uploaded every user); null when it has\nnot taken one since it joined or was last sent everything again.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "labels": {
            "description": "Its labels, as placement last saw them: its endpoint's, with its own\nover them.",
            "type": "object"
          },
          "last_error": {
            "default": null,
            "description": "The error of one of its rows that has one; null when none has.",
            "type": [
              "string",
              "null"
            ]
          },
          "left_at": {
            "default": null,
            "description": "When it stopped being a member; null for a member. One that left is\nremembered until it confirms the deletes it missed, or is forgotten\n(`DELETE .../members/{endpoint}/{device}`).",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "paused": {
            "default": null,
            "description": "Why what it reports is not taken (the bulk-delete guard), if so;\nnull when it is not paused.",
            "type": [
              "string",
              "null"
            ]
          },
          "settings_class": {
            "default": null,
            "description": "Its settings class: devices of the same class share setting values.\nNull when it takes no settings.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "SyncOutcomesView": {
        "description": "How the rows written fare on the members: taken, not taken (with why),\nor not the kind of data a member takes at all.",
        "properties": {
          "applies": {
            "default": 0,
            "description": "(row, member) pairs where the member takes the row: it is sent.",
            "minimum": 0,
            "type": "integer"
          },
          "not_applicable": {
            "default": 0,
            "description": "(row, member) pairs where the member does not take this kind of\ndata at all.",
            "minimum": 0,
            "type": "integer"
          },
          "not_placed": {
            "default": 0,
            "description": "(person, member) pairs the group's placement does not put together.",
            "minimum": 0,
            "type": "integer"
          },
          "unsupported": {
            "default": [],
            "description": "The members that take this kind of data but cannot take a row, and\nwhy.",
            "items": {
              "$ref": "#/components/schemas/SyncUnsupportedView"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "SyncPersonMemberView": {
        "allOf": [
          {
            "default": {
              "applied_version": 0,
              "attempts": 0,
              "state": "pending"
            },
            "oneOf": [
              {
                "description": "A member's state for a row.",
                "properties": {
                  "action": {
                    "default": null,
                    "oneOf": [
                      {
                        "type": "null"
                      },
                      {
                        "$ref": "#/components/schemas/SyncRowActionView",
                        "description": "A row being sent: the action carrying it."
                      }
                    ]
                  },
                  "applied_hash": {
                    "default": null,
                    "description": "What the member was last sent of the row, hashed as the member\ntakes it. Left out when nothing was.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "applied_version": {
                    "default": 0,
                    "description": "The row's version the member has (or was found not to take). 0: none yet.",
                    "format": "int64",
                    "type": "integer"
                  },
                  "attempts": {
                    "default": 0,
                    "description": "Sends that failed, or went unanswered, in a row.",
                    "format": "int32",
                    "type": "integer"
                  },
                  "error": {
                    "default": null,
                    "description": "A failed row: why the last send failed; for one whose command was given up on, \"the clock never answered\n<kind> <id>, sent at <time>\".",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "last_command": {
                    "default": null,
                    "description": "The id of the action carrying it.",
                    "format": "int64",
                    "minimum": 0,
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "omitted": {
                    "description": "What the member's projection leaves out (a second card), and why.",
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "reason": {
                    "default": null,
                    "description": "Why it is unsupported or not applicable; for a row being sent whose command is in the device's hand, what it waits\nfor (\"waiting for the clock to answer <kind> <id>, sent at <time>\": state, not failure: it ends when the device\nanswers, or when the action is given up on).",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "reported": {
                    "description": "What the device last reported for a row of someone the group does\nnot have (its fields, never secrets).",
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "reported_at": {
                    "default": null,
                    "description": "When the device last reported the row.",
                    "format": "date-time",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "reported_hash": {
                    "default": null,
                    "description": "What the device last reported of the row, hashed. Left out when it\nhas not reported it.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "sending_hash": {
                    "default": null,
                    "description": "What is being sent, hashed as the member takes it.",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "sending_version": {
                    "default": null,
                    "description": "The version being sent, or that failed.",
                    "format": "int64",
                    "type": [
                      "integer",
                      "null"
                    ]
                  },
                  "state": {
                    "default": "pending",
                    "oneOf": [
                      {
                        "$ref": "#/components/schemas/ShownRowState",
                        "description": "Where the member is with the row."
                      }
                    ]
                  }
                },
                "type": "object"
              }
            ]
          },
          {
            "properties": {
              "device": {
                "default": "",
                "description": "The member's device id.",
                "type": "string"
              },
              "endpoint": {
                "default": "",
                "description": "The member's endpoint.",
                "type": "string"
              }
            },
            "type": "object"
          }
        ],
        "description": "Where one member is with a person."
      },
      "SyncPunchesView": {
        "description": "A person's latest punch in a group, and the recent ones.",
        "properties": {
          "device": {
            "default": "",
            "description": "The device it was punched on.",
            "type": "string"
          },
          "endpoint": {
            "default": "",
            "description": "The endpoint of the device it was punched on.",
            "type": "string"
          },
          "event_id": {
            "default": "",
            "description": "The punch event's id.",
            "type": "string"
          },
          "local": {
            "default": "",
            "description": "The wall time it was punched at, as the device showed it.",
            "type": "string"
          },
          "recent": {
            "default": [],
            "description": "The latest few punches, newest first (the first is the latest),\neach with `time` (with the offset the device recorded it under),\n`local`, `endpoint`, `device`, `id` (the punch event's id), and\n`state_name` and `work_code` when it had them.",
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "state_name": {
            "default": null,
            "description": "What the punch was (check_in, check_out, ...); null when the device\ngave no name.",
            "type": [
              "string",
              "null"
            ]
          },
          "time": {
            "default": "1970-01-01T00:00:00Z",
            "description": "When the latest punch was made.",
            "format": "date-time",
            "type": "string"
          },
          "user_id": {
            "default": "",
            "description": "The person's user id.",
            "type": "string"
          },
          "work_code": {
            "default": null,
            "description": "The work code punched with; null when none.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "SyncResumedView": {
        "description": "A member taking what it reports again.",
        "properties": {
          "resumed": {
            "default": false,
            "description": "false if it was not paused.",
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "SyncResyncView": {
        "description": "A member sent everything again.",
        "properties": {
          "rows": {
            "default": 0,
            "description": "How many rows will be sent again.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "SyncRetriedMemberView": {
        "description": "A member an id change carries on on, and the step it carries on from.",
        "properties": {
          "device": {
            "default": "",
            "description": "The member's device id.",
            "type": "string"
          },
          "endpoint": {
            "default": "",
            "description": "The member's endpoint.",
            "type": "string"
          },
          "step": {
            "default": "",
            "description": "The step the change carries on from: settle, create, verify_new,\ndelete_old or verify_old.",
            "type": "string"
          }
        },
        "type": "object"
      },
      "SyncRetriedView": {
        "description": "An id change carried on from where it stopped.",
        "properties": {
          "retried": {
            "default": [],
            "description": "The members where it carries on.",
            "items": {
              "$ref": "#/components/schemas/SyncRetriedMemberView"
            },
            "type": "array"
          }
        },
        "type": "object"
      },
      "SyncRetryView": {
        "description": "A member's failed rows sent again.",
        "properties": {
          "rows": {
            "default": 0,
            "description": "How many failed rows will be sent again.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "SyncRowActionView": {
        "description": "The action carrying a row to a member.",
        "properties": {
          "id": {
            "default": 0,
            "description": "The action's id on the member's device.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "sent_at": {
            "default": null,
            "description": "When its step now out was handed to the device; null while queued. A step handed out waits for the device's\nanswer, with no time limit: it is answered, lost (the device answered one handed out after it, or restarted) or\ncancelled.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "default": null,
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/ActionStatus",
                "description": "queued, in_progress, done, failed, cancelled (null: no longer kept)."
              }
            ]
          }
        },
        "type": "object"
      },
      "SyncRowView": {
        "description": "A registry row: never its secrets or bytes.",
        "properties": {
          "changed_at": {
            "default": "1970-01-01T00:00:00Z",
            "description": "When it last changed.",
            "format": "date-time",
            "type": "string"
          },
          "changed_by": {
            "default": "",
            "description": "`api:<user>` or `device:<endpoint>/<device>`.",
            "type": "string"
          },
          "deleted": {
            "default": false,
            "description": "A tombstone: the row was deleted, and is kept until every member\nconfirmed the delete. Its fields are then gone (a credential keeps\nits kind, slot and format).",
            "type": "boolean"
          },
          "domain": {
            "default": "",
            "description": "The row's domain: people, access, lists or settings.",
            "type": "string"
          },
          "fields": {
            "description": "The row's fields, without secrets.",
            "type": "object"
          },
          "key": {
            "default": "",
            "description": "The row's key: a user id, `<user_id>/<kind>/<slot>/<format>` for a\ncredential, `<class>/<name>` for a setting, or the key it was\nwritten under.",
            "type": "string"
          },
          "kind": {
            "default": "",
            "description": "The row's kind: person, credential, schedule, holiday,\naccess_group, zone, work_code, job_code, tip_code, message or\nsetting.",
            "type": "string"
          },
          "secrets_set": {
            "default": null,
            "description": "The secrets it holds (keypad_pin, password), by name.",
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "sha256": {
            "default": null,
            "description": "A credential's bytes, hashed.",
            "type": [
              "string",
              "null"
            ]
          },
          "slot": {
            "default": null,
            "description": "The group-wide number devices that number this kind know it by.",
            "format": "int32",
            "type": [
              "integer",
              "null"
            ]
          },
          "unreadable": {
            "default": null,
            "description": "Its sealed values could not be opened (the secret key is gone).",
            "type": [
              "string",
              "null"
            ]
          },
          "version": {
            "default": 0,
            "description": "The group's sequence number of its latest change.",
            "format": "int64",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "SyncSettingsView": {
        "description": "The values a group keeps for a settings class.",
        "properties": {
          "class": {
            "default": "",
            "description": "The settings class, or `*`.",
            "type": "string"
          },
          "values": {
            "description": "Setting name to value; a sensitive one only as its size\n(`<redacted N bytes>`).",
            "type": "object"
          },
          "versions": {
            "description": "Setting name to the version of its latest change.",
            "type": "object"
          }
        },
        "type": "object"
      },
      "SyncUnsupportedView": {
        "description": "A member a written row cannot go to, and why.",
        "properties": {
          "device": {
            "default": "",
            "description": "The member's device id.",
            "type": "string"
          },
          "endpoint": {
            "default": "",
            "description": "The member's endpoint.",
            "type": "string"
          },
          "key": {
            "default": "",
            "description": "The row's key.",
            "type": "string"
          },
          "reason": {
            "default": "",
            "description": "Why the member cannot take it.",
            "type": "string"
          }
        },
        "type": "object"
      },
      "SyncWriteView": {
        "description": "What a registry write did.",
        "properties": {
          "changed": {
            "default": 0,
            "description": "Rows changed (writing the same values again changes none).",
            "minimum": 0,
            "type": "integer"
          },
          "members": {
            "default": {
              "applies": 0,
              "not_applicable": 0,
              "not_placed": 0,
              "unsupported": []
            },
            "oneOf": [
              {
                "$ref": "#/components/schemas/SyncOutcomesView",
                "description": "How the rows changed fare on the group's members."
              }
            ]
          },
          "version": {
            "default": 0,
            "description": "The newest version of the rows written.",
            "format": "int64",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "Targets": {
        "additionalProperties": false,
        "description": "Which devices a job runs on, found when it is created: the allowed\ndevices of `endpoints` (every endpoint when none is named) that\n`select` picks by their labels (the endpoint's labels with the device's\nown over them), when either is given; and the devices listed in\n`devices`.",
        "properties": {
          "devices": {
            "description": "Devices by \"endpoint/device\".",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "endpoints": {
            "description": "The endpoints whose allowed devices it runs on (with `select`, those\nit picks). Absent: every endpoint, when `select` is given.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "select": {
            "description": "A selector over the devices' labels (`docs/selectors.md`):\n`site = north and floor in (1, 2)`.",
            "example": "site = north and floor in (1, 2)",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "TenantChange": {
        "additionalProperties": false,
        "description": "What to change of a tenant: what is given, the rest kept.",
        "properties": {
          "external_ids": {
            "type": [
              "object",
              "null"
            ]
          },
          "metadata": {
            "description": "The whole metadata, in place of what it was: at most 16 KiB as\nJSON, 16 levels deep. Changed, everyone of the tenant is worked out\nagain (policies read it).",
            "type": [
              "object",
              "null"
            ]
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "TenantConfig": {
        "additionalProperties": false,
        "description": "A tenant, as the install keeps it (`[[tenant]]`).",
        "properties": {
          "adopted": {
            "additionalProperties": {
              "type": "string"
            },
            "description": "The shared policy packages it adopted, by name: the major version\nit follows (`\"2\"`) or the version it pins (`\"2.3.1\"`). Its endpoints\nname them as their `policy`.",
            "propertyNames": {
              "type": "string"
            },
            "type": "object"
          },
          "external_ids": {
            "$ref": "#/components/schemas/BTreeMap",
            "description": "What other systems know it by: system name to id."
          },
          "id": {
            "description": "Its id: 1 to 64 letters, digits, '-' or '_'. It is how the admin\nAPI's paths (`/api/tenants/{tenant}/...`), `hourctl --tenant` and\ntokens (`connect:<tenant>`) name it, and it cannot be changed.",
            "type": "string"
          },
          "limits": {
            "$ref": "#/components/schemas/TenantLimits",
            "description": "Its own limits, over the install's defaults (`limits.tenants`)."
          },
          "metadata": {
            "description": "Free-form data from other systems, kept as given.",
            "type": "object"
          },
          "name": {
            "description": "A name for people to know it by.",
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/TenantStatus",
            "description": "`active` (the default), `suspended` or `stopped`."
          }
        },
        "required": [
          "id"
        ],
        "type": "object"
      },
      "TenantLimits": {
        "additionalProperties": false,
        "description": "A tenant's own limits; each one absent takes the install's default\n(`limits.tenants`), and 0 is no limit.",
        "properties": {
          "devices": {
            "default": null,
            "description": "Devices it may have that are not waiting to be allowed (allowed or\nblocked). A device beyond it is refused registration (a stranger is\nanswered 429 and kept nowhere; one added through the API, 409).",
            "format": "int64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "messages_per_second": {
            "default": null,
            "description": "Device messages a second its devices may send to one instance, all\ntogether; a message over it is answered \"try again later\" (503 with\n`Retry-After`) and is not taken in.",
            "format": "int32",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "packages": {
            "default": null,
            "description": "Policy package lines (`name@major.minor`) it may keep of its own,\neach with up to the revisions kept of a line. A push of a line it\ndoes not have yet, past the limit, is refused (409); a new revision\nof a line it has is not. Default 50.",
            "format": "int64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "pending_devices": {
            "default": null,
            "description": "Devices it may have waiting to be allowed, across its endpoints\n(each endpoint's own `max_pending_devices` applies too). Strangers\nbeyond it are refused (429).",
            "format": "int64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "people": {
            "default": null,
            "description": "People its sync groups may keep, all groups together. A write\nthrough the API that would add one more is refused; nothing a clock\nsends is. A tenant found over it all the same (the limit lowered\nbelow what it has, two writes at once each taking the last place)\nis told once (`tenant.limit_reached`), and again only after it was\nback within it.",
            "format": "int64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          },
          "set_aside": {
            "default": null,
            "description": "MQTT messages it may have set aside at once (kept until their\ndevice is allowed, say: the site's `/docs/mqtt/` page). One more is held\nunacknowledged instead, and the broker keeps it. Default 10000.",
            "format": "int64",
            "minimum": 0,
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "TenantStatus": {
        "description": "Where a tenant stands. Suspending or stopping one is the operator's\nbusiness decision; either stops everything Connect does for it until it\nis resumed: its devices' requests are refused with a \"come back later\"\n(never taken in and dropped: a clock keeps what was not acknowledged),\nno command goes out, and none of its jobs, sync groups or sinks runs.",
        "enum": [
          "active",
          "suspended",
          "stopped"
        ],
        "type": "string"
      },
      "TenantView": {
        "description": "A tenant.",
        "properties": {
          "created": {
            "format": "date-time",
            "type": "string"
          },
          "external_ids": {
            "description": "Its id in each other system, by the system's name.",
            "type": "object"
          },
          "id": {
            "description": "Its id, as paths and sinks name it: opaque to the engine.",
            "type": "string"
          },
          "loading": {
            "description": "Set while a document is being loaded into it (`import`): it cannot\nbe changed, suspended, resumed or deleted (409) until the load ends.",
            "type": "boolean"
          },
          "metadata": {
            "description": "Kept as given, never read by the engine; policies read it\n(`ctx:tenant()`).",
            "type": "object"
          },
          "name": {
            "type": "string"
          },
          "status": {
            "description": "active, or suspended (nothing worked out, writes refused, its sinks'\ndeliveries refused until it is resumed).",
            "type": "string"
          },
          "updated": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "external_ids",
          "metadata",
          "status",
          "created",
          "updated"
        ],
        "type": "object"
      },
      "TimecardView": {
        "description": "A person's timecard of a pay period, as last worked out.",
        "properties": {
          "approvals": {
            "description": "Where each subject's approval stands: each `subject`, `state`, and,\nwaiting, the `approver` it is routed to and the `organization` it\nwaits on.",
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "approved": {
            "description": "Approved at every stage of the period's approval.",
            "type": "boolean"
          },
          "closed": {
            "description": "When it was closed; null: open.",
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "exceptions": {
            "description": "How many of its exceptions are open or acknowledged.",
            "minimum": 0,
            "type": "integer"
          },
          "first": {
            "example": "2026-10-05",
            "type": "string"
          },
          "last": {
            "example": "2026-10-18",
            "type": "string"
          },
          "paid": {
            "description": "Its decimal hours in paid categories.",
            "type": "string"
          },
          "person": {
            "type": "string"
          },
          "worked": {
            "description": "Its worked time.",
            "type": "string"
          }
        },
        "required": [
          "person",
          "first",
          "last",
          "paid",
          "worked",
          "approved",
          "approvals",
          "exceptions"
        ],
        "type": "object"
      },
      "TimecardsPage": {
        "description": "A page of timecards.",
        "properties": {
          "next": {
            "description": "Pass as `after` for the next page; null: there is none.",
            "type": [
              "string",
              "null"
            ]
          },
          "timecards": {
            "items": {
              "$ref": "#/components/schemas/TimecardView"
            },
            "type": "array"
          }
        },
        "required": [
          "timecards"
        ],
        "type": "object"
      },
      "Totals": {
        "description": "What some lines come to.",
        "properties": {
          "categories": {
            "description": "By pay category, by name.",
            "items": {
              "$ref": "#/components/schemas/CategoryTotal"
            },
            "type": "array"
          },
          "paid": {
            "description": "The decimal hours of the lines in paid categories.",
            "example": "8.00",
            "type": "string"
          },
          "quantities": {
            "description": "The counts and money, by measure and category.",
            "items": {
              "$ref": "#/components/schemas/QuantityTotal"
            },
            "type": "array"
          },
          "worked": {
            "description": "The time of the lines in categories that count as worked.",
            "example": "8h",
            "type": "string"
          }
        },
        "required": [
          "paid",
          "worked",
          "categories",
          "quantities"
        ],
        "type": "object"
      },
      "Traffic": {
        "description": "One device message the instance handled, and what became of it.",
        "properties": {
          "at": {
            "description": "When it was handled.",
            "format": "date-time",
            "type": "string"
          },
          "device": {
            "description": "The device it came from, by id; null when it could not be told.",
            "type": [
              "string",
              "null"
            ]
          },
          "duration_ms": {
            "description": "How long handling it took, in milliseconds.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "endpoint": {
            "description": "The endpoint it came in on.",
            "type": "string"
          },
          "error": {
            "description": "What went wrong; null when nothing did.",
            "type": [
              "string",
              "null"
            ]
          },
          "events": {
            "description": "How many events it made and stored.",
            "minimum": 0,
            "type": "integer"
          },
          "method": {
            "description": "The request method (\"GET\", \"POST\"; \"PUBLISH\" for mqtt).",
            "type": "string"
          },
          "not_stored": {
            "description": "How many events it made that could not be stored, though the device\nwas answered as if they were (an endpoint whose package delivers by\n`cursor` or `none` is not told to send again): they are counted in\n`houradvantage_events_not_stored_total`. Absent when none.",
            "minimum": 0,
            "type": "integer"
          },
          "path": {
            "description": "The request path (http) or topic (mqtt).",
            "type": "string"
          },
          "query": {
            "description": "The query string, without the '?'; empty when there is none.",
            "type": "string"
          },
          "remote_ip": {
            "description": "The client address it came from (the one a trusted proxy names, when\none forwarded it); `mqtt` for a message taken from a broker.",
            "type": "string"
          },
          "request_body": {
            "description": "The request body as text, up to `limits.traffic_body_bytes`, with\ncontrol characters replaced and what was cut off counted.",
            "type": "string"
          },
          "request_bytes": {
            "description": "The request body's size, in bytes.",
            "minimum": 0,
            "type": "integer"
          },
          "response_body": {
            "description": "The answer's body as text, kept as `request_body` is, with values the\npackage marks secret masked.",
            "type": "string"
          },
          "route": {
            "description": "The package route that handled it; null when none matched, or none\nwas tried.",
            "type": [
              "string",
              "null"
            ]
          },
          "seq": {
            "description": "Its number in this instance's traffic log, counted from 1 since the\ninstance started.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "status": {
            "description": "The status the device was answered with.",
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "seq",
          "at",
          "endpoint",
          "remote_ip",
          "method",
          "path",
          "query",
          "request_body",
          "request_bytes",
          "status",
          "response_body",
          "events",
          "duration_ms"
        ],
        "type": "object"
      },
      "UnlinkedPage": {
        "description": "A page of them.",
        "properties": {
          "next": {
            "description": "Pass as `after` for the next page; null: there is none.",
            "type": [
              "string",
              "null"
            ]
          },
          "unlinked": {
            "items": {
              "$ref": "#/components/schemas/UnlinkedView"
            },
            "type": "array"
          }
        },
        "required": [
          "unlinked"
        ],
        "type": "object"
      },
      "UnlinkedView": {
        "description": "An unlinked person.",
        "properties": {
          "first_seen": {
            "example": "2026-10-05T13:00:06Z",
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "description": "Their id in the tenant, from the sender's ids: `<group>~<person>`\n(Connect's id of the person in their group), after\n`<connect tenant>.` unless that is the default one. Their ledger,\nfacts and exceptions are under it.",
            "type": "string"
          },
          "last_seen": {
            "example": "2026-10-07T13:00:02Z",
            "format": "date-time",
            "type": "string"
          },
          "linked": {
            "description": "Whom they are linked to now; null: no one.",
            "type": [
              "string",
              "null"
            ]
          },
          "links": {
            "description": "Their links, oldest first.",
            "items": {
              "$ref": "#/components/schemas/LinkView"
            },
            "type": "array"
          },
          "sender": {
            "$ref": "#/components/schemas/SenderView"
          }
        },
        "required": [
          "id",
          "sender",
          "first_seen",
          "last_seen",
          "links"
        ],
        "type": "object"
      },
      "UnreadablePage": {
        "description": "A page of them.",
        "properties": {
          "next": {
            "description": "Pass as `after` for the next page; null: there is none.",
            "type": [
              "string",
              "null"
            ]
          },
          "punches": {
            "items": {
              "$ref": "#/components/schemas/UnreadableView"
            },
            "type": "array"
          }
        },
        "required": [
          "punches"
        ],
        "type": "object"
      },
      "UnreadableView": {
        "description": "A punch that could not be read.",
        "properties": {
          "event": {
            "description": "The event, as it was delivered.",
            "type": "object"
          },
          "id": {
            "description": "The event's id.",
            "type": "string"
          },
          "stored": {
            "description": "When it was kept.",
            "format": "date-time",
            "type": "string"
          },
          "why": {
            "description": "Why it could not be read.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "event",
          "why",
          "stored"
        ],
        "type": "object"
      },
      "Unrouted": {
        "description": "Why a punch is unrouted.",
        "enum": [
          "no_route",
          "ambiguous",
          "policy",
          "policy_failed",
          "unknown_person",
          "deciding"
        ],
        "type": "string"
      },
      "UnroutedPunchView": {
        "description": "A punch set aside until it is routed, as the API shows it.",
        "properties": {
          "candidates": {
            "description": "Its candidates when it was last worked out.",
            "items": {
              "$ref": "#/components/schemas/Route"
            },
            "type": "array"
          },
          "data": {
            "description": "The punch as its package reported it.",
            "type": "object"
          },
          "device": {
            "description": "The device that took it.",
            "type": "string"
          },
          "endpoint": {
            "description": "The endpoint's id within the tenant.",
            "type": "string"
          },
          "id": {
            "description": "The punch's id (its event's): the same once it is routed.",
            "type": "string"
          },
          "reason": {
            "$ref": "#/components/schemas/Unrouted",
            "description": "Why it is unrouted: no_route, unknown_person, ambiguous, policy,\npolicy_failed or deciding."
          },
          "received_at": {
            "description": "When Connect received it.",
            "format": "date-time",
            "type": "string"
          },
          "user_id": {
            "description": "The person's user id.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "user_id",
          "endpoint",
          "device",
          "received_at",
          "data",
          "reason",
          "candidates"
        ],
        "type": "object"
      },
      "UpdateDevice": {
        "additionalProperties": false,
        "description": "A change to a device: each field left out is not changed.",
        "properties": {
          "adopt_key": {
            "description": "True makes a key the device presented its active key: how a device\nrefused for presenting another key is let in again. For a device\nthat presented a key while it was held (`key_held`), the first key\nit presented then, the one seen when deciding to allow it, never a\nlater one; else the key it is presenting.",
            "type": "boolean"
          },
          "adopt_presented_key": {
            "description": "True makes the key the device is presenting now its active key,\nwhatever it was held with: the choice to make, knowingly, after a\n`key_conflict_at`.",
            "type": "boolean"
          },
          "external_ids": {
            "description": "What other systems know the device by, merged in as `labels` is: a\ntext sets a system's id, null takes it away. At most 32 systems.",
            "type": [
              "object",
              "null"
            ]
          },
          "key": {
            "description": "A string sets the key (1 to 128 characters, none of them control\ncharacters), null takes it away, leaving it out changes nothing.",
            "type": [
              "string",
              "null"
            ]
          },
          "labels": {
            "description": "The device's own labels, merged in as a JSON merge patch does: a\nvalue sets the label, null takes it away, a label left out stays.\nThey are put over its endpoint's labels; a sync group's placement\nrules pick members by them. At most 64 labels; a name is 1 to 63\nletters, digits, `-`, `_`, `.` or `/`, a value 1 to 63 letters,\ndigits, `-`, `_` or `.`.",
            "type": [
              "object",
              "null"
            ]
          },
          "metadata": {
            "description": "Free-form data from other systems, merged in as a JSON merge patch.\nKept as given (at most 16 KiB of JSON), never read by Connect.",
            "type": [
              "object",
              "null"
            ]
          },
          "status": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/DeviceStatus",
                "description": "`allowed`, `blocked` or `pending`."
              }
            ]
          }
        },
        "type": "object"
      },
      "UpdateLogs": {
        "additionalProperties": false,
        "description": "The log level to use.",
        "properties": {
          "level": {
            "description": "What to log, in `RUST_LOG` syntax: a level (\"error\", \"warn\", \"info\", \"debug\", \"trace\", \"off\"), or a level per\nmodule (\"warn,houradvantage=debug\"). Absent: unchanged.",
            "example": "warn,houradvantage=debug",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "Value": {},
      "VarView": {
        "description": "A var: a value packages read with `vars.get(name)`, for the whole\ntenant or for one package.",
        "properties": {
          "name": {
            "description": "Its name: 1 to 64 letters, digits, '_', '-' or '.'.",
            "type": "string"
          },
          "package": {
            "description": "The package it is for, by name (every version of it); absent: the\ntenant's, for every package. A package's own value of a name is read\nbefore the tenant's.",
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "description": "When it was last set.",
            "format": "date-time",
            "type": "string"
          },
          "updated_by": {
            "description": "Who set it last: the admin login's user name, `token:<name>` for an\nAPI token, or `local` without a login.",
            "type": "string"
          },
          "value": {
            "description": "The value, as text.",
            "type": "string"
          }
        },
        "required": [
          "name",
          "value",
          "updated_at",
          "updated_by"
        ],
        "type": "object"
      },
      "WaveSize": {
        "description": "A wave's size: a count, or a share of every device (\"25%\").",
        "oneOf": [
          {
            "format": "int32",
            "minimum": 0,
            "type": "integer"
          },
          {
            "type": "string"
          }
        ]
      },
      "Window": {
        "additionalProperties": false,
        "description": "When devices may start, in each device's own zone (its endpoint's\n`timezone` option, else its sync group's `*/timezone` setting, else\nUTC). A device already running goes on when the window closes.",
        "properties": {
          "days": {
            "description": "The days it opens on: \"mon\" .. \"sun\" (or the full names). Absent:\nevery day.",
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "hours": {
            "description": "\"HH:MM-HH:MM\", local time; \"22:00-05:00\" runs past midnight into\nthe next day (the day it opened on counts). Absent: the whole day.\nA window gives its days, its hours or both.",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "type": "object"
      },
      "Withdrawn": {
        "description": "What withdrawing a person's biometrics did.",
        "properties": {
          "deletes": {
            "description": "The deletes queued on the group's devices, in the urgent lane: one\nper device and action its package offers.",
            "items": {
              "$ref": "#/components/schemas/QueuedDelete"
            },
            "type": "array"
          },
          "events_purged": {
            "description": "The person's biometric events removed from the event log.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          },
          "undelivered_purged": {
            "description": "Of those, the ones a sink had not taken yet.",
            "format": "int64",
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "events_purged",
          "undelivered_purged",
          "deletes"
        ],
        "type": "object"
      },
      "WorkerView": {
        "description": "A worker's records.",
        "properties": {
          "records": {
            "items": {
              "$ref": "#/components/schemas/RecordView"
            },
            "type": "array"
          },
          "worker": {
            "type": "string"
          }
        },
        "required": [
          "worker",
          "records"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "basic": {
        "description": "The admin login: the user name in `HOURADVANTAGE_ADMIN_USERNAME` and the password whose argon2 hash is in `HOURADVANTAGE_ADMIN_PASSWORD_HASH`. Without a login configured, none is asked for, and only requests whose Host header names a loopback address are answered.",
        "scheme": "basic",
        "type": "http"
      },
      "bearer": {
        "description": "A named API token, `hadv_` and 43 more characters, made with `POST /api/tokens` (`hourctl token create`). It is taken whether or not a login is configured. A token revoked through one instance is refused there at once, and by the other instances when each is told (a note), with no time to wait. A token scoped to one tenant (`connect:<tenant>` or `attend:<tenant>`) reaches only that tenant's routes of that engine, never an install-level route nor the tenant's own record, suspend, resume, stop, delete, export or import; elsewhere it is answered 403.",
        "scheme": "bearer",
        "type": "http"
      },
      "signature": {
        "description": "A delivery's signature, as a Connect webhook sink signs: `v1=` and the HMAC-SHA256, hex, of `<x-houradvantage-timestamp>.<body>`, keyed with one of the tenant's delivery keys (`POST /api/attendance/tenants/{tenant}/delivery-keys`). Only the deliveries route takes it, and it takes nothing else: no login, no API token.",
        "in": "header",
        "name": "x-houradvantage-signature",
        "type": "apiKey"
      }
    }
  },
  "info": {
    "contact": {
      "name": "Tim Williamson"
    },
    "description": "Runs and changes the gateway while it runs: listeners, endpoints, sinks, sync groups, packages, devices and their commands, and what happened.\n\n**Access.** With an admin login configured (`HOURADVANTAGE_ADMIN_USERNAME`, `HOURADVANTAGE_ADMIN_PASSWORD_HASH`), every request needs it (HTTP Basic) or a named API token (`Authorization: Bearer hadv_...`). Without a login, the API answers only requests whose Host header names a loopback address, and refuses requests a proxy forwarded. A request whose Origin header differs from its Host is refused either way. The probes (`/livez`, `/api/health`, `/api/ready`) need no login; `/metrics` needs it, or an install token, as the install's routes do. `POST /api/attendance/tenants/{tenant}/deliveries` takes neither: only a signature by one of the tenant's delivery keys.\n\n**Bodies.** Requests and answers are JSON: send `Content-Type: application/json` with a body. A body that cannot be read is refused before the route sees it: 400 when it is not JSON, 415 without the content type, 422 when it is not the shape asked for (an unknown field, a value of the wrong type). Every refusal is `{\"error\": \"...\"}`, but for a path or query parameter that cannot be read (a number that is not one, a time that is not RFC 3339), which is refused with a plain-text reason. A 422 for parameters that do not fit what a command or action declares also lists what is wrong with each field in `fields`.\n\n**Changes.** Every change that succeeds is added to the audit trail (`GET /api/audit`), with passwords, keys and secrets taken out of the request. A change that moves the config version answers with a `houradvantage-config-version` header: the version every instance is to reach (`GET /api/peers` shows how far each one has got). A change that leaves something for you to do elsewhere says so in a `Warning` header (code 299) for each thing.\n\n**Request ids.** Every answer carries an `X-Request-Id` header: the one the request was sent with when it is 1 to 128 letters, digits, `-`, `_`, `.` or `:`, a new one otherwise (an odd or oversized one is replaced, never cleaned up). The same id is in an `{\"error\"}` body's `request_id`, on the gateway's log lines about the request, in the audit trail entry of the change it made, and in the `request` of every event made while it ran. It is a correlation id only: nothing is allowed or deduplicated by it.\n\n**Retries.** A `POST` or `PATCH` sent with an `Idempotency-Key` header (1 to 255 visible ASCII characters, a UUID say) is done once, however often it is sent, for 24 hours from when it was first sent. Sent again with the same key and the same method, path, query and body, it is answered as it was the first time, refusals too, with `Idempotent-Replayed: true` and the first request's id in `Original-Request`. The same key with another request is refused 422; the same key while its first request runs still, 409. Keys are kept per scope: the install's (the login, an install token) and each tenant token's apart. An answer that says to try again (429) or is a server failure (5xx), and one streamed as it is made (an export), is not kept: the retry runs. The import of a tenant takes no key.",
    "license": {
      "name": "Proprietary: all rights reserved"
    },
    "title": "Hour Advantage admin API",
    "version": "0.1.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/api/attendance/packages/shared": {
      "get": {
        "description": "Every revision of the install's shared policy packages, by name and revision: each version's source, layers,\nscenarios and effective day, whether it is active (published), pushed or failed its scenarios, and how they ran.",
        "operationId": "attendance_shared_packages",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "by": "builder",
                    "description": "The franchise's pay rules.",
                    "effective": "2026-11-02",
                    "layers": [
                      {
                        "id": "overtime",
                        "locks": [
                          "*"
                        ],
                        "order": 10,
                        "revision": 1,
                        "settings": {},
                        "steps": [
                          {
                            "add": {
                              "id": "daily",
                              "params": {
                                "over": "8h",
                                "to": "overtime",
                                "window": "day"
                              },
                              "uses": "standard/threshold"
                            }
                          }
                        ]
                      }
                    ],
                    "name": "franchise",
                    "results": [
                      {
                        "passed": true,
                        "scenario": "overtime.toml"
                      }
                    ],
                    "revision": 2,
                    "scenarios": {
                      "overtime.toml": "description = \"...\""
                    },
                    "state": "active",
                    "stored": "2026-10-20T09:00:00Z",
                    "version": "2.1.0"
                  }
                ],
                "schema": {
                  "items": {
                    "type": "object"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every revision."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List the shared packages",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Takes a version of a shared policy package for the install: its `name`, semver `version`, `description`,\n`effective` day (the workday it is in force from; absent: from the beginning), `source` (its Lua, a module of\nsteps; absent for a package of layers only), `layers` (as a tenant's are, with eligibility rules and locks) and\n`scenarios` (by file name, TOML), which run here first, each with the package adopted, and keeps it as the\npackage's next revision. One whose scenarios fail is kept as a failed revision, with its results, and refused:\nit is never activated, and no tenant sees a change. A version published never changes: other content under it\nis refused. With `activate=true` the revision is also published, as activating it does\n(`hourctl attend pkg publish <folder> --shared`).",
        "operationId": "attendance_push_shared_package",
        "parameters": [
          {
            "description": "`true` makes it the active revision of its line at once, as\nactivating it does (for development: push, activate, try). False\nunless given.",
            "example": true,
            "in": "query",
            "name": "activate",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "effective": "2026-11-02",
                "layers": [
                  {
                    "id": "overtime",
                    "locks": [
                      "*"
                    ],
                    "revision": 1,
                    "steps": [
                      {
                        "add": {
                          "id": "daily",
                          "params": {
                            "over": "8h",
                            "to": "overtime",
                            "window": "day"
                          },
                          "uses": "standard/threshold"
                        }
                      }
                    ]
                  }
                ],
                "name": "franchise",
                "scenarios": {
                  "overtime.toml": "description = \"...\""
                },
                "version": "2.1.0"
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "held": [],
                  "new": true,
                  "published": {
                    "by": "builder",
                    "description": "The franchise's pay rules.",
                    "effective": "2026-11-02",
                    "layers": [
                      {
                        "id": "overtime",
                        "locks": [
                          "*"
                        ],
                        "order": 10,
                        "revision": 1,
                        "settings": {},
                        "steps": [
                          {
                            "add": {
                              "id": "daily",
                              "params": {
                                "over": "8h",
                                "to": "overtime",
                                "window": "day"
                              },
                              "uses": "standard/threshold"
                            }
                          }
                        ]
                      }
                    ],
                    "name": "franchise",
                    "results": [
                      {
                        "passed": true,
                        "scenario": "overtime.toml"
                      }
                    ],
                    "revision": 2,
                    "scenarios": {
                      "overtime.toml": "description = \"...\""
                    },
                    "state": "active",
                    "stored": "2026-10-20T09:00:00Z",
                    "version": "2.1.0"
                  },
                  "updated": [
                    "franchisee-12"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PublishedView"
                }
              }
            },
            "description": "Pushed before: the revision it was."
          },
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "held": [],
                  "new": true,
                  "published": {
                    "by": "builder",
                    "description": "The franchise's pay rules.",
                    "effective": "2026-11-02",
                    "layers": [
                      {
                        "id": "overtime",
                        "locks": [
                          "*"
                        ],
                        "order": 10,
                        "revision": 1,
                        "settings": {},
                        "steps": [
                          {
                            "add": {
                              "id": "daily",
                              "params": {
                                "over": "8h",
                                "to": "overtime",
                                "window": "day"
                              },
                              "uses": "standard/threshold"
                            }
                          }
                        ]
                      }
                    ],
                    "name": "franchise",
                    "results": [
                      {
                        "passed": true,
                        "scenario": "overtime.toml"
                      }
                    ],
                    "revision": 2,
                    "scenarios": {
                      "overtime.toml": "description = \"...\""
                    },
                    "state": "active",
                    "stored": "2026-10-20T09:00:00Z",
                    "version": "2.1.0"
                  },
                  "updated": [
                    "franchisee-12"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PublishedView"
                }
              }
            },
            "description": "Kept as a new revision."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "1 of its scenarios failed, so it is kept as revision 3 (failed) and never activated: overtime.toml: the week starting 2026-10-05: worked 8h, expected 9h"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Refused: not a package (its name, version, a layer, its source or scenarios), or a scenario that fails (the revision is kept as failed)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Other content under a published version; or the name is a tenant's own package's."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Push a shared package",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/packages/shared/{name}": {
      "get": {
        "description": "Every revision of the shared package `name`, a failed one with its results.",
        "operationId": "attendance_shared_package",
        "parameters": [
          {
            "description": "The package's name.",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "by": "builder",
                    "description": "The franchise's pay rules.",
                    "effective": "2026-11-02",
                    "layers": [
                      {
                        "id": "overtime",
                        "locks": [
                          "*"
                        ],
                        "order": 10,
                        "revision": 1,
                        "settings": {},
                        "steps": [
                          {
                            "add": {
                              "id": "daily",
                              "params": {
                                "over": "8h",
                                "to": "overtime",
                                "window": "day"
                              },
                              "uses": "standard/threshold"
                            }
                          }
                        ]
                      }
                    ],
                    "name": "franchise",
                    "results": [
                      {
                        "passed": true,
                        "scenario": "overtime.toml"
                      }
                    ],
                    "revision": 2,
                    "scenarios": {
                      "overtime.toml": "description = \"...\""
                    },
                    "state": "active",
                    "stored": "2026-10-20T09:00:00Z",
                    "version": "2.1.0"
                  }
                ],
                "schema": {
                  "items": {
                    "type": "object"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Its revisions."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No shared package of that name."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Get a shared package",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/packages/shared/{name}/revisions/{revision}/activate": {
      "post": {
        "description": "Activates the revision: its version is published. Every tenant whose adoption admits it (following its major,\nor pinning it or a later version) is worked out again from its effective day; each whose followed version it\nchanges is sent `package.updated`; a tenant pinning an earlier version keeps it. A failed revision is never\nactivated, and a version published as one revision is never published as another.",
        "operationId": "attendance_activate_shared_package",
        "parameters": [
          {
            "description": "The package's name.",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The revision, counted from 1 in the order pushed.",
            "in": "path",
            "name": "revision",
            "required": true,
            "schema": {
              "format": "int32",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "held": [],
                  "new": true,
                  "published": {
                    "by": "builder",
                    "description": "The franchise's pay rules.",
                    "effective": "2026-11-02",
                    "layers": [
                      {
                        "id": "overtime",
                        "locks": [
                          "*"
                        ],
                        "order": 10,
                        "revision": 1,
                        "settings": {},
                        "steps": [
                          {
                            "add": {
                              "id": "daily",
                              "params": {
                                "over": "8h",
                                "to": "overtime",
                                "window": "day"
                              },
                              "uses": "standard/threshold"
                            }
                          }
                        ]
                      }
                    ],
                    "name": "franchise",
                    "results": [
                      {
                        "passed": true,
                        "scenario": "overtime.toml"
                      }
                    ],
                    "revision": 2,
                    "scenarios": {
                      "overtime.toml": "description = \"...\""
                    },
                    "state": "active",
                    "stored": "2026-10-20T09:00:00Z",
                    "version": "2.1.0"
                  },
                  "updated": [
                    "franchisee-12"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PublishedView"
                }
              }
            },
            "description": "Published: the tenants it updated."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The revision failed its scenarios, or its version is published as another."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The package has no such revision."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Publish a revision of a shared package",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/packages/shared/{name}/revisions/{revision}/bundle": {
      "get": {
        "description": "The revision as it was pushed: its name, version, source, layers and scenarios.",
        "operationId": "attendance_shared_package_bundle",
        "parameters": [
          {
            "description": "The package's name.",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The revision.",
            "in": "path",
            "name": "revision",
            "required": true,
            "schema": {
              "format": "int32",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "description": "The franchise's pay rules.",
                  "effective": "2026-11-02",
                  "layers": [
                    {
                      "id": "overtime",
                      "locks": [
                        "*"
                      ],
                      "order": 10,
                      "revision": 1,
                      "settings": {},
                      "steps": [
                        {
                          "add": {
                            "id": "daily",
                            "params": {
                              "over": "8h",
                              "to": "overtime",
                              "window": "day"
                            },
                            "uses": "standard/threshold"
                          }
                        }
                      ]
                    }
                  ],
                  "name": "franchise",
                  "scenarios": {
                    "overtime.toml": "description = \"...\""
                  },
                  "version": "2.1.0"
                },
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "The package as pushed."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The package has no such revision."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Download a revision of a shared package",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/sinks": {
      "get": {
        "description": "The install-level sinks' route, as the tenant route `/api/attendance/tenants/{tenant}/sinks` is a tenant's: an install-level sink is sent every Time and Attendance tenant's events, where a tenant's sink is sent its tenant's own events and those the sources it names post into it.\n\nThe scope's sinks, each with where it sends events and which ones; the signing secret only as `secret_set`.\n`GET .../sinks/status` shows how each one's deliveries are going.",
        "operationId": "attendance_list_sinks_of_install",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "events": [
                      "period.closed",
                      "period.adjusted"
                    ],
                    "id": "payroll",
                    "secret_set": true,
                    "type": "webhook",
                    "url": "https://payroll.example.com/attendance"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SinkView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every sink."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List sinks",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "The install-level sinks' route, as the tenant route `/api/attendance/tenants/{tenant}/sinks` is a tenant's: an install-level sink is sent every Time and Attendance tenant's events, where a tenant's sink is sent its tenant's own events and those the sources it names post into it.\n\nAdds a `webhook` sink that Time and Attendance's events are posted to, as `{\"events\": [...]}`, in order, each batch\nuntil it answers 2xx, signed as Connect's are when it has a `secret` (`x-houradvantage-timestamp`,\n`x-houradvantage-signature`: `v1=` and the hex HMAC-SHA256 of the timestamp, a '.', and the body). A tenant's sink\nis sent the tenant's own events (`period.closed`, `exception.raised`...) and those the systems it names in\n`sources` post into the tenant (`POST .../events`); an install-level sink is sent every tenant's events, and names\nno sources. `events` limits it to those types; empty or absent, it is sent every type. It starts with the events\nstored from now on. Recorded in the audit trail, the secret left out.",
        "operationId": "attendance_create_sink_of_install",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "events": [
                  "period.closed",
                  "period.adjusted"
                ],
                "id": "payroll",
                "secret": "a-long-random-string",
                "type": "webhook",
                "url": "https://payroll.example.com/attendance"
              },
              "schema": {
                "$ref": "#/components/schemas/SinkConfig"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "period.closed",
                    "period.adjusted"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://payroll.example.com/attendance"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "Added: as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "webhook sink 'payroll' needs url"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a sink, or the sink is not valid: an id that is not 1-64 letters, digits, '-' or '_' (or is `status`); a type other than `webhook`; a missing `url`, or one that is not http or https; a `person_id`, `receiver` or `tenant`; `sources` on an install-level sink."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sink 'payroll' already exists"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A sink with that id exists."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Add a sink",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/sinks/status": {
      "get": {
        "description": "The install-level sinks' route, as the tenant route `/api/attendance/tenants/{tenant}/sinks/status` is a tenant's: an install-level sink is sent every Time and Attendance tenant's events, where a tenant's sink is sent its tenant's own events and those the sources it names post into it.\n\nHow each sink is getting on: how many events wait for it, since when, when it last took some, whether it is\nrefusing them and why, and where it is in the events. One sink is delivered to by one instance at a time; this\nreads what that instance has recorded, so any instance running the engine gives the same answer. A sink that\nrefuses is tried again until it takes the events, however long that takes: nothing is skipped unless you move it\n(`POST .../sinks/{id}/position`).",
        "operationId": "attendance_sink_status_of_install",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "behind": 3,
                    "delivered_at": "2026-10-18T05:00:01Z",
                    "dropped": null,
                    "error": null,
                    "failing_since": null,
                    "oldest_waiting_at": "2026-10-19T05:00:00Z",
                    "position": 1205,
                    "sink": "payroll"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SinkStatus"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every sink whose state could be read."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List sink deliveries",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/sinks/{id}": {
      "delete": {
        "description": "The install-level sinks' route, as the tenant route `/api/attendance/tenants/{tenant}/sinks/{id}` is a tenant's: an install-level sink is sent every Time and Attendance tenant's events, where a tenant's sink is sent its tenant's own events and those the sources it names post into it.\n\nRemoves a sink: nothing more is sent to it, and its place in the events goes with it: a sink made again with its\nid starts as a new sink does. Recorded in the audit trail.",
        "operationId": "attendance_delete_sink_of_install",
        "parameters": [
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "period.closed",
                    "period.adjusted"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://payroll.example.com/attendance"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "Removed: as it was."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Remove a sink",
        "tags": [
          "attendance"
        ]
      },
      "get": {
        "description": "The install-level sinks' route, as the tenant route `/api/attendance/tenants/{tenant}/sinks/{id}` is a tenant's: an install-level sink is sent every Time and Attendance tenant's events, where a tenant's sink is sent its tenant's own events and those the sources it names post into it.\n\nOne sink, the secret shown only as `secret_set`.",
        "operationId": "attendance_show_sink_of_install",
        "parameters": [
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "period.closed",
                    "period.adjusted"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://payroll.example.com/attendance"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "The sink."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Get a sink",
        "tags": [
          "attendance"
        ]
      },
      "patch": {
        "description": "The install-level sinks' route, as the tenant route `/api/attendance/tenants/{tenant}/sinks/{id}` is a tenant's: an install-level sink is sent every Time and Attendance tenant's events, where a tenant's sink is sent its tenant's own events and those the sources it names post into it.\n\nChanges a sink's settings: only the fields given change (a JSON merge patch); `secret` set to null stops signing.\nIts deliveries go on with the new settings from where it is in the events; a batch under way may be sent again.\nRecorded in the audit trail, the secret left out.",
        "operationId": "attendance_update_sink_of_install",
        "parameters": [
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "events": [
                  "period.closed"
                ]
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "period.closed",
                    "period.adjusted"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://payroll.example.com/attendance"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "Changed: as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sink 'payroll': url must be http or https"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a JSON object, it changes the id, or the sink is not valid once patched."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Change a sink",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/sinks/{id}/position": {
      "post": {
        "description": "The install-level sinks' route, as the tenant route `/api/attendance/tenants/{tenant}/sinks/{id}/position` is a tenant's: an install-level sink is sent every Time and Attendance tenant's events, where a tenant's sink is sent its tenant's own events and those the sources it names post into it.\n\nMoves a sink along Time and Attendance's events by hand: ahead, to skip what it refuses or no longer wants, or\nback, to have it sent events again. `{\"seq\": n}` makes the next event it is sent the first after `n`; `{\"seq\":\n\"latest\"}` skips every event stored so far. Sequence numbers are those of Time and Attendance's own events (`GET\n/api/attendance/tenants/{tenant}/events`), not Connect's. Recorded in the audit trail, and told to the log's sinks\nwith a `sink.moved` event: moving a sink ahead is the only way it loses events it has not taken.",
        "operationId": "attendance_move_sink_of_install",
        "parameters": [
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "seq": "latest"
              },
              "schema": {
                "$ref": "#/components/schemas/PositionBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "from": 1180,
                  "sink": "payroll",
                  "to": 1205
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkMovedView"
                }
              }
            },
            "description": "Moved: from where to where."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no event 5000 yet: the newest is 4181"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`seq` is neither a sequence number of 0 or more nor \"latest\", or it is past the newest event."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Move a sink",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants": {
      "get": {
        "description": "Every tenant of the install, by id: the customers Time and Attendance keeps time for.",
        "operationId": "attendance_tenants",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "created": "2026-10-01T14:00:00Z",
                    "external_ids": {
                      "payroll": "C-1042"
                    },
                    "id": "acme",
                    "metadata": {},
                    "name": "Acme Staffing",
                    "status": "active",
                    "updated": "2026-10-01T14:00:00Z"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/TenantView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The tenants."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List the tenants",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Creates a tenant: a customer (a company, a group of companies, a staffing agency) whose time is kept apart from\nevery other's, with one employer of its id and name (`.../employers` makes more). A sink\nthat names it and was refused while it did not exist delivers the punches that waited at once. 409 if one of its\nid exists.",
        "operationId": "attendance_create_tenant",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "external_ids": {
                  "payroll": "C-1042"
                },
                "id": "acme",
                "metadata": {
                  "contract": {
                    "long_day": "10h"
                  }
                },
                "name": "Acme Staffing"
              },
              "schema": {
                "$ref": "#/components/schemas/NewTenant"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-01T14:00:00Z",
                  "external_ids": {
                    "payroll": "C-1042"
                  },
                  "id": "acme",
                  "metadata": {
                    "contract": {
                      "long_day": "10h"
                    }
                  },
                  "name": "Acme Staffing",
                  "status": "active",
                  "updated": "2026-10-01T14:00:00Z"
                },
                "schema": {
                  "$ref": "#/components/schemas/TenantView"
                }
              }
            },
            "description": "Created."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a tenant: its id, name or metadata."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A tenant of its id exists."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Create a tenant",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}": {
      "delete": {
        "description": "Deletes the tenant and everything kept of it: facts, setup, layers, packages, ledgers, exceptions, exports, sinks.\nEvery token scoped to it (`attend:<tenant>`) is revoked, as `DELETE /api/tokens/{name}` revokes one: a tenant made\nagain with the same id is reached by none of them. It cannot be undone; write the tenant out first\n(`GET .../export`) to keep a copy.",
        "operationId": "attendance_delete_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Delete a tenant",
        "tags": [
          "attendance"
        ]
      },
      "get": {
        "description": "The tenant: its name, its ids in other systems, its metadata (which policies read) and whether it is active or\nsuspended.",
        "operationId": "attendance_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-01T14:00:00Z",
                  "external_ids": {
                    "payroll": "C-1042"
                  },
                  "id": "acme",
                  "metadata": {
                    "contract": {
                      "long_day": "10h"
                    }
                  },
                  "name": "Acme Staffing",
                  "status": "active",
                  "updated": "2026-10-01T14:00:00Z"
                },
                "schema": {
                  "$ref": "#/components/schemas/TenantView"
                }
              }
            },
            "description": "The tenant."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read a tenant",
        "tags": [
          "attendance"
        ]
      },
      "patch": {
        "description": "Changes a tenant's name, external ids or metadata (each given in place of what it was; the rest kept). Changed\nmetadata has everyone of the tenant worked out again, as bulk work: policies read it.",
        "operationId": "attendance_update_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "metadata": {
                  "contract": {
                    "long_day": "12h"
                  }
                }
              },
              "schema": {
                "$ref": "#/components/schemas/TenantChange"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-01T14:00:00Z",
                  "external_ids": {
                    "payroll": "C-1042"
                  },
                  "id": "acme",
                  "metadata": {
                    "contract": {
                      "long_day": "10h"
                    }
                  },
                  "name": "Acme Staffing",
                  "status": "active",
                  "updated": "2026-10-01T14:00:00Z"
                },
                "schema": {
                  "$ref": "#/components/schemas/TenantView"
                }
              }
            },
            "description": "The tenant as it now is."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a tenant then: its name or metadata."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Change a tenant",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/clocks": {
      "get": {
        "description": "The tenant's clock records, by device id. A record is what Time and Attendance knows of a device punches are made\non: where it hangs, its labels, and the work values it gives a punch where the person keyed none. It is the\ncurrent state only.",
        "operationId": "attendance_clocks",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "created": "2026-10-08T10:00:00Z",
                    "external_ids": {},
                    "id": "Z34ACMEN00118",
                    "labels": {
                      "floor": "2",
                      "lunch_keys": "no"
                    },
                    "location": "fresno",
                    "metadata": {},
                    "name": "Dock door",
                    "values": {
                      "site": "dock"
                    }
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/ClockView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Its clocks."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No tenant of that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List the clocks",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Makes a clock record: from then on, the punches that arrive from the device take its location, labels and\nvalues. The punches already stored keep what they have. 409 if one of its id exists; 400 for a location the\ntenant does not have.",
        "operationId": "attendance_make_clock",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "id": "Z34ACMEN00118",
                "labels": {
                  "lunch_keys": "no"
                },
                "location": "fresno",
                "name": "Dock door"
              },
              "schema": {
                "$ref": "#/components/schemas/ClockBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-08T10:00:00Z",
                  "external_ids": {},
                  "id": "Z34ACMEN00118",
                  "labels": {
                    "floor": "2",
                    "lunch_keys": "no"
                  },
                  "location": "fresno",
                  "metadata": {},
                  "name": "Dock door",
                  "values": {
                    "site": "dock"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ClockView"
                }
              }
            },
            "description": "Made."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a clock: its id, name, location, values, labels or metadata."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "One of its id exists, or the tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Make a clock record",
        "tags": [
          "attendance"
        ]
      },
      "put": {
        "description": "Gives each of the list as a whole clock record: made if it is new, changed if its id exists (each as given, not\nmerged). All or none: one that is not a clock, or names a location the tenant does not have, refuses the whole\nlist. For a tenant's clocks entered at once.",
        "operationId": "attendance_put_clocks",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": [
                {
                  "id": "Z34ACMEN00118",
                  "labels": {
                    "lunch_keys": "no"
                  },
                  "location": "fresno",
                  "name": "Dock door"
                },
                {
                  "id": "BLEUN00021",
                  "location": "fresno",
                  "name": "Lobby"
                }
              ],
              "schema": {
                "items": {
                  "$ref": "#/components/schemas/ClockBody"
                },
                "type": "array"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "created": "2026-10-08T10:00:00Z",
                    "external_ids": {},
                    "id": "Z34ACMEN00118",
                    "labels": {
                      "floor": "2",
                      "lunch_keys": "no"
                    },
                    "location": "fresno",
                    "metadata": {},
                    "name": "Dock door",
                    "values": {
                      "site": "dock"
                    }
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/ClockView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The clocks as they are now."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "One is not a clock, or has no id, or names no location the tenant has, or an id twice."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Make or change clock records",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/clocks/{id}": {
      "delete": {
        "description": "Removes a clock record. The punches already stored keep their stamps; those that arrive from the device after\nit have none, as from a device that was never entered.",
        "operationId": "attendance_delete_clock",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The clock's device id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant or clock."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Delete a clock record",
        "tags": [
          "attendance"
        ]
      },
      "get": {
        "description": "One of the tenant's clock records.",
        "operationId": "attendance_clock",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The clock's device id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-08T10:00:00Z",
                  "external_ids": {},
                  "id": "Z34ACMEN00118",
                  "labels": {
                    "floor": "2",
                    "lunch_keys": "no"
                  },
                  "location": "fresno",
                  "metadata": {},
                  "name": "Dock door",
                  "values": {
                    "site": "dock"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ClockView"
                }
              }
            },
            "description": "The clock."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant or clock."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read a clock record",
        "tags": [
          "attendance"
        ]
      },
      "patch": {
        "description": "Changes a clock's name, location, values, labels, external ids or metadata (each given in place of what it\nwas). The punches that arrive from now on take the new record; the punches stored keep what they have, and\nnobody is worked out again.",
        "operationId": "attendance_change_clock",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The clock's device id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "labels": {
                  "lunch_keys": "yes"
                }
              },
              "schema": {
                "$ref": "#/components/schemas/ClockBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-08T10:00:00Z",
                  "external_ids": {},
                  "id": "Z34ACMEN00118",
                  "labels": {
                    "floor": "2",
                    "lunch_keys": "no"
                  },
                  "location": "fresno",
                  "metadata": {},
                  "name": "Dock door",
                  "values": {
                    "site": "dock"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/ClockView"
                }
              }
            },
            "description": "The clock as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a clock then, or another id given."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant or clock."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Change a clock record",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/clocks/{id}/restamp": {
      "get": {
        "description": "What re-stamping the clock's punches from `from` would do, changing nothing: how many of its punches from then\non do not carry the clock's record as it is now, and whose they are.",
        "operationId": "attendance_restamp_preview",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The clock's device id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The first instant: a time (RFC 3339), or a date, the start of that day in the zone of the clock's location\n(a clock with no location takes a time only).",
            "in": "query",
            "name": "from",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "clock": "Z34ACMEN00118",
                  "complete": true,
                  "first": "2026-10-05T11:58:02Z",
                  "from": "2026-10-05T00:00:00Z",
                  "last": "2026-10-09T21:04:40Z",
                  "looked_at": 340,
                  "people": 41,
                  "preview": true,
                  "restamped": 312
                },
                "schema": {
                  "$ref": "#/components/schemas/RestampView"
                }
              }
            },
            "description": "What it would do."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a date or time."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant or clock."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Preview a re-stamp",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Gives the clock's punches from `from` on the clock's record as it is now: its location, labels and values. A\npunch is never changed: each one that does not carry the record already gets a correction saying so, by whom and\nwhy, so the stamp it came with and every stamp since stay in the log. Those persons are worked out again from the\npunch's workday, an audit entry is written and a `clock.restamped` event is sent. Punches that carry the record\nalready are left alone, so asking again changes nothing. One run re-stamps at most 20000 punches: if `complete`\nis false, call again with the same `from` for the rest (safe: punches that carry the record are left alone). Use the preview first to see what it would do.",
        "operationId": "attendance_restamp",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The clock's device id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "from": "2026-10-05",
                "reason": "the clock moved to the dock"
              },
              "schema": {
                "$ref": "#/components/schemas/RestampBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "clock": "Z34ACMEN00118",
                  "complete": true,
                  "first": "2026-10-05T11:58:02Z",
                  "from": "2026-10-05T00:00:00Z",
                  "id": "3f9a1c0b7d2e",
                  "last": "2026-10-09T21:04:40Z",
                  "looked_at": 340,
                  "people": 41,
                  "preview": false,
                  "restamped": 312
                },
                "schema": {
                  "$ref": "#/components/schemas/RestampView"
                }
              }
            },
            "description": "What it did."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a date or time."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant or clock."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Re-stamp a clock's punches",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/clocks/{id}/shift": {
      "get": {
        "description": "What shifting the clock's punches made from `from` up to `to` would do, changing nothing: how many of them would\nbe moved by `by_seconds` (or put back by `undo`), and whose they are.",
        "operationId": "attendance_shift_preview",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The clock's device id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The first instant: a time (RFC 3339), or a date (see the request's `from`).",
            "in": "query",
            "name": "from",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The end of the range, not included.",
            "in": "query",
            "name": "to",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "By how many seconds to move each punch. Give this or `undo`.",
            "in": "query",
            "name": "by_seconds",
            "required": false,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "description": "The id of a shift to take back. Give this or `by_seconds`.",
            "in": "query",
            "name": "undo",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "by_seconds": 3600,
                  "clock": "Z34ACMEN00118",
                  "complete": true,
                  "done_before": 0,
                  "first": "2026-03-09T11:58:02Z",
                  "from": "2026-03-09T00:00:00Z",
                  "last": "2026-03-13T21:04:40Z",
                  "left": 9,
                  "looked_at": 340,
                  "people": 41,
                  "preview": true,
                  "shifted": 331,
                  "to": "2026-03-14T00:00:00Z"
                },
                "schema": {
                  "$ref": "#/components/schemas/ClockShiftView"
                }
              }
            },
            "description": "What it would do."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a date or time, an empty range, or not one of by_seconds and undo."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Preview a shift of a clock's punches",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Moves the clock's punches made from `from` up to `to` by `by_seconds`: for a clock that was wrong for a stretch\n(a clock that kept standard time through daylight saving is an hour behind). A punch is never changed: each one\ngets a correction that moves it, saying by whom and why, so the punch as it came and every move stay in the log.\nThose persons are worked out again from the punch's workday, an audit entry is written and a `clock.shifted` event\nis sent. A punch another correction has moved already, or voided, is left as it is (`left`), and asking again with the\nsame `id` changes nothing it did (`done_before`). `undo` takes back the shift of another request: each punch it moved goes to the instant it\nwas made. One run moves at most 20000 punches: if `complete` is false, call again with the same body and `id` for\nthe rest. Use the preview first to see what it would do.",
        "operationId": "attendance_shift",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The clock's device id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "by_seconds": 3600,
                "from": "2026-03-09",
                "id": "dst-spring",
                "reason": "the clock kept standard time",
                "to": "2026-03-14"
              },
              "schema": {
                "$ref": "#/components/schemas/ClockShiftBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "by_seconds": 3600,
                  "clock": "Z34ACMEN00118",
                  "complete": true,
                  "done_before": 0,
                  "first": "2026-03-09T11:58:02Z",
                  "from": "2026-03-09T00:00:00Z",
                  "id": "dst-spring",
                  "last": "2026-03-13T21:04:40Z",
                  "left": 9,
                  "looked_at": 340,
                  "people": 41,
                  "preview": false,
                  "shifted": 331,
                  "to": "2026-03-14T00:00:00Z"
                },
                "schema": {
                  "$ref": "#/components/schemas/ClockShiftView"
                }
              }
            },
            "description": "What it did."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a date or time, an empty range, a bad id, or not one of by_seconds and undo."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Shift a clock's punches",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/days": {
      "get": {
        "description": "Each person's days from `from` through `to` (at most 366 days), as a person's days read has them, a page of people\nat a time, by person: everyone with facts, or with `under` those in that organization or one under it on `on` (`to`\nwithout it). With `detail=totals`, each person's totals and pay periods only, without the days. A person who cannot\nbe read (no zone set up) says why in `error`, and the others are read.",
        "operationId": "attendance_days",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The first day: YYYY-MM-DD; at most 366 days in all.",
            "example": "2026-10-01",
            "in": "query",
            "name": "from",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The last day: YYYY-MM-DD, on or after `from`.",
            "example": "2026-10-31",
            "in": "query",
            "name": "to",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "pay (the default) or a bill side.",
            "example": "pay",
            "in": "query",
            "name": "side",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "days (the default): each person's days, totals and periods; totals:\ntheir totals and periods only.",
            "example": "totals",
            "in": "query",
            "name": "detail",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only those in this organization, or one under it: hierarchy:organization.",
            "example": "management:ops-west",
            "in": "query",
            "name": "under",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The day `under` is asked of: YYYY-MM-DD; `to` without it.",
            "example": "2026-10-31",
            "in": "query",
            "name": "on",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Carry on after this person: the previous page's `next`.",
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "At most this many people: 100 unless given, at most 100.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "from": "2026-10-05",
                  "next": null,
                  "people": [
                    {
                      "periods": [
                        {
                          "approved": false,
                          "closed": null,
                          "first": "2026-10-05",
                          "in_range": {
                            "categories": [
                              {
                                "category": "work",
                                "hours": "40.00",
                                "paid": true,
                                "time": "40h",
                                "worked": true
                              }
                            ],
                            "paid": "40.00",
                            "quantities": [],
                            "worked": "40h"
                          },
                          "kept": true,
                          "last": "2026-10-18",
                          "pending": false,
                          "totals": {
                            "categories": [
                              {
                                "category": "work",
                                "hours": "80.00",
                                "paid": true,
                                "time": "80h",
                                "worked": true
                              }
                            ],
                            "paid": "80.00",
                            "quantities": [],
                            "worked": "80h"
                          }
                        }
                      ],
                      "person": "104552",
                      "totals": {
                        "categories": [
                          {
                            "category": "work",
                            "hours": "40.00",
                            "paid": true,
                            "time": "40h",
                            "worked": true
                          }
                        ],
                        "paid": "40.00",
                        "quantities": [],
                        "worked": "40h"
                      }
                    }
                  ],
                  "side": "pay",
                  "to": "2026-10-11"
                },
                "schema": {
                  "$ref": "#/components/schemas/DaysPage"
                }
              }
            },
            "description": "A page of them."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "from after to, more than 366 days, a detail that is not days or totals, or an under that is not hierarchy:organization."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No tenant of that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read people's days",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/deliveries": {
      "post": {
        "description": "Takes a batch of events exactly as a Connect webhook sink posts it (`{\"events\": [...]}`, the event contract), and\nrecords the punches in it as the tenant's facts; other events are passed over. Every event's id makes its punch's:\na batch delivered again records nothing twice.\n\nIt takes no login and no API token: only a signature by one of the tenant's delivery keys, as a webhook sink signs\nwith its `secret`. `x-houradvantage-timestamp` is the Unix time in seconds; `x-houradvantage-signature` is\n`v1=<hex>`, the HMAC-SHA256, keyed with the delivery key, of the timestamp, a `.`, and the body as sent (several\n`v1=` signatures may be given, separated by commas or spaces). A timestamp more than 5 minutes from this server's\nclock, either way, is refused. Each refusal says why in `error`, so a sender's status shows it. A tenant that does\nnot exist is answered as a signature by none of its keys is (401), so nothing about which tenants exist is told\nbefore a key is proven; once one is, a suspended tenant is answered 409.\n\nA sender (a client address, as device listeners read it behind `trusted_proxies`, an IPv6 one by its /64) whose\ndeliveries, to any tenants, have failed their signature check 10 times lately is answered 429 for its next\ndelivery, before the body is read, until a failure is forgiven every 10 seconds. A sender behind a proxy\n`trusted_proxies` does not name is its address. At most 8 deliveries have their body read at once before their\nsignature is checked: a ninth is answered 503 with `Retry-After`, and is to be sent again.",
        "operationId": "attendance_deliver",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "When it was signed: Unix seconds.",
            "example": "1791403200",
            "in": "header",
            "name": "x-houradvantage-timestamp",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "`v1=` and the HMAC-SHA256 of `<timestamp>.<body>`, hex, keyed with a delivery key.",
            "example": "v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd",
            "in": "header",
            "name": "x-houradvantage-signature",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "events": [
                  {
                    "data": {
                      "state_name": "check_in",
                      "time": "2026-10-07T08:00:00-05:00",
                      "user_id": "1001"
                    },
                    "device": "CG1",
                    "endpoint": "office",
                    "id": "bfd9ac4682c0d0c9b901bb6c4189f75c",
                    "package": "zk-push@3.4.0",
                    "received_at": "2026-10-07T13:00:02Z",
                    "schema": 3,
                    "tenant": "dealer-north",
                    "type": "punch"
                  }
                ]
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "punches": 1
                },
                "schema": {
                  "$ref": "#/components/schemas/Delivered"
                }
              }
            },
            "description": "Taken: how many of its punches were readable and taken in."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a batch of events."
          },
          "401": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the signature matches none of tenant 'acme''s delivery keys (wrong, or revoked)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No signature, a stale timestamp, or a signature by none of the tenant's keys; and for a tenant that does not exist, the same answer as for a wrong key."
          },
          "408": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body stopped arriving (nothing for 10 seconds) or had not all arrived in 60 seconds: deliver again."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "tenant 'acme' is suspended"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended: deliver again once it is resumed."
          },
          "413": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Larger than 16 MiB."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many deliveries from this sender failed their signature check lately: deliver again later."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here, its database cannot be used right now, or too many deliveries are being read at once: deliver again shortly."
          }
        },
        "security": [
          {
            "signature": []
          }
        ],
        "summary": "Deliver punches",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/delivery-keys": {
      "get": {
        "description": "The keys the tenant issued to whoever delivers punches into it, oldest first, those revoked included (`revoked`,\nwith when and by whom): each one's id, label, who issued it and when, and when it last delivered. Their secrets\nare never shown.",
        "operationId": "attendance_delivery_keys",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "created": "2026-10-07T14:00:00Z",
                    "created_by": "admin",
                    "id": "3f9a0c21d4e8",
                    "label": "dealer-north connect",
                    "last_used": "2026-10-07T14:05:12Z",
                    "revoked": false,
                    "revoked_at": null,
                    "revoked_by": null
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/DeliveryKeyView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The keys."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List a tenant's delivery keys",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Issues a key to whoever is to deliver punches into the tenant: a Connect sink of this install (any of its tenants,\nor the install's), another install's, or any other system. It delivers and does nothing else. The answer carries\nthe secret once: give it to the sender, as its sink's `secret`, and keep no other copy; it cannot be shown again.\nThe tenant takes every key it issued until each is revoked: issue a new one, move the sender to it, then revoke\nthe old one. Recorded in the audit trail, the secret never.",
        "operationId": "attendance_issue_delivery_key",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "label": "dealer-north connect"
              },
              "schema": {
                "$ref": "#/components/schemas/NewDeliveryKey"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-07T14:00:00Z",
                  "created_by": "admin",
                  "id": "3f9a0c21d4e8",
                  "label": "dealer-north connect",
                  "last_used": null,
                  "revoked": false,
                  "revoked_at": null,
                  "revoked_by": null,
                  "secret": "hadk_Q2xvY2tFWEFNUExFb25seUVYQU1QTEVvbmx5RVhB"
                },
                "schema": {
                  "$ref": "#/components/schemas/IssuedDeliveryKey"
                }
              }
            },
            "description": "Issued: the key, and its secret this once."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The label is longer than 200 characters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended: resume it to issue a key."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Issue a delivery key",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/delivery-keys/{id}": {
      "delete": {
        "description": "Revokes the key: every instance refuses it from the next delivery (each delivery reads the tenant's keys anew). A\nConnect sink still carrying it falls behind, its status saying why, until it is given another of the tenant's\nkeys. The key stays in the list, flagged `revoked`, with when and by whom. Recorded in the audit trail, naming the\nkey, its label, who issued it and when it last delivered.",
        "operationId": "attendance_revoke_delivery_key",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The key's id.",
            "example": "3f9a0c21d4e8",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "204": {
            "description": "Revoked. No body."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant, or it has no key of that id in use (none was issued, or it is revoked already)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Revoke a delivery key",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/employers": {
      "get": {
        "description": "The tenant's employers, the first made first: the legal entities its people are employees of. A tenant is made\nwith one, of its own id and name.",
        "operationId": "attendance_employers",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "created": "2026-10-01T14:00:00Z",
                    "external_ids": {
                      "ein": "12-3456789"
                    },
                    "id": "acme",
                    "name": "Acme Staffing"
                  },
                  {
                    "created": "2026-10-02T09:30:00Z",
                    "external_ids": {
                      "business_number": "123456789RC0001"
                    },
                    "id": "acme-ca",
                    "name": "Acme Staffing Canada"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/EmployerView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Its employers."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No tenant of that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List the employers",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Makes an employer of the tenant, with its ids in other systems. 409 if one of its id exists.",
        "operationId": "attendance_make_employer",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "external_ids": {
                  "paye": "123/AB456"
                },
                "id": "acme-uk",
                "name": "Acme Staffing UK"
              },
              "schema": {
                "$ref": "#/components/schemas/EmployerBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-08T10:00:00Z",
                  "external_ids": {
                    "paye": "123/AB456"
                  },
                  "id": "acme-uk",
                  "name": "Acme Staffing UK"
                },
                "schema": {
                  "$ref": "#/components/schemas/EmployerView"
                }
              }
            },
            "description": "Made."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not an employer: its id or name."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "One of its id exists, or the tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Make an employer",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/employers/{id}": {
      "get": {
        "description": "One of the tenant's employers: its name and its ids in other systems.",
        "operationId": "attendance_employer",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The employer's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-01T14:00:00Z",
                  "external_ids": {
                    "ein": "12-3456789"
                  },
                  "id": "acme",
                  "name": "Acme Staffing"
                },
                "schema": {
                  "$ref": "#/components/schemas/EmployerView"
                }
              }
            },
            "description": "The employer."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant or employer."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read an employer",
        "tags": [
          "attendance"
        ]
      },
      "patch": {
        "description": "Changes an employer's name or its ids in other systems (each given in place of what it was). Its id never\nchanges, nor whose employer it is.",
        "operationId": "attendance_change_employer",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The employer's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "external_ids": {
                  "adp": "XYZ",
                  "ein": "12-3456789"
                }
              },
              "schema": {
                "$ref": "#/components/schemas/EmployerBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-01T14:00:00Z",
                  "external_ids": {
                    "adp": "XYZ",
                    "ein": "12-3456789"
                  },
                  "id": "acme",
                  "name": "Acme Staffing"
                },
                "schema": {
                  "$ref": "#/components/schemas/EmployerView"
                }
              }
            },
            "description": "The employer as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not an employer then, or another id given."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant or employer."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Change an employer",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/events": {
      "get": {
        "description": "The tenant's events in Time and Attendance's log, oldest first, a page at a time, each with its sequence number\n(`seq`): the engine's own (`endpoint` `attendance`) and those other systems posted into the tenant (`endpoint`\n`source:<source>`). An event is never returned before every event with a lower `seq` is in place, so reading on\nfrom `next` skips nothing. They are kept for the install's `retention_days` once every sink they go to has taken\nthem, and until it does while one has not.",
        "operationId": "attendance_events",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only events after the one with this sequence number: the `next` of\nthe page before. Default 0, from the oldest kept.",
            "example": 1180,
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "description": "At most this many events: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "description": "Only events of this type.",
            "example": "period.closed",
            "in": "query",
            "name": "type",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only the events this source posted (`erp`), or the engine's own\n(`attendance`).",
            "example": "erp",
            "in": "query",
            "name": "source",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only events received at or after this time (RFC 3339).",
            "example": "2026-10-19T00:00:00Z",
            "in": "query",
            "name": "since",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "Only events received before this time (RFC 3339).",
            "example": "2026-10-20T00:00:00Z",
            "in": "query",
            "name": "until",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    {
                      "data": {
                        "person": "104552",
                        "side": "pay",
                        "tenant": "acme"
                      },
                      "device": "104552/pay/2026-10-05",
                      "endpoint": "attendance",
                      "id": "9c1e7b6d4a0f8e5c2b1a9d8c7e6f3f2a",
                      "package": "houradvantage-attend",
                      "received_at": "2026-10-19T05:00:00Z",
                      "schema": 3,
                      "seq": 1205,
                      "tenant": "acme",
                      "type": "period.closed"
                    }
                  ],
                  "next": 1205
                },
                "schema": {
                  "$ref": "#/components/schemas/EventsPage"
                }
              }
            },
            "description": "A page of events, oldest first."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`until` is not later than `since`, or `source` is not an id."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "no tenant 'acme'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List a tenant's events",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Events another system sends into the tenant (an HR system, a scheduling app, another install): kept in Time and\nAttendance's log as the tenant's, and sent to the tenant's sinks that name their `source` in their `sources`, and\nto the install-level sinks. Each names its `source` and carries an `id` its source gives no other event: posted\nagain with the same source and id (a retry), it is taken once, and the answer lists it among the `duplicates`.\nA post holds 1 to 100 events, each with at most 16 KiB of `data`, and is kept all together or not at all: one\nevent that is not as asked refuses the whole post, saying which. Kept, an event is in the standard envelope: its\n`endpoint` is `source:<source>`, its `package` the source, its `device` what it is about. A suspended tenant\ntakes none (409). Posts are not recorded in the audit trail: they are data, not changes to the setup.",
        "operationId": "attendance_post_events",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "events": [
                  {
                    "data": {
                      "person": "104552",
                      "start": "2026-10-12"
                    },
                    "device": "104552",
                    "id": "hr-hire-20391",
                    "source": "hr",
                    "type": "employee.hired"
                  }
                ]
              },
              "schema": {
                "$ref": "#/components/schemas/PostedEvents"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "duplicates": [],
                  "stored": [
                    "hr-hire-20391"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PostedView"
                }
              }
            },
            "description": "Kept: the ids stored, and those posted before."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "event 0: its data is 20480 bytes as JSON: at most 16384"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The post is not as asked: no events or more than 100, or an event whose id, source, type or device is not as described (the sources `connect` and `attendance` are Connect's and Time and Attendance's own), or whose data is over 16 KiB."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here, or the database cannot be used right now: post it again."
          }
        },
        "summary": "Post events into a tenant",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/exceptions": {
      "get": {
        "description": "The exceptions of everyone's ledgers as last worked out, by time, then person: by default those someone still has\nto deal with (open, or acknowledged and not yet put right or excused). An exception goes from the list by itself\nonce the facts are put right (a correction, a punch that arrived), or when someone excuses it. To read on, pass\nthe answer's `next` as `after`.",
        "operationId": "attendance_exceptions",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only those in these states, comma separated: open, acknowledged,\nexcused. Default: open and acknowledged (those someone still has to\ndeal with).",
            "example": "open,acknowledged",
            "in": "query",
            "name": "state",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only this person's.",
            "example": "104552",
            "in": "query",
            "name": "person",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only exceptions of this kind.",
            "example": "missing_out",
            "in": "query",
            "name": "exception",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only those about something at or after this instant (RFC 3339).",
            "example": "2026-10-05T00:00:00Z",
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only those about something before this instant (RFC 3339).",
            "example": "2026-10-12T00:00:00Z",
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only unlinked people's (true), or only the others' (false).",
            "in": "query",
            "name": "unlinked",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "description": "Only the exceptions of those in this organization, or one under it:\nhierarchy:organization.",
            "example": "management:ops-west",
            "in": "query",
            "name": "under",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The day `under` is asked of: YYYY-MM-DD; today (UTC) without it.",
            "example": "2026-10-07",
            "in": "query",
            "name": "on",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Carry on after the previous page: its `next`.",
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "At most this many: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "exceptions": [
                    {
                      "about": "9f2d",
                      "at": "2026-10-05T13:00:00Z",
                      "detail": "",
                      "exception": "missing_out",
                      "id": "3f9a0c21d4e8b765",
                      "noted_at": "2026-10-06T14:00:00Z",
                      "noted_by": "lead",
                      "period": "2026-10-05",
                      "person": "104552",
                      "state": "acknowledged"
                    }
                  ],
                  "next": null
                },
                "schema": {
                  "$ref": "#/components/schemas/ExceptionsPage"
                }
              }
            },
            "description": "A page of them."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A state that is none, or an after that is no page's next."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List exceptions to follow up",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/export": {
      "get": {
        "description": "Streams all of the tenant's data as a portable document, as it is read: JSON lines, the tenant first, then each\nsetup revision, layer and package version, each of its sinks (the signing secret only as `secret_set`), each\nperson with every fact about them and the record of each of their closed periods (its ledger as it stood at its\nclose, as paid), each punch that could not be read (the event as it came, why, and when it was stored), each\nexport made, and an end line with how many people and facts it has. Other ledgers are not in it: they are worked\nout again where it is loaded.",
        "operationId": "attendance_export_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/x-ndjson": {
                "example": "{\"tenant\":{\"format\":3,\"tenant\":{\"id\":\"acme\",\"name\":\"Acme Staffing\"}}}\n{\"end\":{\"people\":0,\"facts\":0}}\n",
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The document."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Write a tenant out",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/exports": {
      "get": {
        "description": "The tenant's exports, newest first: by whom, of which period, with which exporter, how many people they\nwrote, and how they ended.",
        "operationId": "attendance_exports",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "At most this many: 100 unless given, at most 1000.",
            "example": 20,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "by": "payroll",
                    "created": "2026-10-12T15:00:00Z",
                    "exporter": "standard/csv",
                    "finished": "2026-10-12T15:00:04Z",
                    "id": "6f1c2e0a-5b7d-4c3e-9a8f-0d1e2f3a4b5c",
                    "only": "approved",
                    "people": 1834,
                    "period": "2026-10-05",
                    "side": "pay",
                    "state": "done"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/ExportView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The exports."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List exports",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Writes the pay period's ledgers, as last worked out, with the exporter named, and streams the file as it is\nwritten: its media type and name are the exporter's (`Content-Disposition`), and `X-Export-Id` names the export.\nAn export is of one employer's people: the one named (`employer`), or the tenant's only one; a tenant with\nseveral names one, or `*` for everyone's.\nRefused (409) while anyone of the tenant waits to have the period worked out, naming them (those whose\nworking out failed wait until it is put right). The export is kept, with which ledger of each person it wrote,\nso whose time changed since can be read; the file is not. An exporter that fails, or keeps something from one\nperson to the next, ends the export failed and the download cut short.",
        "operationId": "attendance_export",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "employer": "acme-us",
                "exporter": "standard/csv",
                "only": "approved",
                "params": {
                  "id_attribute": "payroll_id"
                },
                "period": "2026-10-05"
              },
              "schema": {
                "$ref": "#/components/schemas/NewExport"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "text/csv": {
                "example": "person,first,last,workday,category,hours\nP1,2026-10-05,2026-10-11,2026-10-05,work,8.00\n",
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The file, as the exporter writes it."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such exporter, a whose that is none, no such employer, or no employer named where the tenant has several."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "People of the period wait to be worked out."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Export a pay period",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/exports/{id}": {
      "get": {
        "description": "One export, with the people whose ledger of the period changed since it was written (a late correction, a\npunch that came in after): what the next export, or an adjustment, has to carry.",
        "operationId": "attendance_export_read",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The export's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "by": "payroll",
                  "changed": [
                    "104552"
                  ],
                  "created": "2026-10-12T15:00:00Z",
                  "exporter": "standard/csv",
                  "finished": "2026-10-12T15:00:04Z",
                  "id": "6f1c2e0a-5b7d-4c3e-9a8f-0d1e2f3a4b5c",
                  "only": "approved",
                  "people": 1834,
                  "period": "2026-10-05",
                  "side": "pay",
                  "state": "done"
                },
                "schema": {
                  "$ref": "#/components/schemas/ExportView"
                }
              }
            },
            "description": "The export."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such export."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read an export",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/hierarchies": {
      "get": {
        "description": "The tenant's hierarchies of organizations (cost centers, management, regions), by id: each a tree of its own,\ncutting across employers.",
        "operationId": "attendance_hierarchies",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "created": "2026-10-01T14:00:00Z",
                    "id": "management",
                    "name": "Management"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/HierarchyView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Its hierarchies."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No tenant of that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List the hierarchies",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Makes a hierarchy of the tenant: a tree its organizations are put in. 409 if one of its id exists.",
        "operationId": "attendance_make_hierarchy",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "id": "management",
                "name": "Management"
              },
              "schema": {
                "$ref": "#/components/schemas/HierarchyBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-08T10:00:00Z",
                  "id": "management",
                  "name": "Management"
                },
                "schema": {
                  "$ref": "#/components/schemas/HierarchyView"
                }
              }
            },
            "description": "Made."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a hierarchy: its id or name."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "One of its id exists, or the tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Make a hierarchy",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/hierarchies/{hierarchy}": {
      "patch": {
        "description": "Changes a hierarchy's name. Its id never changes.",
        "operationId": "attendance_change_hierarchy",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The hierarchy's id.",
            "in": "path",
            "name": "hierarchy",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "name": "Line management"
              },
              "schema": {
                "$ref": "#/components/schemas/HierarchyBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-01T14:00:00Z",
                  "id": "management",
                  "name": "Line management"
                },
                "schema": {
                  "$ref": "#/components/schemas/HierarchyView"
                }
              }
            },
            "description": "The hierarchy as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a name, or another id given."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant or hierarchy."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Rename a hierarchy",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/hierarchies/{hierarchy}/organizations": {
      "get": {
        "description": "The organizations of a hierarchy, by id, each with its parents from each day on (its moves).",
        "operationId": "attendance_organizations",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The hierarchy's id.",
            "in": "path",
            "name": "hierarchy",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Carry on after this id: the previous page's `next`.",
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "At most this many: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "next": null,
                  "organizations": [
                    {
                      "created": "2026-10-01T14:00:00Z",
                      "external_ids": {},
                      "hierarchy": "management",
                      "id": "ops-west",
                      "labels": {
                        "level": "team"
                      },
                      "metadata": {},
                      "name": "Operations West",
                      "parents": [
                        {
                          "parent": "ops"
                        },
                        {
                          "from": "2026-10-12",
                          "parent": "west"
                        }
                      ]
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/OrganizationsPage"
                }
              }
            },
            "description": "A page of them."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant or hierarchy."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List a hierarchy's organizations",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Makes an organization of a hierarchy, under `parent` (from the beginning) or a root. 409 if one of its id\nexists in the hierarchy; 400 for a parent the hierarchy does not have.",
        "operationId": "attendance_make_organization",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The hierarchy's id.",
            "in": "path",
            "name": "hierarchy",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "id": "ops-west",
                "labels": {
                  "level": "team"
                },
                "name": "Operations West",
                "parent": "ops"
              },
              "schema": {
                "$ref": "#/components/schemas/OrganizationBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-08T10:00:00Z",
                  "external_ids": {},
                  "hierarchy": "management",
                  "id": "ops-west",
                  "labels": {
                    "level": "team"
                  },
                  "metadata": {},
                  "name": "Operations West",
                  "parents": [
                    {
                      "parent": "ops"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/OrganizationView"
                }
              }
            },
            "description": "Made."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not an organization, or a parent the hierarchy does not have."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant or hierarchy."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "One of its id exists, or the tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Make an organization",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/hierarchies/{hierarchy}/organizations/{id}": {
      "get": {
        "description": "One organization of a hierarchy, with its parents from each day on.",
        "operationId": "attendance_organization",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The hierarchy's id.",
            "in": "path",
            "name": "hierarchy",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The organization's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-08T10:00:00Z",
                  "external_ids": {},
                  "hierarchy": "management",
                  "id": "ops-west",
                  "labels": {
                    "level": "team"
                  },
                  "metadata": {},
                  "name": "Operations West",
                  "parents": [
                    {
                      "parent": "ops"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/OrganizationView"
                }
              }
            },
            "description": "The organization."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant, hierarchy or organization."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read an organization",
        "tags": [
          "attendance"
        ]
      },
      "patch": {
        "description": "Changes an organization's name, external ids, labels or metadata (each given in place of what it was). Its\nparents change only by a move. Everyone ever in it, or under it, is worked out again from now: policies read\nit.",
        "operationId": "attendance_change_organization",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The hierarchy's id.",
            "in": "path",
            "name": "hierarchy",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The organization's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "labels": {
                  "level": "department"
                }
              },
              "schema": {
                "$ref": "#/components/schemas/OrganizationBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-08T10:00:00Z",
                  "external_ids": {},
                  "hierarchy": "management",
                  "id": "ops-west",
                  "labels": {
                    "level": "department"
                  },
                  "metadata": {},
                  "name": "Operations West",
                  "parents": [
                    {
                      "parent": "ops"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/OrganizationView"
                }
              }
            },
            "description": "The organization as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not an organization then, another id given, or a parent (move it)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant, hierarchy or organization."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Change an organization",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/hierarchies/{hierarchy}/organizations/{id}/move": {
      "post": {
        "description": "Puts an organization under another (or makes it a root) from a day, its whole subtree with it; before that\nday it is where it was. Everyone ever in it or under it is worked out again from that day. A move that would\nmake the tree go round, on any day, is refused (409).",
        "operationId": "attendance_move_organization",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The hierarchy's id.",
            "in": "path",
            "name": "hierarchy",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The organization's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "from": "2026-10-12",
                "parent": "west"
              },
              "schema": {
                "$ref": "#/components/schemas/MoveBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-08T10:00:00Z",
                  "external_ids": {},
                  "hierarchy": "management",
                  "id": "ops-west",
                  "labels": {},
                  "metadata": {},
                  "name": "Operations West",
                  "parents": [
                    {
                      "parent": "ops"
                    },
                    {
                      "from": "2026-10-12",
                      "parent": "west"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/OrganizationView"
                }
              }
            },
            "description": "The organization as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A parent the hierarchy does not have."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant, hierarchy or organization."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tree would go round, or the tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Move an organization",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/import": {
      "post": {
        "description": "Reads a tenant's document (as `GET .../export` writes it) into this tenant, a line at a time as it arrives: its\nsetup, layers, packages, every person's facts, its unreadable punches and its exports, each kept with when it was\nstored where the document was written. The document's tenant must be this one: a document of another tenant is refused (400)\nunless `from` names it, a rename said out loud. A tenant of this id that does not exist is created as the document\ndescribes it, suspended until the document's end line has loaded, then with the document's status; one that\nexists must have no data yet, and is suspended while it loads, then has its own status back. A load holds the\ntenant: a second one into it meanwhile is refused (409). Its people are worked out again from their facts, as bulk\nwork (other tenants' punches go first), with no events: what was loaded (closed periods, approved timecards,\nexceptions) was told of where it came from. Its sinks are kept once it has loaded, all checked before any is kept\n(a sink of an id the tenant has already stays as it is); no secret is in the document, so `secrets_to_set` names\nthe sinks loaded that had one, to be set again. A document cut short (no end line) or that does not read is refused,\nsaying where; what was loaded before stays, the tenant suspended. Loading the same document again goes on where it\nstopped: what is stored the same is passed over, what is stored differently is refused (409), naming it.",
        "operationId": "attendance_import_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The document's tenant, when it is loaded into another: a rename.",
            "example": "acme",
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/x-ndjson": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "closed": 5502,
                  "exports": 4,
                  "facts": 120440,
                  "layers": 3,
                  "packages": 1,
                  "people": 1834,
                  "secrets_to_set": [
                    "payroll"
                  ],
                  "setup": 12,
                  "sinks": 1,
                  "unreadable": 2
                },
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "What was loaded."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The document is not one, is cut short, is another tenant's (without `from`), or the tenant has data; or a sink of it is not one (the tenant loaded, none of its sinks)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Another load into the tenant is under way, or one of another document stopped part way; or a line of a load that goes on is stored already, differently."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Load a tenant's document",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/in": {
      "get": {
        "description": "The people at work, on a lunch or on a break now, by person: as their pay ledgers were last worked out, each\nsince the punch that started what they are in, on that punch's device, with the labor context of the work. A\nstretch counts as in until its shift reaches the longest a shift may be that the policy says (its `longest_shift`\nstep); past it, it is taken as an out never punched. With the policy saying none, it is in until a punch or a rule closes it. A person waiting to be worked out again is marked `pending`: a\npunch just recorded shows once it is worked out. With `under`, only those in that organization or one under it\non `on`; with `location`, only those at that work location on `on`.",
        "operationId": "attendance_in_now",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only those in this organization, or one under it: hierarchy:organization.",
            "example": "management:ops-west",
            "in": "query",
            "name": "under",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The day `under` and `location` are asked of: YYYY-MM-DD; today (UTC) without it.",
            "example": "2026-10-07",
            "in": "query",
            "name": "on",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only those at this work location.",
            "example": "reno",
            "in": "query",
            "name": "location",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Carry on after this person: the previous page's `next`.",
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "At most this many: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "as_of": "2026-10-07T17:00:00Z",
                  "in": [
                    {
                      "device": "CG1",
                      "kind": "lunch",
                      "pending": false,
                      "period": "2026-10-05",
                      "person": "104552",
                      "punch": "p-88213",
                      "since": "2026-10-07T16:31:00Z",
                      "until": "2026-10-08T05:02:00Z",
                      "values": {
                        "job": "picking"
                      }
                    }
                  ],
                  "next": null
                },
                "schema": {
                  "$ref": "#/components/schemas/InPage"
                }
              }
            },
            "description": "A page of them."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "An under that is not hierarchy:organization, or a location that is no id."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No tenant of that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List who is in now",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/layers": {
      "get": {
        "description": "Every policy layer of the tenant, in the order kept: each layer's revisions, with the order it applies in, its\neligibility rule (`applies_to`: whom it applies to; absent: everyone), and the settings, steps and locks each\nsets.",
        "operationId": "attendance_layers",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "from": null,
                    "id": "tenant",
                    "locks": [],
                    "order": 0,
                    "revision": 1,
                    "settings": {
                      "pay_periods": {
                        "every_days": 14,
                        "from": "2026-10-05"
                      }
                    },
                    "steps": [],
                    "to": null
                  },
                  {
                    "applies_to": "jurisdiction = us-ca",
                    "from": null,
                    "id": "us-ca",
                    "locks": [
                      "step:daily"
                    ],
                    "order": 10,
                    "revision": 1,
                    "settings": {},
                    "steps": [
                      {
                        "add": {
                          "after": null,
                          "before": null,
                          "id": "daily",
                          "params": {
                            "over": "8h",
                            "to": "overtime",
                            "window": "day"
                          },
                          "uses": "standard/threshold"
                        }
                      }
                    ],
                    "to": null
                  }
                ],
                "schema": {
                  "items": {
                    "type": "object"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every layer."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List the policy layers",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Adds a revision of one of the tenant's layers: its `id` (1 to 64 letters, digits, `-` or `_`), `revision`,\n`order` (the lowest applies first; default 0), `applies_to` (an eligibility rule, a selector over the person on\neach day: `jurisdiction = us-ca`, `under unions:local-42`, `attributes.pay_group = seasonal`; absent: everyone),\nthe days it is in force (`from`, `to`), and the `settings`, `steps` and `locks` it sets. A revision kept never\nchanges: the same again changes nothing, another with its id and revision is refused (409). Those the layer's\nrules (this revision's and its others') can pick are marked to have their ledgers worked out again from the day\nit is in force from; everyone, where a rule picks by what people lack or the layer has none.",
        "operationId": "attendance_add_layer",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "from": "2026-11-01",
                "id": "tenant",
                "locks": [],
                "order": 0,
                "revision": 2,
                "settings": {},
                "steps": [
                  {
                    "add": {
                      "after": null,
                      "before": null,
                      "id": "weekly",
                      "params": {
                        "over": "40h",
                        "to": "overtime",
                        "window": "week"
                      },
                      "uses": "standard/threshold"
                    }
                  }
                ],
                "to": null
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "recorded": [
                    "new"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/RecordedView"
                }
              }
            },
            "description": "Kept, or kept already."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "layer us-ca: rule 'jurisdiction = ': column 16: a value is missing"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a layer: its id, rule, a setting it gives or locks (naming the closest one) or a lock is not one, or it gives a step parameters the step does not take."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "That layer's revision is kept already, and differently; or it changes what an adopted package locks."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Add a policy layer",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/locations": {
      "get": {
        "description": "The tenant's work locations, by id: each with the time zone days there are worked out in and its\njurisdiction.",
        "operationId": "attendance_locations",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "created": "2026-10-01T14:00:00Z",
                    "external_ids": {},
                    "id": "fresno",
                    "jurisdiction": "us-ca",
                    "labels": {
                      "region": "west/california"
                    },
                    "metadata": {},
                    "name": "Fresno DC",
                    "zone": "America/Los_Angeles"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/LocationView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Its locations."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No tenant of that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List the work locations",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Makes a work location of the tenant. 409 if one of its id exists; 400 for a zone that is none.",
        "operationId": "attendance_make_location",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "id": "fresno",
                "jurisdiction": "us-ca",
                "name": "Fresno DC",
                "zone": "America/Los_Angeles"
              },
              "schema": {
                "$ref": "#/components/schemas/LocationBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-08T10:00:00Z",
                  "external_ids": {},
                  "id": "fresno",
                  "jurisdiction": "us-ca",
                  "labels": {},
                  "metadata": {},
                  "name": "Fresno DC",
                  "zone": "America/Los_Angeles"
                },
                "schema": {
                  "$ref": "#/components/schemas/LocationView"
                }
              }
            },
            "description": "Made."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a location: its id, name, zone, jurisdiction, values, labels or metadata."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "One of its id exists, or the tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Make a work location",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/locations/{id}": {
      "get": {
        "description": "One of the tenant's work locations.",
        "operationId": "attendance_location",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The location's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-08T10:00:00Z",
                  "external_ids": {},
                  "id": "fresno",
                  "jurisdiction": "us-ca",
                  "labels": {},
                  "metadata": {},
                  "name": "Fresno DC",
                  "zone": "America/Los_Angeles"
                },
                "schema": {
                  "$ref": "#/components/schemas/LocationView"
                }
              }
            },
            "description": "The location."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant or location."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read a work location",
        "tags": [
          "attendance"
        ]
      },
      "patch": {
        "description": "Changes a location's name, zone, jurisdiction, external ids, labels or metadata (each given in place of what\nit was). Everyone ever at it is worked out again from now: their days are in its zone, and policies read it.",
        "operationId": "attendance_change_location",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The location's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "jurisdiction": "us-ca-fresno"
              },
              "schema": {
                "$ref": "#/components/schemas/LocationBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-08T10:00:00Z",
                  "external_ids": {},
                  "id": "fresno",
                  "jurisdiction": "us-ca-fresno",
                  "labels": {},
                  "metadata": {},
                  "name": "Fresno DC",
                  "zone": "America/Los_Angeles"
                },
                "schema": {
                  "$ref": "#/components/schemas/LocationView"
                }
              }
            },
            "description": "The location as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a location then, or another id given."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant or location."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Change a work location",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/packages": {
      "get": {
        "description": "Every revision of the tenant's own policy packages, by name and revision (the shared ones it adopts are listed\nunder `/api/attendance/packages/shared`).",
        "operationId": "attendance_packages",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "by": "builder",
                    "description": "The franchise's pay rules.",
                    "effective": "2026-11-02",
                    "layers": [
                      {
                        "id": "overtime",
                        "locks": [
                          "*"
                        ],
                        "order": 10,
                        "revision": 1,
                        "settings": {},
                        "steps": [
                          {
                            "add": {
                              "id": "daily",
                              "params": {
                                "over": "8h",
                                "to": "overtime",
                                "window": "day"
                              },
                              "uses": "standard/threshold"
                            }
                          }
                        ]
                      }
                    ],
                    "name": "franchise",
                    "results": [
                      {
                        "passed": true,
                        "scenario": "overtime.toml"
                      }
                    ],
                    "revision": 2,
                    "scenarios": {
                      "overtime.toml": "description = \"...\""
                    },
                    "state": "active",
                    "stored": "2026-10-20T09:00:00Z",
                    "version": "2.1.0"
                  }
                ],
                "schema": {
                  "items": {
                    "type": "object"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every revision."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List the tenant's own packages",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Takes a version of the tenant's own policy package, as a shared one is pushed (its scenarios run here first;\nwith `activate=true` published at once), for this tenant alone: no other tenant sees or adopts it. A package's\nname is the tenant's or the install's, never both. The tenant adopts it as any package\n(`.../packages/adopted/{name}`).",
        "operationId": "attendance_push_package",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "`true` makes it the active revision of its line at once, as\nactivating it does (for development: push, activate, try). False\nunless given.",
            "example": true,
            "in": "query",
            "name": "activate",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "name": "acme",
                "scenarios": {
                  "cap.toml": "description = \"...\""
                },
                "source": "return { cap = { stage = 'allocate', window = 'day', run = function(ctx, p) end } }",
                "version": "1.0.0"
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "held": [],
                  "new": true,
                  "published": {
                    "by": "builder",
                    "description": "The franchise's pay rules.",
                    "effective": "2026-11-02",
                    "layers": [
                      {
                        "id": "overtime",
                        "locks": [
                          "*"
                        ],
                        "order": 10,
                        "revision": 1,
                        "settings": {},
                        "steps": [
                          {
                            "add": {
                              "id": "daily",
                              "params": {
                                "over": "8h",
                                "to": "overtime",
                                "window": "day"
                              },
                              "uses": "standard/threshold"
                            }
                          }
                        ]
                      }
                    ],
                    "name": "franchise",
                    "results": [
                      {
                        "passed": true,
                        "scenario": "overtime.toml"
                      }
                    ],
                    "revision": 2,
                    "scenarios": {
                      "overtime.toml": "description = \"...\""
                    },
                    "state": "active",
                    "stored": "2026-10-20T09:00:00Z",
                    "version": "2.1.0"
                  },
                  "updated": [
                    "franchisee-12"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PublishedView"
                }
              }
            },
            "description": "The tenant pushed it before: its revision."
          },
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "held": [],
                  "new": true,
                  "published": {
                    "by": "builder",
                    "description": "The franchise's pay rules.",
                    "effective": "2026-11-02",
                    "layers": [
                      {
                        "id": "overtime",
                        "locks": [
                          "*"
                        ],
                        "order": 10,
                        "revision": 1,
                        "settings": {},
                        "steps": [
                          {
                            "add": {
                              "id": "daily",
                              "params": {
                                "over": "8h",
                                "to": "overtime",
                                "window": "day"
                              },
                              "uses": "standard/threshold"
                            }
                          }
                        ]
                      }
                    ],
                    "name": "franchise",
                    "results": [
                      {
                        "passed": true,
                        "scenario": "overtime.toml"
                      }
                    ],
                    "revision": 2,
                    "scenarios": {
                      "overtime.toml": "description = \"...\""
                    },
                    "state": "active",
                    "stored": "2026-10-20T09:00:00Z",
                    "version": "2.1.0"
                  },
                  "updated": [
                    "franchisee-12"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PublishedView"
                }
              }
            },
            "description": "Kept as the tenant package's new revision."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Refused: not a package, or a scenario that fails (kept as failed)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Other content under a published version; or the name is a shared package's; or the tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Push one of the tenant's packages",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/packages/adopted": {
      "get": {
        "description": "Each with what the tenant adopted (a major version it follows, or the version it pins), the version that takes\nnow, and the versions in force by it, each from the day it is.",
        "operationId": "attendance_adopted",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "adopted": "2",
                    "follows": true,
                    "name": "franchise",
                    "shared": true,
                    "version": "2.1.0",
                    "versions": [
                      {
                        "from": null,
                        "version": "2.0.0"
                      },
                      {
                        "from": "2026-11-02",
                        "version": "2.1.0"
                      }
                    ]
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/AdoptedView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The tenant's adoptions, by name."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List the packages the tenant adopted",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/packages/adopted/{name}": {
      "delete": {
        "description": "The tenant no longer adopts the package: its layers and steps leave the tenant's policy, and its people are\nworked out again from now. Refused while a layer of the tenant's uses one of its steps.",
        "operationId": "attendance_drop_package",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The package's name.",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "adopted": "2",
                  "follows": true,
                  "name": "franchise",
                  "shared": true,
                  "version": "2.1.0",
                  "versions": [
                    {
                      "from": null,
                      "version": "2.1.0"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/AdoptedView"
                }
              }
            },
            "description": "Dropped: what the tenant had adopted."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the tenant's layer site uses package franchise: it is in use"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A layer of the tenant's uses the package."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant, or the tenant has not adopted it."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Drop a package",
        "tags": [
          "attendance"
        ]
      },
      "put": {
        "description": "Follows a major version of a package (`{\"version\": \"2\"}`), or pins one version (`{\"version\": \"2.3.1\"}`; before\nits effective day the versions before it), in place of what the tenant adopted of it before: the tenant's own\npackage of that name, or else the shared one. Its layers then come before the tenant's own, and its steps run\nas `<name>/<step>`. The tenant's people are worked out again from now. A version that takes nothing published\nis refused, and so is a package that locks what a layer of the tenant's changes.",
        "operationId": "attendance_adopt",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The package's name.",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "version": "2"
              },
              "schema": {
                "$ref": "#/components/schemas/Adopt"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "adopted": "2",
                  "follows": true,
                  "name": "franchise",
                  "shared": true,
                  "version": "2.1.0",
                  "versions": [
                    {
                      "from": null,
                      "version": "2.1.0"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/AdoptedView"
                }
              }
            },
            "description": "Adopted: what it takes now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "version '2.3' is not major.minor.patch"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a major version or a whole version."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No package of that name is published at a version it takes."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A layer of the tenant's changes what the package locks; or the tenant has not set up an accrual category or a measure the package needs (all lacking are listed); or the tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Adopt a package",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/packages/{name}": {
      "get": {
        "description": "Every revision of the tenant's own package `name`.",
        "operationId": "attendance_package",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The package's name.",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "by": "builder",
                    "description": "The franchise's pay rules.",
                    "effective": "2026-11-02",
                    "layers": [
                      {
                        "id": "overtime",
                        "locks": [
                          "*"
                        ],
                        "order": 10,
                        "revision": 1,
                        "settings": {},
                        "steps": [
                          {
                            "add": {
                              "id": "daily",
                              "params": {
                                "over": "8h",
                                "to": "overtime",
                                "window": "day"
                              },
                              "uses": "standard/threshold"
                            }
                          }
                        ]
                      }
                    ],
                    "name": "franchise",
                    "results": [
                      {
                        "passed": true,
                        "scenario": "overtime.toml"
                      }
                    ],
                    "revision": 2,
                    "scenarios": {
                      "overtime.toml": "description = \"...\""
                    },
                    "state": "active",
                    "stored": "2026-10-20T09:00:00Z",
                    "version": "2.1.0"
                  }
                ],
                "schema": {
                  "items": {
                    "type": "object"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Its revisions."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant has no package of that name."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Get one of the tenant's packages",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/packages/{name}/revisions/{revision}/activate": {
      "post": {
        "description": "Publishes the revision's version for the tenant, as a shared one's is: the tenant is worked out again from its\neffective day where its adoption admits it, and told (`package.updated`) when its followed version changes.",
        "operationId": "attendance_activate_package",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The package's name.",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The revision.",
            "in": "path",
            "name": "revision",
            "required": true,
            "schema": {
              "format": "int32",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "held": [],
                  "new": true,
                  "published": {
                    "by": "builder",
                    "description": "The franchise's pay rules.",
                    "effective": "2026-11-02",
                    "layers": [
                      {
                        "id": "overtime",
                        "locks": [
                          "*"
                        ],
                        "order": 10,
                        "revision": 1,
                        "settings": {},
                        "steps": [
                          {
                            "add": {
                              "id": "daily",
                              "params": {
                                "over": "8h",
                                "to": "overtime",
                                "window": "day"
                              },
                              "uses": "standard/threshold"
                            }
                          }
                        ]
                      }
                    ],
                    "name": "franchise",
                    "results": [
                      {
                        "passed": true,
                        "scenario": "overtime.toml"
                      }
                    ],
                    "revision": 2,
                    "scenarios": {
                      "overtime.toml": "description = \"...\""
                    },
                    "state": "active",
                    "stored": "2026-10-20T09:00:00Z",
                    "version": "2.1.0"
                  },
                  "updated": [
                    "franchisee-12"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PublishedView"
                }
              }
            },
            "description": "Published."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The revision failed its scenarios, or its version is published as another."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant, or the package has no such revision."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Activate a revision of the tenant's package",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/packages/{name}/revisions/{revision}/bundle": {
      "get": {
        "description": "The revision as it was pushed.",
        "operationId": "attendance_package_bundle",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The package's name.",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The revision.",
            "in": "path",
            "name": "revision",
            "required": true,
            "schema": {
              "format": "int32",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "description": "The franchise's pay rules.",
                  "effective": "2026-11-02",
                  "layers": [
                    {
                      "id": "overtime",
                      "locks": [
                        "*"
                      ],
                      "order": 10,
                      "revision": 1,
                      "settings": {},
                      "steps": [
                        {
                          "add": {
                            "id": "daily",
                            "params": {
                              "over": "8h",
                              "to": "overtime",
                              "window": "day"
                            },
                            "uses": "standard/threshold"
                          }
                        }
                      ]
                    }
                  ],
                  "name": "franchise",
                  "scenarios": {
                    "overtime.toml": "description = \"...\""
                  },
                  "version": "2.1.0"
                },
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "The package as pushed."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant, or the package has no such revision."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Download a revision of the tenant's package",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/pay-periods": {
      "get": {
        "description": "The person's pay periods holding a day from `from` through `to` (at most 366 days), the earliest first, as their\npolicy has them on each day (a layer may give different people different periods, and change them from a day\non), each with where it stands for them: whether a ledger of it is kept, closed (and when), approved, and whether\nthey wait to be worked out again from a day of it or before.",
        "operationId": "attendance_pay_periods",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person whose pay periods: their policy says them, and may give\ndifferent people different periods.",
            "example": "104552",
            "in": "query",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The first day: YYYY-MM-DD; at most 366 days in all.",
            "example": "2026-10-01",
            "in": "query",
            "name": "from",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The last day: YYYY-MM-DD, on or after `from`.",
            "example": "2026-12-31",
            "in": "query",
            "name": "to",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "pay (the default) or a bill side.",
            "example": "pay",
            "in": "query",
            "name": "side",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "periods": [
                    {
                      "approved": true,
                      "closed": "2026-10-21T14:00:00Z",
                      "first": "2026-10-05",
                      "kept": true,
                      "last": "2026-10-18",
                      "pending": false
                    },
                    {
                      "approved": false,
                      "closed": null,
                      "first": "2026-10-19",
                      "kept": false,
                      "last": "2026-11-01",
                      "pending": false
                    }
                  ],
                  "person": "104552",
                  "side": "pay"
                },
                "schema": {
                  "$ref": "#/components/schemas/PayPeriodsView"
                }
              }
            },
            "description": "The periods."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "from after to, more than 366 days, or a person with no zone set up."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No tenant of that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List a person's pay periods",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/pending": {
      "get": {
        "description": "The tenant's people waiting to have their ledgers worked out again, by person, a page at a time: each with where\nfrom (an instant, whose workday in their zone it is, and a workday a change names), and why the last try failed for\nthose it failed for. An unlinked person (`GET .../unlinked`) says so. To read on, pass the answer's `next` as\n`after`.",
        "operationId": "attendance_pending",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only unlinked people (true), or only the others (false).",
            "in": "query",
            "name": "unlinked",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "description": "Only those in this organization, or one under it:\nhierarchy:organization.",
            "example": "management:ops-west",
            "in": "query",
            "name": "under",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The day `under` is asked of: YYYY-MM-DD; today (UTC) without it.",
            "example": "2026-10-07",
            "in": "query",
            "name": "on",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Carry on after the previous page: its `next`.",
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "At most this many: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "next": null,
                  "pending": [
                    {
                      "person": "104552",
                      "since_at": "2026-10-05T13:02:00Z"
                    },
                    {
                      "failed": "step boom (bad/boom): no rate for this",
                      "person": "104553",
                      "since_at": "2026-10-06T09:00:00Z",
                      "since_day": "2026-10-01"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PendingPage"
                }
              }
            },
            "description": "A page of who waits."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List who waits to be worked out",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/people": {
      "get": {
        "description": "Everyone the tenant knows (a person with facts, or with an employee record alone), by id in byte order; with `under`, only those in that organization or one under it on the\nday `on`, as the tree and their memberships were that day.",
        "operationId": "attendance_people",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only those in this organization, or one under it: hierarchy:organization.",
            "example": "management:ops-west",
            "in": "query",
            "name": "under",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The day `under` is asked of: YYYY-MM-DD; today (UTC) without it.",
            "example": "2026-10-07",
            "in": "query",
            "name": "on",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Carry on after this person: the previous page's `next`.",
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "At most this many: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "next": null,
                  "people": [
                    "104552",
                    "104553"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PeoplePage"
                }
              }
            },
            "description": "A page of them."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "An under that is not hierarchy:organization."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No tenant of that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List the people",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/people/{person}": {
      "get": {
        "description": "The person's employment on a day, from the employment facts recorded about them (hired, terminated, leaves,\nchanges of attributes such as exempt or the state worked in): whether they are employed, since when, on leave, for\nhow many days, and the attributes in force. Policies read the same (`ctx:person`).",
        "operationId": "attendance_person",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's id.",
            "in": "path",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The workday: YYYY-MM-DD; the person's today (in their zone, by\ntheir policy's workday) without it.",
            "example": "2026-10-07",
            "in": "query",
            "name": "day",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "day": "2026-10-07",
                  "employment": {
                    "attributes": {
                      "exempt": false,
                      "state": "CA"
                    },
                    "days_employed": 79,
                    "employed": true,
                    "first_hired": "2026-07-20",
                    "hired": "2026-07-20",
                    "on_leave_since": null,
                    "terminated": null
                  },
                  "person": "104552"
                },
                "schema": {
                  "$ref": "#/components/schemas/EmploymentView"
                }
              }
            },
            "description": "Their employment that day."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read a person's employment",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/people/{person}/days": {
      "get": {
        "description": "Each day from `from` through `to` (at most 366 days, any days, whatever pay periods they are in): the pay period it\nis in, its schedule (shifts, a day off, holidays, the leave asked for), its lines (each with its pay category, labor\ncontext, time and decimal hours, where its time came from and what the policy's steps did to it), its counts and\nmoney, the punches of the day as taken, its exceptions, and its totals; then the totals of all the days, and a\nsummary of each pay period the days touch, with where it stands and its own totals (the whole period's, and its\ndays' in the range). A day of a period with no ledger kept (ahead, or not worked out yet) is as scheduled, worked\nout on read, with no time (`kept` false).",
        "operationId": "attendance_person_days",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's id.",
            "in": "path",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The first day: YYYY-MM-DD; at most 366 days in all, any\ndays, whatever pay periods they are in.",
            "example": "2026-10-01",
            "in": "query",
            "name": "from",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The last day: YYYY-MM-DD, on or after `from`.",
            "example": "2026-10-31",
            "in": "query",
            "name": "to",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "pay (the default) or a bill side.",
            "example": "pay",
            "in": "query",
            "name": "side",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "days": [
                    {
                      "date": "2026-10-05",
                      "exceptions": [],
                      "holidays": [],
                      "kept": true,
                      "leave": [],
                      "lines": [
                        {
                          "category": "work",
                          "context": {},
                          "end": "2026-10-05T21:00:00Z",
                          "from": {
                            "segment": {
                              "kind": "work",
                              "punch": "p-1182"
                            }
                          },
                          "hours": "8.00",
                          "stamps": [],
                          "start": "2026-10-05T13:00:00Z",
                          "time": "8h"
                        }
                      ],
                      "period": {
                        "first": "2026-10-05",
                        "last": "2026-10-18"
                      },
                      "punches": [
                        {
                          "corrections": [],
                          "punch": {
                            "at": "2026-10-05T13:00:00Z",
                            "id": "p-1182",
                            "kind": "in",
                            "recorded": "2026-10-05T13:00:00Z",
                            "values": {}
                          }
                        }
                      ],
                      "quantities": [],
                      "shifts": [
                        {
                          "end": "2026-10-05T21:00:00Z",
                          "id": "days-2026-10-05",
                          "start": "2026-10-05T13:00:00Z",
                          "values": {}
                        }
                      ],
                      "totals": {
                        "categories": [
                          {
                            "category": "work",
                            "hours": "8.00",
                            "paid": true,
                            "time": "8h",
                            "worked": true
                          }
                        ],
                        "paid": "8.00",
                        "quantities": [],
                        "worked": "8h"
                      },
                      "zone": "America/Chicago"
                    }
                  ],
                  "from": "2026-10-05",
                  "periods": [
                    {
                      "approved": false,
                      "closed": null,
                      "first": "2026-10-05",
                      "in_range": {
                        "categories": [
                          {
                            "category": "work",
                            "hours": "8.00",
                            "paid": true,
                            "time": "8h",
                            "worked": true
                          }
                        ],
                        "paid": "8.00",
                        "quantities": [],
                        "worked": "8h"
                      },
                      "kept": true,
                      "last": "2026-10-18",
                      "pending": false,
                      "totals": {
                        "categories": [
                          {
                            "category": "work",
                            "hours": "40.00",
                            "paid": true,
                            "time": "40h",
                            "worked": true
                          }
                        ],
                        "paid": "40.00",
                        "quantities": [],
                        "worked": "40h"
                      }
                    }
                  ],
                  "person": "104552",
                  "side": "pay",
                  "to": "2026-10-05",
                  "totals": {
                    "categories": [
                      {
                        "category": "work",
                        "hours": "8.00",
                        "paid": true,
                        "time": "8h",
                        "worked": true
                      }
                    ],
                    "paid": "8.00",
                    "quantities": [],
                    "worked": "8h"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/DaysView"
                }
              }
            },
            "description": "Their days."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "from after to, more than 366 days, or a person with no zone set up."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No tenant of that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read a person's days",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/people/{person}/exceptions/{id}": {
      "post": {
        "description": "Records a note about one of the person's exceptions, by whoever calls: acknowledged, excused or reopened. The\nlatest note is where the exception stands; the person's ledgers are worked out again, so an excused exception no\nlonger keeps approval back, and exception.resolved is sent for it.\nWith `preview=true`, nothing is recorded: the answer is what recording would change in the person's ledgers,\nchecked and refused exactly as the write is.",
        "operationId": "attendance_note_exception",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's id.",
            "in": "path",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The exception's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "true: record nothing, and answer what recording would change\n(a preview); checked and refused as the write is.",
            "in": "query",
            "name": "preview",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "action": "excuse",
                "comment": "doctor's appointment, agreed"
              },
              "schema": {
                "$ref": "#/components/schemas/NewNote"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "id": "8c1e0f6a-1b0e-4c4e-9c55-1f2a3b4c5d6e",
                  "recorded": "new"
                },
                "schema": {
                  "$ref": "#/components/schemas/Answer_NoteView"
                }
              }
            },
            "description": "Recorded; with `preview=true`, what recording it would change."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No kept ledger of the person has that exception."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A note with that id is recorded already, differently."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Note an exception",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/people/{person}/facts": {
      "get": {
        "description": "Everything recorded about the person that their ledgers are worked out from, as it was recorded: punches,\ncorrections, labor entries, approvals, closes, accrual adjustments, schedule overrides, employment changes,\nexception notes, leave requests and break attestations, each with `recorded` (when Connect received a clock punch, or the time its\nsender gave) and `stored` (when Time and Attendance stored it, which orders them). Facts are never changed;\na correction is a fact of its own.",
        "operationId": "attendance_facts",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's id.",
            "in": "path",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "facts": [
                    {
                      "punch": {
                        "at": "2026-10-05T13:00:00Z",
                        "device": "CG0001",
                        "id": "9f2c",
                        "kind": "in",
                        "recorded": "2026-10-05T13:00:05Z",
                        "stored": "2026-10-05T13:00:06.120Z",
                        "values": {}
                      }
                    }
                  ],
                  "person": "104552"
                },
                "schema": {
                  "$ref": "#/components/schemas/FactsView"
                }
              }
            },
            "description": "The person's facts."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List a person's facts",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Records facts about the person, all of them or none: corrections, labor entries, approvals, closes, accrual\nadjustments, schedule overrides, employment changes, exception notes, leave requests, break attestations, or punches made outside a\nclock. A punch, and one a correction adds, names the device it was made on (`device`): a clock's id, or the id the\nsystem that took it gives itself (`mobile`, `web`). Each fact is stamped with when it was stored (`stored`), which alone orders the person's facts and tells\nwhich pay period it was recorded in (a change to a closed one is late by it); a `recorded` the caller gives is\nkept as information, and a `stored` it gives is not kept. A fact recorded again (the same id, the same\ncontent, whenever sent) changes nothing; the same id with other content refuses the whole request (409). An approval of a\nsubject that is blocked now (exceptions not excused on its days where its rule says `blocked_by_exceptions`, or a\npolicy step) is refused (409), naming what blocks it, at whatever stage. The person is marked to\nhave their ledgers worked out again from the earliest day the new facts change. A post records at most 1000 facts,\neach with an id of at most 256 characters (a punch's device 1 to 256), naming days from 1900-01-01 through 2199-12-31 (an instant's day in\nUTC); an attestation names at most 16 breaks, each numbered 1 to 16, with a reason of at most 1000 characters.\nWith `preview=true`, nothing is recorded: the answer is what recording would change in the person's ledgers,\nchecked and refused exactly as the write is.",
        "operationId": "attendance_record",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's id.",
            "in": "path",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "true: record nothing, and answer what recording would change\n(a preview); checked and refused as the write is.",
            "in": "query",
            "name": "preview",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "facts": [
                  {
                    "correction": {
                      "by": "lead",
                      "change": {
                        "move": {
                          "punch": "9f2d",
                          "to": "2026-10-05T22:00:00Z"
                        }
                      },
                      "id": "c1",
                      "reason": "left at five",
                      "recorded": "2026-10-06T14:00:00Z"
                    }
                  }
                ]
              },
              "schema": {
                "$ref": "#/components/schemas/NewFacts"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "recorded": [
                    "new"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/Answer_RecordedView"
                }
              }
            },
            "description": "What came of each; with `preview=true`, what recording them would change."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A fact is not one, its id is more than 256 characters, a punch (or one a correction adds) names no device or one of more than 256 characters, it names a day before 1900 or after 2199, an attestation is past its bounds, or there are more than 1000."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A fact's id is recorded already, with other content; or an approval is of a subject blocked now (open exceptions on its days, or a policy step), named."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Record facts",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/people/{person}/leave": {
      "get": {
        "description": "The person's leave requests as they stand (those replaced or taken back left out), each with where its approval\nstands by the tenant's approval rule for leave: pending at a stage, approved, or rejected. With no rule for\nleave, a request waits for one decision, at the stage `approval`.",
        "operationId": "attendance_leave",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's id.",
            "in": "path",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "by": "104552",
                    "category": "vacation",
                    "comment": "family visit",
                    "days": {
                      "2026-10-12": "8h",
                      "2026-10-13": "4h"
                    },
                    "fingerprint": "4be1d2a0c3f94e7b8a6d5c2e1f0a9b87",
                    "id": "v1",
                    "recorded": "2026-10-01T14:00:00Z",
                    "stage": "hr",
                    "state": "pending",
                    "subject": "leave:v1:2026-10-12"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/LeaveView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Their leave requests."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List a person's leave",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Records a leave request for the person, by the caller: a pay category and the time on each day, and the values the\ntenant's policy reads of it (the relationship of a bereavement). It waits for the\nstages of the tenant's approval rule for leave (with none, one decision at the stage `approval`); approved, its time is in the person's ledgers, in its\ncategory. To change one, ask again naming it in `replaces`.\nWith `preview=true`, nothing is recorded: the answer is what recording would change in the person's ledgers,\nchecked and refused exactly as the write is.",
        "operationId": "attendance_request_leave",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's id.",
            "in": "path",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "true: record nothing, and answer what recording would change\n(a preview); checked and refused as the write is.",
            "in": "query",
            "name": "preview",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "category": "vacation",
                "comment": "family visit",
                "days": {
                  "2026-10-12": "8h",
                  "2026-10-13": "4h"
                }
              },
              "schema": {
                "$ref": "#/components/schemas/NewLeave"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "id": "v1",
                  "recorded": "new"
                },
                "schema": {
                  "$ref": "#/components/schemas/Answer_LeaveRecorded"
                }
              }
            },
            "description": "Recorded; with `preview=true`, what recording it would change."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No days, or a time that is no duration."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A request with that id is recorded already, differently."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Ask for leave",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/people/{person}/leave/{id}": {
      "delete": {
        "description": "Cancels one of the person's standing leave requests, by the caller: its time is no longer in their ledgers, and\nleave.cancelled is sent.\nWith `preview=true`, nothing is recorded: the answer is what recording would change in the person's ledgers,\nchecked and refused exactly as the write is.",
        "operationId": "attendance_cancel_leave",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's id.",
            "in": "path",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The request's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "true: record nothing, and answer what recording would change\n(a preview); checked and refused as the write is.",
            "in": "query",
            "name": "preview",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "id": "1f0c9a52-7d3e-4b8a-9c11-5e2f6a7b8c9d",
                  "recorded": "new"
                },
                "schema": {
                  "$ref": "#/components/schemas/Answer_LeaveRecorded"
                }
              }
            },
            "description": "Taken back: the id of the cancel recorded; with `preview=true`, what taking it back would change."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The person has no standing request with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Take leave back",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/people/{person}/leave/{id}/decision": {
      "post": {
        "description": "Records a decision on one of the person's standing leave requests at a stage of the approval rule for leave, by\nthe caller, on the request as it stands now (its fingerprint). Approved at every stage, its time is in the\nperson's ledgers.\nWith `preview=true`, nothing is recorded: the answer is what recording would change in the person's ledgers,\nchecked and refused exactly as the write is.",
        "operationId": "attendance_decide_leave",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's id.",
            "in": "path",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The request's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "true: record nothing, and answer what recording would change\n(a preview); checked and refused as the write is.",
            "in": "query",
            "name": "preview",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "decision": "approve",
                "stage": "supervisor"
              },
              "schema": {
                "$ref": "#/components/schemas/LeaveDecision"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "id": "v1",
                  "recorded": "new"
                },
                "schema": {
                  "$ref": "#/components/schemas/Answer_LeaveRecorded"
                }
              }
            },
            "description": "Recorded; with `preview=true`, what recording it would change."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The person has no standing request with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Decide on leave",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/people/{person}/ledger": {
      "get": {
        "description": "The person's ledger of the pay period `day` (a workday; without it, the person's today) is in, as last worked\nout. While the person waits to be worked out\nagain (something new was recorded for them, or their setup or policy changed), `pending` says so: the ledger is\nabout to change. 404 until their ledgers have been worked out for that period.",
        "operationId": "attendance_ledger",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's id.",
            "in": "path",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "A workday of the pay period: YYYY-MM-DD; the person's today (in\ntheir zone, by their policy's workday) without it.",
            "example": "2026-10-07",
            "in": "query",
            "name": "day",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "pay (the default) or bill.",
            "example": "pay",
            "in": "query",
            "name": "side",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "first": "2026-10-05",
                  "last": "2026-10-18",
                  "ledger": {
                    "days": [
                      {
                        "date": "2026-10-05",
                        "lines": [
                          {
                            "category": "work"
                          }
                        ]
                      }
                    ]
                  },
                  "person": "104552",
                  "side": "pay"
                },
                "schema": {
                  "$ref": "#/components/schemas/LedgerView"
                }
              }
            },
            "description": "The ledger."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not worked out for that period yet: the message says what is missing (no fact about the person, waiting, no time zone) and the command that sets it."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read a ledger",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/people/{person}/record": {
      "get": {
        "description": "The person's employee record: the employer whose employee they are, and their worker. 404 for a person with\nnone (no fact recorded for them, and none made).",
        "operationId": "attendance_record_of",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's id.",
            "in": "path",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "employer": "acme-ca",
                  "person": "4471",
                  "worker": "w-17"
                },
                "schema": {
                  "$ref": "#/components/schemas/RecordView"
                }
              }
            },
            "description": "Their record."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant, or no record of the person."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read a person's record",
        "tags": [
          "attendance"
        ]
      },
      "put": {
        "description": "Makes the person's employee record, of the employer given (before their first fact, for a tenant of several\nemployers: a person first recorded without one is an employee of the tenant's first), or changes their worker.\nA record's employer never changes: one of another employer is refused (409), since employment with another\nemployer is another record. A change of worker works the person, and the records of their worker before and\nafter, out again from now: rules across employers read the worker's other records.",
        "operationId": "attendance_set_record",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's id.",
            "in": "path",
            "name": "person",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "employer": "acme-ca",
                "worker": "w-17"
              },
              "schema": {
                "$ref": "#/components/schemas/RecordBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "employer": "acme-ca",
                  "person": "4471",
                  "worker": "w-17"
                },
                "schema": {
                  "$ref": "#/components/schemas/RecordView"
                }
              }
            },
            "description": "Their record."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such employer."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A record of another employer, an unlinked person, or the tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Make or change a person's record",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/recalculate": {
      "post": {
        "description": "Marks the people named (everyone of the tenant when none are) to be worked out again from their first day\nwithout reusing anything kept: each kept ledger is worked out from the facts alone, whatever its stages' digests\nsay, and the new ledger is compared with the one kept, so what it changes is told as events, as for any\nrecalculation, with the reason as the cause. For after a package or engine fix, when a ledger kept by a faulty\nbuild is wrong in a way its digests do not show. Closed pay periods stay closed (what a close recorded is not\nworked out again). The answer is when they are marked: the work follows, and `GET .../pending` shows who waits.",
        "operationId": "attendance_recalculate",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "people": [
                  "104552"
                ],
                "reason": "overtime rule fixed in 2.4.1"
              },
              "schema": {
                "$ref": "#/components/schemas/RecalculateBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "marked": 1
                },
                "schema": {
                  "$ref": "#/components/schemas/RecalculateView"
                }
              }
            },
            "description": "How many were marked."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Work people out again, keeping nothing",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/resume": {
      "post": {
        "description": "The tenant's people are worked out again, and its API takes writes again; its sinks deliver the punches that\nwaited at once.",
        "operationId": "attendance_resume_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-01T14:00:00Z",
                  "external_ids": {
                    "payroll": "C-1042"
                  },
                  "id": "acme",
                  "metadata": {
                    "contract": {
                      "long_day": "10h"
                    }
                  },
                  "name": "Acme Staffing",
                  "status": "active",
                  "updated": "2026-10-01T14:00:00Z"
                },
                "schema": {
                  "$ref": "#/components/schemas/TenantView"
                }
              }
            },
            "description": "Resumed."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Resume a tenant",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/setup": {
      "get": {
        "description": "The setup items in force: the tenant's, and with `?person=` the person's own, which a person's ledgers are\nworked out with over the tenant's (dimensions, assignments, implications, shifts and shift definitions,\nholidays, pay categories, measures, rates, approval rules, accrual categories, defaults, time zone).",
        "operationId": "attendance_setup",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person whose own setup this is; absent: the tenant's.",
            "example": "104552",
            "in": "query",
            "name": "person",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Why it is put (on a set or a removal), in free text: kept with the revision, and told of with\nthe results that change because of it (`because`).",
            "example": "announced by decree on 3 October",
            "in": "query",
            "name": "reason",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "person": [
                    {
                      "zone": {
                        "from": "2026-10-12",
                        "zone": "America/New_York"
                      }
                    }
                  ],
                  "tenant": [
                    {
                      "zone": "America/Chicago"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/SetupView"
                }
              }
            },
            "description": "The setup in force."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read the setup",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/setup/{kind}/{id}": {
      "delete": {
        "description": "Takes the setup item `kind`/`id` away (a new revision that holds nothing), the tenant's or with `?person=`\nthe person's own.",
        "operationId": "attendance_remove_setup",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The item's kind.",
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The item's id among its kind.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person whose own setup this is; absent: the tenant's.",
            "example": "104552",
            "in": "query",
            "name": "person",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Why it is put (on a set or a removal), in free text: kept with the revision, and told of with\nthe results that change because of it (`because`).",
            "example": "announced by decree on 3 October",
            "in": "query",
            "name": "reason",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "revision": 3
                },
                "schema": {
                  "$ref": "#/components/schemas/RevisionView"
                }
              }
            },
            "description": "The new revision."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant's measure or accrual category is needed by a package the tenant adopts (the package is named): drop the package first."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Remove a setup item",
        "tags": [
          "attendance"
        ]
      },
      "put": {
        "description": "Sets the tenant's setup item `kind`/`id`, or with `?person=` the person's own, as a new revision: the body\nis the item (for a `zone`, the zone's name, or `{\"zone\": ..., \"from\": \"2026-10-08\"}` for a zone in force from that\nworkday on, the days before read in the zone before; for an `assignment`, its fields). Whom it applies to is\nmarked to have their ledgers worked out again from the earliest day it changes.",
        "operationId": "attendance_set_setup",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "dimension, assignment, implication, shift, shift_definition, holiday, category, measure, rate, approval_rule, accrual_category, defaults or zone.",
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The item's id among its kind.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person whose own setup this is; absent: the tenant's.",
            "example": "104552",
            "in": "query",
            "name": "person",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Why it is put (on a set or a removal), in free text: kept with the revision, and told of with\nthe results that change because of it (`because`).",
            "example": "announced by decree on 3 October",
            "in": "query",
            "name": "reason",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": "America/Chicago",
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "revision": 2
                },
                "schema": {
                  "$ref": "#/components/schemas/RevisionView"
                }
              }
            },
            "description": "The new revision."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not an item of that kind, or its id is more than 256 characters."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Set a setup item",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/shift-costs": {
      "post": {
        "description": "A labor-cost estimate, before anyone works the shifts: for each person, what working every shift proposed would\nadd to their pay. Each person's pay ledgers are worked out from their real facts with the setup and policy in force,\nonce as they are and once with the shifts worked as proposed (an in punch at each start, an out at each finish,\nwith the values given), as a recalculation would work them out had the punches been recorded; the answer is the\ndifference: the hours of each pay category and in all, the money where the person has rates (none said without),\nthe lines and counts added and taken away with what the policy's steps did to each (the overtime a shift tips a\nweek into, a short-rest premium, a differential), the exceptions raised, and the leave requests the policy would\nrefuse. Nothing is recorded, and it is not in the audit trail. At most 100 people and 31 shifts, each at most 24\nhours, worked out within 1,000,000,000 script steps in all. A person who cannot be estimated (no zone set up) says why in `error`.",
        "operationId": "attendance_shift_costs",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "people": [
                  "104552",
                  "104553"
                ],
                "shifts": [
                  {
                    "finish": "2026-10-10T22:00:00Z",
                    "start": "2026-10-10T12:00:00Z",
                    "values": {
                      "assignment": "A12"
                    }
                  }
                ]
              },
              "schema": {
                "$ref": "#/components/schemas/ShiftCostAsk"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "estimates": [
                    {
                      "added": [
                        {
                          "category": "overtime",
                          "hours": {
                            "places": 2,
                            "steps": 200
                          },
                          "stamps": [
                            {
                              "did": "moved 2h from work to overtime: over 8h in the day",
                              "layers": "tenant rev 1",
                              "step": "daily"
                            }
                          ],
                          "workday": "2026-10-10"
                        }
                      ],
                      "added_quantities": [],
                      "exceptions": [],
                      "hours": {
                        "overtime": "2.00",
                        "work": "8.00"
                      },
                      "money": [
                        {
                          "amount": 16000,
                          "category": "work",
                          "currency": "USD"
                        },
                        {
                          "amount": 6000,
                          "category": "overtime",
                          "currency": "USD"
                        }
                      ],
                      "paid_hours": "10.00",
                      "person": "104552",
                      "refused": [],
                      "removed": [],
                      "removed_quantities": [],
                      "total_money": [
                        {
                          "amount": 22000,
                          "currency": "USD"
                        }
                      ],
                      "worked": "10h"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/ShiftCosts"
                }
              }
            },
            "description": "Each person's estimate, in the order asked."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Too many people or shifts, none, a shift that does not finish after it starts or is longer than 24 hours, or more than can be worked out within the work limit (1,000,000,000 script steps)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A shift is in a pay period closed for one of the people: its cost is a late change to that period, not an estimate."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Estimate what shifts would cost",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/sinks": {
      "get": {
        "description": "The scope's sinks, each with where it sends events and which ones; the signing secret only as `secret_set`.\n`GET .../sinks/status` shows how each one's deliveries are going.",
        "operationId": "attendance_list_sinks",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "events": [
                      "period.closed",
                      "period.adjusted"
                    ],
                    "id": "payroll",
                    "secret_set": true,
                    "type": "webhook",
                    "url": "https://payroll.example.com/attendance"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SinkView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every sink."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List sinks",
        "tags": [
          "attendance"
        ]
      },
      "post": {
        "description": "Adds a `webhook` sink that Time and Attendance's events are posted to, as `{\"events\": [...]}`, in order, each batch\nuntil it answers 2xx, signed as Connect's are when it has a `secret` (`x-houradvantage-timestamp`,\n`x-houradvantage-signature`: `v1=` and the hex HMAC-SHA256 of the timestamp, a '.', and the body). A tenant's sink\nis sent the tenant's own events (`period.closed`, `exception.raised`...) and those the systems it names in\n`sources` post into the tenant (`POST .../events`); an install-level sink is sent every tenant's events, and names\nno sources. `events` limits it to those types; empty or absent, it is sent every type. It starts with the events\nstored from now on. Recorded in the audit trail, the secret left out.",
        "operationId": "attendance_create_sink",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "events": [
                  "period.closed",
                  "period.adjusted"
                ],
                "id": "payroll",
                "secret": "a-long-random-string",
                "type": "webhook",
                "url": "https://payroll.example.com/attendance"
              },
              "schema": {
                "$ref": "#/components/schemas/SinkConfig"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "period.closed",
                    "period.adjusted"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://payroll.example.com/attendance"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "Added: as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "webhook sink 'payroll' needs url"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a sink, or the sink is not valid: an id that is not 1-64 letters, digits, '-' or '_' (or is `status`); a type other than `webhook`; a missing `url`, or one that is not http or https; a `person_id`, `receiver` or `tenant`; `sources` on an install-level sink."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sink 'payroll' already exists"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A sink with that id exists."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Add a sink",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/sinks/status": {
      "get": {
        "description": "How each sink is getting on: how many events wait for it, since when, when it last took some, whether it is\nrefusing them and why, and where it is in the events. One sink is delivered to by one instance at a time; this\nreads what that instance has recorded, so any instance running the engine gives the same answer. A sink that\nrefuses is tried again until it takes the events, however long that takes: nothing is skipped unless you move it\n(`POST .../sinks/{id}/position`).",
        "operationId": "attendance_sink_status",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "behind": 3,
                    "delivered_at": "2026-10-18T05:00:01Z",
                    "dropped": null,
                    "error": null,
                    "failing_since": null,
                    "oldest_waiting_at": "2026-10-19T05:00:00Z",
                    "position": 1205,
                    "sink": "payroll"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SinkStatus"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every sink whose state could be read."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List sink deliveries",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/sinks/{id}": {
      "delete": {
        "description": "Removes a sink: nothing more is sent to it, and its place in the events goes with it: a sink made again with its\nid starts as a new sink does. Recorded in the audit trail.",
        "operationId": "attendance_delete_sink",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "period.closed",
                    "period.adjusted"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://payroll.example.com/attendance"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "Removed: as it was."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Remove a sink",
        "tags": [
          "attendance"
        ]
      },
      "get": {
        "description": "One sink, the secret shown only as `secret_set`.",
        "operationId": "attendance_show_sink",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "period.closed",
                    "period.adjusted"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://payroll.example.com/attendance"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "The sink."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Get a sink",
        "tags": [
          "attendance"
        ]
      },
      "patch": {
        "description": "Changes a sink's settings: only the fields given change (a JSON merge patch); `secret` set to null stops signing.\nIts deliveries go on with the new settings from where it is in the events; a batch under way may be sent again.\nRecorded in the audit trail, the secret left out.",
        "operationId": "attendance_update_sink",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "events": [
                  "period.closed"
                ]
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "period.closed",
                    "period.adjusted"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://payroll.example.com/attendance"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "Changed: as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sink 'payroll': url must be http or https"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a JSON object, it changes the id, or the sink is not valid once patched."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Change a sink",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/sinks/{id}/position": {
      "post": {
        "description": "Moves a sink along Time and Attendance's events by hand: ahead, to skip what it refuses or no longer wants, or\nback, to have it sent events again. `{\"seq\": n}` makes the next event it is sent the first after `n`; `{\"seq\":\n\"latest\"}` skips every event stored so far. Sequence numbers are those of Time and Attendance's own events (`GET\n/api/attendance/tenants/{tenant}/events`), not Connect's. Recorded in the audit trail, and told to the log's sinks\nwith a `sink.moved` event: moving a sink ahead is the only way it loses events it has not taken.",
        "operationId": "attendance_move_sink",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "seq": "latest"
              },
              "schema": {
                "$ref": "#/components/schemas/PositionBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "from": 1180,
                  "sink": "payroll",
                  "to": 1205
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkMovedView"
                }
              }
            },
            "description": "Moved: from where to where."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no event 5000 yet: the newest is 4181"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`seq` is neither a sequence number of 0 or more nor \"latest\", or it is past the newest event."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the attendance engine does not run on this instance (start it with HOURADVANTAGE_ATTEND)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Move a sink",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/suspend": {
      "post": {
        "description": "The operator's decision to stop the tenant: nothing of it is worked out and it sends no events; its API refuses\nwrites (409); its sinks' deliveries are refused, so their punches wait in Connect (each such sink falls\nbehind, its status saying why) until it is resumed. Connect keeps them however long that takes, and tells of a\nsink still behind after `retention_days` (`sink.behind`).",
        "operationId": "attendance_suspend_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "created": "2026-10-01T14:00:00Z",
                  "external_ids": {
                    "payroll": "C-1042"
                  },
                  "id": "acme",
                  "metadata": {
                    "contract": {
                      "long_day": "10h"
                    }
                  },
                  "name": "Acme Staffing",
                  "status": "suspended",
                  "updated": "2026-10-01T14:00:00Z"
                },
                "schema": {
                  "$ref": "#/components/schemas/TenantView"
                }
              }
            },
            "description": "Suspended."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Suspend a tenant",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/timecards": {
      "get": {
        "description": "Each person's timecard of the pay period starting `period`, as last worked out, by person: its hours, whether it\nis approved and closed, where each subject's approval stands (and the organization a decision waits on, where a\nstage is tied to a hierarchy), and how many exceptions are still to deal with. With `under`, only those in that\norganization or one under it on `on` (the period's last day without it).",
        "operationId": "attendance_timecards",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The pay period's first day: YYYY-MM-DD.",
            "example": "2026-10-05",
            "in": "query",
            "name": "period",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "pay (the default) or a bill side.",
            "example": "pay",
            "in": "query",
            "name": "side",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only those in this organization, or one under it: hierarchy:organization.",
            "example": "management:ops-west",
            "in": "query",
            "name": "under",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The day `under` is asked of: YYYY-MM-DD; the period's last day without it.",
            "example": "2026-10-18",
            "in": "query",
            "name": "on",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Carry on after this person: the previous page's `next`.",
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "At most this many: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "next": null,
                  "timecards": [
                    {
                      "approvals": [
                        {
                          "organization": "ops-west",
                          "state": {
                            "pending": "supervisor"
                          },
                          "subject": "period:2026-10-05"
                        }
                      ],
                      "approved": false,
                      "closed": null,
                      "exceptions": 0,
                      "first": "2026-10-05",
                      "last": "2026-10-18",
                      "paid": "80.00",
                      "person": "104552",
                      "worked": "80h"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/TimecardsPage"
                }
              }
            },
            "description": "A page of them."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A period that is no day, or an under that is not hierarchy:organization."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No tenant of that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List a pay period's timecards",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/unlinked": {
      "get": {
        "description": "The tenant's unlinked people, by id: whom punches arrived for under the sender's ids only. Each with the sender's\nids (Connect's id of the person, the endpoint and user, the device they last punched at), when first and last\nseen, and their links. Their hours show as anyone's: `GET .../people/{id}/ledger`. With `under`, only those\nlinked to someone in that organization, or one under it, on `on`.",
        "operationId": "attendance_unlinked",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only those linked to someone now (true), or only those linked to no\none (false).",
            "in": "query",
            "name": "linked",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "description": "Only those linked to someone in this organization, or one under it:\nhierarchy:organization.",
            "example": "management:ops-west",
            "in": "query",
            "name": "under",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The day `under` is asked of: YYYY-MM-DD; today (UTC) without it.",
            "example": "2026-10-07",
            "in": "query",
            "name": "on",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Carry on after the previous page: its `next`.",
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "At most this many: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "next": null,
                  "unlinked": [
                    {
                      "first_seen": "2026-10-05T13:00:06Z",
                      "id": "hq~0c6f2a1e-7d43-4b8e-9a51-3f2e8d6c4b10",
                      "last_seen": "2026-10-07T13:00:02Z",
                      "linked": null,
                      "links": [],
                      "sender": {
                        "device": "CG0001",
                        "endpoint": "office",
                        "group": "hq",
                        "person": "0c6f2a1e-7d43-4b8e-9a51-3f2e8d6c4b10",
                        "tenant": "default",
                        "user_id": "1001"
                      }
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/UnlinkedPage"
                }
              }
            },
            "description": "A page of them."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No tenant of that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List the unlinked people",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/unlinked/{id}": {
      "get": {
        "description": "One unlinked person: the sender's ids, when first and last seen, whom they are linked to, and their links.",
        "operationId": "attendance_unlinked_person",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The unlinked person's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "first_seen": "2026-10-06T12:58:00Z",
                  "id": "acme.office~5e1d9b02-3f6a-4c8e-b7d1-0a2c4e6f8a90",
                  "last_seen": "2026-10-06T21:01:00Z",
                  "linked": null,
                  "links": [],
                  "sender": {
                    "device": "CG0002",
                    "endpoint": "office",
                    "person": "5e1d9b02-3f6a-4c8e-b7d1-0a2c4e6f8a90",
                    "tenant": "acme",
                    "user_id": "1003"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/UnlinkedView"
                }
              }
            },
            "description": "The unlinked person."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant, or the unlinked person, is not there."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read an unlinked person",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/unlinked/{id}/link": {
      "post": {
        "description": "Says who the unlinked person is: from now on their punches, and the corrections recorded on them, are that\nperson's, as are the punches that arrive under their ids after. The person's ledgers are worked out again from\nthe earliest of the punches that move; a closed period of theirs takes them as a late change (an adjustment in\nthe period open now, or refused, as its policy says). Linking to someone else, or unlinking (`\"person\": null`),\nworks the same way: the punches move from now on. The engine tells `person.linked`, with both ids and the\nsender's, so the sender can be told the person's id. A link to whom they are linked to already changes nothing.",
        "operationId": "attendance_link",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The unlinked person's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "person": "4471"
              },
              "schema": {
                "$ref": "#/components/schemas/LinkBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "first_seen": "2026-10-05T13:00:06Z",
                  "id": "hq~0c6f2a1e-7d43-4b8e-9a51-3f2e8d6c4b10",
                  "last_seen": "2026-10-07T13:00:02Z",
                  "linked": "4471",
                  "links": [
                    {
                      "by": "lead",
                      "person": "4471",
                      "seq": 1,
                      "stored": "2026-10-07T15:00:00Z"
                    }
                  ],
                  "sender": {
                    "device": "CG0001",
                    "endpoint": "office",
                    "group": "hq",
                    "person": "0c6f2a1e-7d43-4b8e-9a51-3f2e8d6c4b10",
                    "tenant": "default",
                    "user_id": "1001"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/UnlinkedView"
                }
              }
            },
            "description": "The unlinked person, linked."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The person is an unlinked person, or no person's id."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant, or no such unlinked person."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Link an unlinked person",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/unreadable": {
      "get": {
        "description": "The tenant's punches that were delivered but could not be read (no time, no device, or no user to place them on), oldest\nfirst, each as it came and why: none is dropped without a trace. Put one right by recording the punch it should\nhave been, then forget it (`DELETE`).",
        "operationId": "attendance_unreadable",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Carry on after the previous page: its `next`.",
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "At most this many: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "next": null,
                  "punches": [
                    {
                      "event": {
                        "data": {
                          "user_id": "1003"
                        },
                        "endpoint": "office",
                        "id": "4be1d2a0c3f94e7b8a6d5c2e1f0a9b87",
                        "type": "punch"
                      },
                      "id": "4be1d2a0c3f94e7b8a6d5c2e1f0a9b87",
                      "stored": "2026-10-05T13:00:06Z",
                      "why": "punch event 4be1d2a0c3f94e7b8a6d5c2e1f0a9b87 has no time"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/UnreadablePage"
                }
              }
            },
            "description": "A page of them."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no tenant of that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "List the punches that could not be read",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/unreadable/{id}": {
      "delete": {
        "description": "Once it is put right (the punch it should have been recorded), it is forgotten: it no longer shows.",
        "operationId": "attendance_forget_unreadable",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The event's id.",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "204": {
            "description": "Forgotten."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant, or no such punch."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Forget a punch that could not be read",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/attendance/tenants/{tenant}/workers/{worker}": {
      "get": {
        "description": "The records of one human across the tenant's employers, linked by their worker id.",
        "operationId": "attendance_worker",
        "parameters": [
          {
            "description": "The tenant's id.",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The worker's id.",
            "in": "path",
            "name": "worker",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "records": [
                    {
                      "employer": "acme-ca",
                      "person": "4471",
                      "worker": "w-17"
                    },
                    {
                      "employer": "acme",
                      "person": "us-9120",
                      "worker": "w-17"
                    }
                  ],
                  "worker": "w-17"
                },
                "schema": {
                  "$ref": "#/components/schemas/WorkerView"
                }
              }
            },
            "description": "Their records."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No such tenant."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The attendance engine does not run here."
          }
        },
        "summary": "Read a worker",
        "tags": [
          "attendance"
        ]
      }
    },
    "/api/audit": {
      "get": {
        "description": "The changes made through this API, oldest first, a page at a time: who made each one, on which instance, what it\ndid, and the request with its passwords, keys and secrets taken out (a secret's request is never kept, and\nsensitive values, such as PINs, card numbers, templates and photos, are kept only as their size). Every request\nthat changes something\nand succeeds is recorded, and so is every wire capture started; requests that fail, reads, scenario runs, events\nposted (data, as a device's messages are) and the instances' own calls to each other are not. Entries are kept for ever, or for `audit_retention_days` when that\nsetting is set. To read on, pass the answer's `next` as `after`; a page with no entries means you have read them\nall, and `next` stays where it was. The filters (`user`, `tenant`, `action`, `since`, `until`, `request_id`) hold\ntogether, each from an index.",
        "operationId": "audit",
        "parameters": [
          {
            "description": "Only entries after the one with this `seq`: the `next` of the page\nbefore. Default 0, from the oldest kept.",
            "example": 512,
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "description": "At most this many entries: 100 unless given, at most 1000 (more is\nread as 1000).",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "description": "Only changes made by this user: the login's name, `token:<name>`, or `local`.",
            "example": "token:deploy",
            "in": "query",
            "name": "user",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only changes whose request named this tenant in its path (`/api/tenants/<tenant>/...`, or\n`/api/attendance/tenants/<tenant>/...`).",
            "example": "acme",
            "in": "query",
            "name": "tenant",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only changes whose action (method and path, `POST /api/sinks`) starts with this.",
            "example": "POST /api/tokens",
            "in": "query",
            "name": "action",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only changes made at or after this time (RFC 3339).",
            "example": "2026-01-15T00:00:00Z",
            "in": "query",
            "name": "since",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "Only changes made before this time (RFC 3339): later than `since`.",
            "example": "2026-01-16T00:00:00Z",
            "in": "query",
            "name": "until",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "Only the change made by the request with this id (`X-Request-Id`).",
            "example": "3f2a9c1e",
            "in": "query",
            "name": "request_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "entries": [
                    {
                      "action": "POST /api/sinks",
                      "at": "2026-01-15T08:00:00Z",
                      "body": "{\"events\":[\"punch\"],\"id\":\"payroll\",\"type\":\"webhook\",\"url\":\"https://example.com/houradvantage\"}",
                      "instance": "gw-1",
                      "outcome": "done",
                      "seq": 513,
                      "status": 201,
                      "summary": "sink 'payroll' added",
                      "user": "admin"
                    },
                    {
                      "action": "PUT /api/secrets/api_key",
                      "at": "2026-01-15T08:01:00Z",
                      "instance": "gw-2",
                      "outcome": "started",
                      "seq": 514,
                      "summary": "PUT /api/secrets/api_key",
                      "user": "token:deploy"
                    }
                  ],
                  "next": 514
                },
                "schema": {
                  "$ref": "#/components/schemas/AuditPage"
                }
              }
            },
            "description": "A page of the audit trail, oldest first."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "until must be later than since"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`until` is not later than `since`."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Read the audit trail",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/export": {
      "get": {
        "description": "What the install itself is set up with: its settings, its log level, its tenants and its install-level sinks.\nA tenant's listeners, endpoints, sinks and sync groups are in its own export\n(`GET /api/tenants/{tenant}/export`). Sink secrets are left out: `secret_set` says whether one is set. Packages,\nAPI tokens and devices are not part of it.",
        "operationId": "export",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "endpoints": [],
                  "listeners": [],
                  "logs": {
                    "level": "info"
                  },
                  "settings": {
                    "audit_retention_days": null,
                    "limits": {
                      "max_body_bytes": 4194304,
                      "max_pending_devices": 100,
                      "set_aside_days": 7,
                      "traffic_body_bytes": 16384
                    },
                    "retention_days": 90,
                    "tenant_destinations": [],
                    "trusted_proxies": []
                  },
                  "sinks": [
                    {
                      "events": [
                        "punch"
                      ],
                      "id": "time",
                      "receiver": "attendance",
                      "secret_set": false,
                      "type": "in_process"
                    }
                  ],
                  "sync_groups": [],
                  "tenants": [
                    {
                      "id": "default"
                    },
                    {
                      "id": "acme",
                      "name": "Acme Manufacturing"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/Export"
                }
              }
            },
            "description": "The install's setup."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Export the install's setup",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/health": {
      "get": {
        "description": "Whether the instance and its database work: `ok` when it takes work (`ready`) and its session to the database is up, and nothing else: not its name, version or environment, which `GET /api/instance` tells behind the\nlogin. It answers 200 whenever it answers at all, while the instance starts too (`starting`), so read the body:\nfor a load balancer use `GET /api/ready`, for a liveness probe `GET /livez`. It needs no login. The session is\nthe database's answer: the call asks nothing of the database, and updates the `houradvantage_database_up` metric.",
        "operationId": "health",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "ok": true,
                  "ready": true
                },
                "schema": {
                  "$ref": "#/components/schemas/Alive"
                }
              }
            },
            "description": "Whether the instance works."
          }
        },
        "security": [
          {}
        ],
        "summary": "Check health",
        "tags": [
          "probes"
        ]
      }
    },
    "/api/instance": {
      "get": {
        "description": "Which instance answers: its name, version, time zone database, whether it takes work and its database answers,\nand the cluster's environment and whether it is production. `hourctl` asks it for `hourctl status` and for the\nenvironment it names before a change. It reads the database session, as health does. A token scoped to a tenant is told\nwhether this is production and the environment, and not the instance, the version or the time zone database.",
        "operationId": "instance",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "database": true,
                  "environment": "production",
                  "instance": "gw-1",
                  "ok": true,
                  "production": true,
                  "ready": true,
                  "tzdb": "2026a",
                  "version": "0.1.0"
                },
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            },
            "description": "The instance."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get the instance",
        "tags": [
          "instance"
        ]
      }
    },
    "/api/logs": {
      "get": {
        "description": "What the gateway logs, and how the instance that answers writes its log lines. The log goes to standard output:\nas text when that is a terminal, else as one JSON object per line for a log collector. `RUST_LOG`, when set,\ndecides the level an instance starts with instead of the stored one; `level` is the one the instance that answers\nuses.",
        "operationId": "logs",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "format": "json",
                  "level": "info"
                },
                "schema": {
                  "$ref": "#/components/schemas/LogsView"
                }
              }
            },
            "description": "The level in use and the format."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get the log level",
        "tags": [
          "setup"
        ]
      },
      "patch": {
        "description": "Changes what every instance logs, from the moment each one takes the change in, and keeps it: instances started\nlater use it too, unless `RUST_LOG` is set where they start. The format cannot be changed here: it follows where\nthe log goes. Recorded in the audit trail.",
        "operationId": "update_logs",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "level": "warn,houradvantage=debug"
              },
              "schema": {
                "$ref": "#/components/schemas/UpdateLogs"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "format": "json",
                  "level": "warn,houradvantage=debug"
                },
                "schema": {
                  "$ref": "#/components/schemas/LogsView"
                }
              }
            },
            "description": "Changed: the level in use and the format."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown field `format`, expected `level`"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body has a field other than `level`, or `level` is not a level or filter."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the settings were changed elsewhere (another gateway instance) in the meantime; try again"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Change the log level",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/openapi.json": {
      "get": {
        "description": "This document: every admin route, its parameters, bodies, answers and refusals, in OpenAPI 3.1. It is built from\nthe routes the gateway serves, so it always matches the version that answers. Load it into an OpenAPI tool to\nbrowse the API or generate a client. Like every route but the probes, it needs the admin login or an API token\nwhen a login is configured.",
        "operationId": "openapi_json",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "info": {
                    "title": "Hour Advantage admin API",
                    "version": "0.1.0"
                  },
                  "openapi": "3.1.0",
                  "paths": {
                    "/api/health": {
                      "get": {
                        "summary": "Check health",
                        "tags": [
                          "probes"
                        ]
                      }
                    }
                  }
                },
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "The API description, OpenAPI 3.1 (shortened here)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get the API description",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/packages": {
      "get": {
        "description": "Every package line (a package name with a major.minor version, such as\n`zk-push@3.4`): the revision active for it, how many revisions of the\npackage are kept, and what this instance runs of it. A line pushed and\nnever activated has no `active`; a line this instance runs from a\nfolder (`hourd dev`) and never pushed has `revisions` 0.",
        "operationId": "packages",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "active": {
                      "activated_at": "2026-01-15T08:00:00Z",
                      "activated_by": "admin",
                      "hash": "sha256:5c2d8f0e9a7b6c4d3e2f1a0b9c8d7e6f0a1b2c3d4e5f60718293a4b5c6d7e8f9",
                      "revision": 7,
                      "version": "3.4.0"
                    },
                    "line": "zk-push@3.4",
                    "name": "zk-push",
                    "revisions": 7,
                    "running": {
                      "id": "zk-push@3.4.0",
                      "revision": 7
                    }
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/PackageLine"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every package line, in line order."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List package lines",
        "tags": [
          "packages"
        ]
      },
      "post": {
        "description": "Takes a bundle built with `hourctl pkg build` (a .tar.gz of at most\n16 MiB, packed and unpacked, and 2048 files) and checks it as it was\nbuilt: its files and hash, the host API, the Lua compiled, every\ndeclaration, and its scenarios, which are run on this instance and\nmust all pass. It is then kept as its package's next revision, never to\nchange. Nothing is put into use until the revision is activated.\n\nThe same bundle pushed again is the revision it was (200, `new` false).\nWith `activate=true` the revision is also activated, as\n`POST /api/packages/{name}/revisions/{revision}/activate` does; when\nthat is refused, the revision stays kept and the answer is the refusal.\nThe change is added to the audit trail.",
        "operationId": "push",
        "parameters": [
          {
            "description": "`true` makes it the active revision of its line at once, as\nactivating it does (for development: push, activate, try). False\nunless given.",
            "example": true,
            "in": "query",
            "name": "activate",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/gzip": {
              "schema": {
                "items": {
                  "format": "int32",
                  "minimum": 0,
                  "type": "integer"
                },
                "type": "array"
              }
            }
          },
          "description": "The bundle (.tar.gz).",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "hash": "sha256:5c2d8f0e9a7b6c4d3e2f1a0b9c8d7e6f0a1b2c3d4e5f60718293a4b5c6d7e8f9",
                  "host_api": 2,
                  "line": "zk-push@3.4",
                  "name": "zk-push",
                  "new": false,
                  "pushed_at": "2026-01-15T08:00:00Z",
                  "pushed_by": "admin",
                  "revision": 7,
                  "scenarios": 12,
                  "size": 48213,
                  "version": "3.4.0"
                },
                "schema": {
                  "$ref": "#/components/schemas/Pushed"
                }
              }
            },
            "description": "Pushed before: the revision it was."
          },
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "activated": {
                    "changed": true,
                    "changes": [
                      "zk-push@3.4 revision 8 (3.4.1) active",
                      "package 'zk-push@3.4.1' added",
                      "package 'zk-push@3.4.0' removed",
                      "endpoint 'office' now uses zk-push@3.4.1"
                    ],
                    "line": "zk-push@3.4",
                    "name": "zk-push",
                    "revision": 8,
                    "version": "3.4.1"
                  },
                  "hash": "sha256:5c2d8f0e9a7b6c4d3e2f1a0b9c8d7e6f0a1b2c3d4e5f60718293a4b5c6d7e8f9",
                  "host_api": 2,
                  "line": "zk-push@3.4",
                  "name": "zk-push",
                  "new": true,
                  "pushed_at": "2026-01-15T08:00:00Z",
                  "pushed_by": "admin",
                  "revision": 8,
                  "scenarios": 12,
                  "size": 48213,
                  "version": "3.4.1"
                },
                "schema": {
                  "$ref": "#/components/schemas/Pushed"
                }
              }
            },
            "description": "Kept as a new revision."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "1 of its scenarios failed, so it is not kept: tests/door.toml: action failed: this device does not take 'open_door'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Refused: not a bundle, a bundle too large, a host API this build does not run, Lua that does not compile, a declaration that is wrong, or a scenario that fails; with `activate`, an activation refused as activating refuses it."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "package zk-push has no revision 8"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "With `activate`: the revision went in the meantime."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "package zk-push@3.4.1 cannot be activated: it requires secret 'push_token' ([requires] in its package.toml), which is not set; set them first (`hourctl var set`, `hourctl secret set`, for the tenant or with --package zk-push)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "With `activate`: the package requires a var or secret this cluster does not have."
          },
          "413": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the request is too large"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is larger than 16 MiB."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Push a package bundle",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/packages/shared": {
      "get": {
        "description": "Every published version of every shared package (each version is a\nline of its own, `overtime@2.3.1`), revisions pushed and never\nactivated, and what this instance runs.",
        "operationId": "shared_packages",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "active": {
                      "activated_at": "2026-10-07T08:00:00Z",
                      "activated_by": "builder",
                      "hash": "sha256:9f2c...",
                      "revision": 4,
                      "version": "2.3.1"
                    },
                    "line": "overtime@2.3.1",
                    "name": "overtime",
                    "revisions": 4,
                    "running": {
                      "id": "overtime@2.3.1",
                      "revision": 4
                    }
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/PackageLine"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The shared package lines, in line order."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List the shared packages",
        "tags": [
          "packages"
        ]
      },
      "post": {
        "description": "Takes a bundle of a policy package built with `hourctl pkg build`,\nchecks it as `POST /api/packages` checks a bundle, runs its scenarios\non this instance and keeps it as the shared package's next revision.\nOne whose scenarios fail is kept as a failed revision, with what failed\n(`GET /api/packages/shared/{name}` shows it), and refused: it is never\nactivated, and no tenant sees a change. A version that is published\n(activated) never changes: other content under it is refused. With\n`activate=true` the revision is also published, as activating it does.\nThe change is added to the audit trail.",
        "operationId": "shared_push",
        "parameters": [
          {
            "description": "`true` makes it the active revision of its line at once, as\nactivating it does (for development: push, activate, try). False\nunless given.",
            "example": true,
            "in": "query",
            "name": "activate",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/gzip": {
              "schema": {
                "items": {
                  "format": "int32",
                  "minimum": 0,
                  "type": "integer"
                },
                "type": "array"
              }
            }
          },
          "description": "The bundle (.tar.gz).",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "hash": "sha256:9f2c...",
                  "host_api": 2,
                  "line": "overtime@2.3.1",
                  "name": "overtime",
                  "new": false,
                  "pushed_at": "2026-10-07T08:00:00Z",
                  "pushed_by": "builder",
                  "revision": 4,
                  "scenarios": 3,
                  "size": 1201,
                  "version": "2.3.1"
                },
                "schema": {
                  "$ref": "#/components/schemas/Pushed"
                }
              }
            },
            "description": "Pushed before: the revision it was."
          },
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "hash": "sha256:9f2c...",
                  "host_api": 2,
                  "line": "overtime@2.4.0",
                  "name": "overtime",
                  "new": true,
                  "pushed_at": "2026-10-07T08:00:00Z",
                  "pushed_by": "builder",
                  "revision": 5,
                  "scenarios": 3,
                  "size": 1201,
                  "version": "2.4.0"
                },
                "schema": {
                  "$ref": "#/components/schemas/Pushed"
                }
              }
            },
            "description": "Kept as a new revision."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "1 of its scenarios failed, so it is kept as revision 5 (failed) and never activated: tests/weekly.toml: expected 'route' to pick payroll"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Refused: not a bundle, a protocol package, Lua that does not compile, a hook that is not one, other content under a published version, or a scenario that fails (the revision is kept as failed)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Push a shared package",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/packages/shared/{name}": {
      "get": {
        "description": "Every revision kept (a failed one with what failed), each published\nversion with what every instance runs of it, and the catalog of what\nthis instance runs: its manifest and its hooks.",
        "operationId": "shared_package",
        "parameters": [
          {
            "description": "The shared package's name.",
            "example": "overtime",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "catalog": [],
                  "lines": [
                    {
                      "activated_at": "2026-10-07T08:00:00Z",
                      "activated_by": "builder",
                      "hash": "sha256:9f2c...",
                      "instances": [
                        {
                          "error": null,
                          "instance": "houradvantage-0",
                          "running": 4,
                          "wanted": 4
                        }
                      ],
                      "line": "overtime@2.3.1",
                      "revision": 4
                    }
                  ],
                  "name": "overtime",
                  "revisions": [
                    {
                      "active": true,
                      "hash": "sha256:9f2c...",
                      "host_api": 2,
                      "line": "overtime@2.3.1",
                      "name": "overtime",
                      "pushed_at": "2026-10-07T08:00:00Z",
                      "pushed_by": "builder",
                      "revision": 4,
                      "size": 1201,
                      "version": "2.3.1"
                    },
                    {
                      "active": false,
                      "failed": [
                        "tests/weekly.toml: expected 'route' to pick payroll"
                      ],
                      "hash": "sha256:41ab...",
                      "host_api": 2,
                      "line": "overtime@2.4.0",
                      "name": "overtime",
                      "pushed_at": "2026-10-08T08:00:00Z",
                      "pushed_by": "builder",
                      "revision": 5,
                      "size": 1240,
                      "version": "2.4.0"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PackageDetail"
                }
              }
            },
            "description": "The package: its revisions, its published versions and its catalog."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "no package 'overtime'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no such shared package."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a shared package",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/packages/shared/{name}/revisions/{revision}/activate": {
      "post": {
        "description": "Activates the revision: its version is published, and every tenant\nfollowing its major version whose endpoints name the package runs it\nfrom now on (each such tenant gets `package.updated`, under its source\n`connect`); a tenant pinning another version keeps it. A failed revision\nis never activated, and a version published as one revision is never\npublished as another. The change is added to the audit trail.",
        "operationId": "shared_activate",
        "parameters": [
          {
            "description": "The shared package's name.",
            "example": "overtime",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The revision, counted from 1 in the order pushed.",
            "example": 5,
            "in": "path",
            "name": "revision",
            "required": true,
            "schema": {
              "format": "int32",
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": true,
                  "changes": [
                    "*:overtime@2.4.0 revision 5 (2.4.0) active",
                    "tenant 'acme': overtime 2.3.1 -> 2.4.0"
                  ],
                  "line": "overtime@2.4.0",
                  "name": "overtime",
                  "revision": 5,
                  "version": "2.4.0"
                },
                "schema": {
                  "$ref": "#/components/schemas/Activated"
                }
              }
            },
            "description": "Published: what changed."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Refused: the revision failed its scenarios, its version is published as another revision, or an endpoint would no longer find its policy."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "package overtime has no revision 8"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The package has no such revision."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Publish a revision of a shared package",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/packages/shared/{name}/revisions/{revision}/bundle": {
      "get": {
        "description": "The bundle of a kept revision, byte for byte as it was pushed.",
        "operationId": "shared_bundle",
        "parameters": [
          {
            "description": "The shared package's name.",
            "example": "overtime",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The revision.",
            "example": 5,
            "in": "path",
            "name": "revision",
            "required": true,
            "schema": {
              "format": "int32",
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/gzip": {
                "schema": {
                  "items": {
                    "format": "int32",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The bundle (.tar.gz)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "package overtime has no revision 8"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The package has no such revision."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Download a revision's bundle of a shared package",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/packages/{name}": {
      "get": {
        "description": "One package by name: every revision kept (oldest first, each saying\nwhether it is active), each active line with what every instance runs\nof it, and the full catalog of what this instance runs of the package\n(its manifest, routes, commands, actions, settings and options, every\nparameter typed). An instance that cannot run a line's active revision\nkeeps the one it had and says why in its `error`.",
        "operationId": "package",
        "parameters": [
          {
            "description": "The package's name.",
            "example": "zk-push",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "catalog": [
                    {
                      "actions": [
                        {
                          "command": "open_door",
                          "name": "open_door",
                          "params": [
                            {
                              "description": "Which door, as the device numbers them; default: its only one.",
                              "name": "door",
                              "required": false,
                              "sensitive": false,
                              "type": "string"
                            },
                            {
                              "description": "How long; default: the device's own unlock time.",
                              "name": "seconds",
                              "required": false,
                              "sensitive": false,
                              "type": "integer"
                            }
                          ],
                          "standard": true,
                          "writes": []
                        }
                      ],
                      "commands": [
                        {
                          "description": "Unlocks the door for a moment.",
                          "implements": "open_door",
                          "key": "open_door",
                          "params": [
                            {
                              "description": "Which door, as the device numbers them; default: its only one.",
                              "name": "door",
                              "required": false,
                              "sensitive": false,
                              "type": "string"
                            },
                            {
                              "description": "How long; default: the device's own unlock time.",
                              "max": 60,
                              "min": 1,
                              "name": "seconds",
                              "required": false,
                              "sensitive": false,
                              "type": "integer"
                            }
                          ],
                          "quick": true,
                          "sensitive_result": false,
                          "success": "zero",
                          "title": "Open door",
                          "writes": []
                        }
                      ],
                      "hash": "sha256:5c2d8f0e9a7b6c4d3e2f1a0b9c8d7e6f0a1b2c3d4e5f60718293a4b5c6d7e8f9",
                      "id": "zk-push@3.4.0",
                      "line": "zk-push@3.4",
                      "manifest": {
                        "delivery": "ack",
                        "description": "Push-protocol time clocks over HTTP.",
                        "host_api": 2,
                        "name": "zk-push",
                        "transports": [
                          "http"
                        ],
                        "vendor": "Acme",
                        "version": "3.4.0"
                      },
                      "options": [
                        {
                          "description": "The devices' zone.",
                          "name": "timezone",
                          "required": false,
                          "type": "timezone"
                        }
                      ],
                      "revision": 7,
                      "routes": [
                        {
                          "description": "Punches the device uploads.",
                          "name": "attlog"
                        }
                      ],
                      "settings": [
                        {
                          "access": "rw",
                          "description": "How loud the device speaks, in per cent.",
                          "max": 100.0,
                          "min": 0.0,
                          "name": "volume",
                          "native": "Volume",
                          "needs_reboot": false,
                          "sensitive": false,
                          "standard": "volume",
                          "title": "Volume",
                          "type": "integer"
                        }
                      ]
                    }
                  ],
                  "lines": [
                    {
                      "activated_at": "2026-01-15T08:00:00Z",
                      "activated_by": "admin",
                      "hash": "sha256:5c2d8f0e9a7b6c4d3e2f1a0b9c8d7e6f0a1b2c3d4e5f60718293a4b5c6d7e8f9",
                      "instances": [
                        {
                          "error": null,
                          "instance": "houradvantage-0",
                          "running": 7,
                          "wanted": 7
                        },
                        {
                          "error": null,
                          "instance": "houradvantage-1",
                          "running": 7,
                          "wanted": 7
                        }
                      ],
                      "line": "zk-push@3.4",
                      "revision": 7
                    }
                  ],
                  "name": "zk-push",
                  "revisions": [
                    {
                      "active": true,
                      "hash": "sha256:5c2d8f0e9a7b6c4d3e2f1a0b9c8d7e6f0a1b2c3d4e5f60718293a4b5c6d7e8f9",
                      "host_api": 2,
                      "line": "zk-push@3.4",
                      "name": "zk-push",
                      "pushed_at": "2026-01-15T08:00:00Z",
                      "pushed_by": "admin",
                      "revision": 7,
                      "size": 48213,
                      "version": "3.4.0"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PackageDetail"
                }
              }
            },
            "description": "The package: its revisions, its active lines and its catalog."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "no package 'zk-push'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No revision of the package is kept and this instance runs none of it."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a package",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/packages/{name}/revisions/{revision}/activate": {
      "post": {
        "description": "Makes a kept revision the one every instance runs for its line (its\nname and major.minor version). This instance loads it first and checks\nthat every endpoint served now still finds its package and fits it, and\nthat the cluster has the vars and secrets the package requires; a\nrevision that fails a check is refused and nothing changes. Then each\ninstance loads it and swaps it in without dropping a message: a message\nunder way finishes with the revision it started with.\n\nRolling back is activating an earlier revision. Activating the active\nrevision changes nothing (`changed` false). An instance whose build\ncannot run the revision keeps what it ran and says why\n(`GET /api/packages/{name}`). The change is added to the audit trail.",
        "operationId": "activate",
        "parameters": [
          {
            "description": "The package's name.",
            "example": "zk-push",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The revision, counted per package from 1 in the order pushed.",
            "example": 8,
            "in": "path",
            "name": "revision",
            "required": true,
            "schema": {
              "format": "int32",
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": true,
                  "changes": [
                    "zk-push@3.4 revision 8 (3.4.1) active",
                    "package 'zk-push@3.4.1' added",
                    "package 'zk-push@3.4.0' removed",
                    "endpoint 'office' now uses zk-push@3.4.1"
                  ],
                  "line": "zk-push@3.4",
                  "name": "zk-push",
                  "revision": 8,
                  "version": "3.4.1"
                },
                "schema": {
                  "$ref": "#/components/schemas/Activated"
                }
              }
            },
            "description": "Active: what changed."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "this instance cannot run revision 8 of zk-push: package zk-push@3.4.1 is written for host API 3; this build of Hour Advantage runs host API 1-2: upgrade Hour Advantage to run it"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Refused: this instance cannot run the revision (a host API its build does not run, a bundle that does not load), or an endpoint served now would not be, or would not fit it."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "package zk-push has no revision 8"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The package has no such revision."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "package zk-push@3.4.1 cannot be activated: it requires secret 'push_token' ([requires] in its package.toml), which is not set; set them first (`hourctl var set`, `hourctl secret set`, for the tenant or with --package zk-push)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The package requires a var or secret a tenant using it does not have."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Activate a revision",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/packages/{name}/revisions/{revision}/bundle": {
      "get": {
        "description": "The bundle of a kept revision, byte for byte as it was pushed: pushing\nit to another cluster makes a revision with the same content hash\n(`hourctl promote` does this).",
        "operationId": "bundle",
        "parameters": [
          {
            "description": "The package's name.",
            "example": "zk-push",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The revision, counted per package from 1 in the order pushed.",
            "example": 8,
            "in": "path",
            "name": "revision",
            "required": true,
            "schema": {
              "format": "int32",
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/gzip": {
                "schema": {
                  "items": {
                    "format": "int32",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The bundle (.tar.gz)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "package zk-push has no revision 8"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The package has no such revision."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Download a revision's bundle",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/peers": {
      "get": {
        "description": "The instances running now, as each says every few seconds in the database: where its admin API is reached for\nlive views, when it last said it was alive, the config version it has put into use and why it could not put the\nnewest into use, and what it runs of each package line. Compare each `applied_version` with `config_version` to\nsee whether a change has reached every instance. An instance that stops saying it is alive drops out of the list.",
        "operationId": "peers",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "config_version": 42,
                  "environment": "production",
                  "instance": "gw-1",
                  "peers": [
                    {
                      "address": "http://192.0.2.21:9090",
                      "applied_version": 42,
                      "config_error": null,
                      "instance": "gw-1",
                      "packages": {
                        "zk-push@3.4": {
                          "running": 3,
                          "wanted": 3
                        }
                      },
                      "seen_at": "2026-01-15T14:00:00Z"
                    },
                    {
                      "address": "http://192.0.2.22:9090",
                      "applied_version": 41,
                      "config_error": null,
                      "instance": "gw-2",
                      "packages": {
                        "zk-push@3.4": {
                          "running": 3,
                          "wanted": 3
                        }
                      },
                      "seen_at": "2026-01-15T13:59:58Z"
                    }
                  ],
                  "production": true
                },
                "schema": {
                  "$ref": "#/components/schemas/PeersView"
                }
              }
            },
            "description": "The instances running now."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List the instances",
        "tags": [
          "instance"
        ]
      }
    },
    "/api/ready": {
      "get": {
        "description": "Whether the instance takes work, for a load balancer's health check: 200 while it does, 503 with why while it\ndoes not. It is not ready while it starts or shuts down, while an http listener not stopped by hand does not have\nits port, or when it has known for more than 5 seconds that it is behind the config version and could not catch\nup. A database it cannot reach does not make it not ready, as every instance shares the database: `database` says\nwhether it answered. It answers from memory, and needs no login.",
        "operationId": "ready",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "config_version": 42,
                  "database": true,
                  "ready": true,
                  "why": []
                },
                "schema": {
                  "$ref": "#/components/schemas/Ready"
                }
              }
            },
            "description": "It takes work."
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "config_version": 42,
                  "database": true,
                  "ready": false,
                  "why": [
                    "listener 'public' does not have its port: listener 'public' binding 0.0.0.0:8080: Address already in use (os error 98)"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/Ready"
                }
              }
            },
            "description": "It does not take work: it is starting or shutting down, an http listener does not have its port, or it is behind the config version. `why` says which."
          }
        },
        "security": [
          {}
        ],
        "summary": "Check readiness",
        "tags": [
          "probes"
        ]
      }
    },
    "/api/scenarios/run": {
      "post": {
        "description": "Runs the scenarios (`tests/*.toml`) of the packages the instance that answers runs, as their bundles carry them,\nin that instance, against fresh gateways that share nothing with the live one: nothing is sent to devices or\nsinks, and nothing is stored. The same runner as `hourctl pkg test`. One run at a time per instance; it answers\nwhen every scenario has run. `passed` is true when no scenario failed. Without a filter, `coverage` says which\nroutes, commands, standard actions and sync declarations of each package a passing scenario exercises. Send `{}`\nto run everything. Not recorded in the audit trail.",
        "operationId": "run_scenarios",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "filter": "zk-push"
              },
              "schema": {
                "$ref": "#/components/schemas/RunScenarios"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "coverage": [],
                  "failed": 0,
                  "passed": true,
                  "reports": [
                    {
                      "actions": [],
                      "commands": [],
                      "description": "A punch is stored as a punch event",
                      "failures": [],
                      "file": "tests/attlog.toml",
                      "package": "zk-push@3.4.0",
                      "routes": [
                        "attlog"
                      ],
                      "steps": 3,
                      "sync_domains": []
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/ScenarioRun"
                }
              }
            },
            "description": "What each scenario did, and coverage when no filter was given."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "a scenario run is already in progress"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A run is already in progress on this instance."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Run package scenarios",
        "tags": [
          "instance"
        ]
      }
    },
    "/api/settings": {
      "get": {
        "description": "The settings every instance uses besides listeners, endpoints, sinks and sync groups: the limits on what devices\nmay send, how many days things are kept, and the proxies trusted in front of the device listeners.",
        "operationId": "settings",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "audit_retention_days": null,
                  "limits": {
                    "max_body_bytes": 4194304,
                    "max_pending_devices": 100,
                    "traffic_body_bytes": 16384
                  },
                  "retention_days": 30,
                  "trusted_proxies": []
                },
                "schema": {
                  "$ref": "#/components/schemas/SettingsView"
                }
              }
            },
            "description": "The settings in use."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get the settings",
        "tags": [
          "setup"
        ]
      },
      "patch": {
        "description": "Changes the settings on every instance. The body is a JSON merge patch (RFC 7396) of what `GET /api/settings`\nshows: send only what changes. `limits` merges field by field; null puts a limit back to its default. Every\nfield is checked before anything changes: `retention_days`, `audit_retention_days` (when set) and `max_body_bytes`\nmust be greater than 0, and each\ntrusted proxy must be an address or a CIDR range, and each of `tenant_destinations` an address, a CIDR range or a\nhost name. Emptying `trusted_proxies` while a listener takes PROXY protocol headers is refused. Recorded in the\naudit trail.\n\n`retention_days` decides how long events are kept once every sink has taken them: lowering it removes those\nsooner, and never an event a sink has not taken, which is kept until the sink takes it or is moved past it.\n\n`audit_retention_days` decides how long audit entries are kept. Unset (null removes it), they are kept for ever;\nset, entries older than that are removed; `retention_days` never removes them.",
        "operationId": "update_settings",
        "parameters": [
          {
            "description": "Has no effect: lowering `retention_days` never removes events sinks have not taken. Taken so that callers sending it keep working.",
            "example": true,
            "in": "query",
            "name": "force",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "limits": {
                  "traffic_body_bytes": 0
                },
                "retention_days": 90
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "description": "A JSON merge patch of the settings: any of `limits`, `retention_days`, `audit_retention_days`, `trusted_proxies`, `tenant_destinations`.",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "limits": {
                    "max_body_bytes": 4194304,
                    "max_pending_devices": 100,
                    "traffic_body_bytes": 0
                  },
                  "retention_days": 90,
                  "trusted_proxies": []
                },
                "schema": {
                  "$ref": "#/components/schemas/SettingsView"
                }
              }
            },
            "description": "Changed: the settings as they are now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown setting 'colour'; there are limits, retention_days, audit_retention_days, trusted_proxies and tenant_destinations"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a JSON object, names a setting there is not (here or in `limits`), or leaves a setting that is not valid."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the settings were changed elsewhere (another gateway instance) in the meantime; try again"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Change the settings",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/sinks": {
      "get": {
        "description": "The install-level sinks' route, as the tenant route `/api/tenants/{tenant}/sinks` is a tenant's: an install-level sink is configured with the install and is sent every tenant's events (and the sources it names), where a tenant's sink is sent the events of its own endpoints and sync groups that name it, and of the sources it names.\n\nEvery sink: where it sends events and which ones. The signing secret is shown only as `secret_set`. `GET /api/tenants/{tenant}/sinks/status` shows how each one's deliveries are going.",
        "operationId": "list_sinks_of_install",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "events": [
                      "punch"
                    ],
                    "id": "payroll",
                    "secret_set": true,
                    "type": "webhook",
                    "url": "https://example.com/houradvantage"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SinkView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "All of them."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List sinks",
        "tags": [
          "setup"
        ]
      },
      "post": {
        "description": "The install-level sinks' route, as the tenant route `/api/tenants/{tenant}/sinks` is a tenant's: an install-level sink is configured with the install and is sent every tenant's events (and the sources it names), where a tenant's sink is sent the events of its own endpoints and sync groups that name it, and of the sources it names.\n\nAdds a sink: a `webhook` that the events of the endpoints and sync groups naming it in their `sinks` are posted to, as `{\"events\": [...]}`, in order, each batch until it answers 2xx. With `secret`, each post is signed: `x-houradvantage-timestamp` carries the Unix time in seconds and `x-houradvantage-signature` carries `v1=` and the hex HMAC-SHA256, keyed with the secret, of the timestamp, a '.', and the body. `events` limits it to those event types; empty or absent, it is sent the default set: every type but the detailed ones sent only when named (the Events reference lists them). A sink is sent nothing until an endpoint or a sync group names it (`PATCH /api/tenants/{tenant}/endpoints/{id}`); it then starts with the events stored from that moment on. Recorded in the audit trail, the secret left out.",
        "operationId": "create_sink_of_install",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "events": [
                  "punch"
                ],
                "id": "payroll",
                "secret": "a-long-random-string",
                "type": "webhook",
                "url": "https://example.com/houradvantage"
              },
              "schema": {
                "$ref": "#/components/schemas/SinkConfig"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "punch"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://example.com/houradvantage"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "Added: as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "webhook sink 'payroll' needs url"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a sink (an unknown field, a missing `id` or `type`), or the sink is not valid: an id that is not 1-64 letters, digits, '-' or '_' (or is `status`); a type other than `webhook`; a missing `url`, or one that is not http or https."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sink 'payroll' already exists"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A sink with that id exists, or the settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Add a sink",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/sinks/status": {
      "get": {
        "description": "The install-level sinks' route, as the tenant route `/api/tenants/{tenant}/sinks/status` is a tenant's: an install-level sink is configured with the install and is sent every tenant's events (and the sources it names), where a tenant's sink is sent the events of its own endpoints and sync groups that name it, and of the sources it names.\n\nHow each sink that an endpoint or a sync group sends events to is getting on: how many events wait for it, since\nwhen, when it last took some, whether it is refusing them and why, and where it is in the events. A sink nothing\nsends events to is not listed. One sink is delivered to by one instance at a time; this\nreads what that instance has recorded, so any instance gives the same answer. A sink that refuses is tried again\nuntil it takes the events, however long that takes: nothing is skipped unless you move it (`POST\n/api/tenants/{tenant}/sinks/{id}/position`). A sink whose state cannot be read from the\ndatabase right now is left out of the answer.",
        "operationId": "sink_status_of_install",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "behind": 12,
                    "delivered_at": "2026-01-15T07:59:30Z",
                    "dropped": null,
                    "error": "sink 'payroll': webhook returned 503 Service Unavailable",
                    "failing_since": "2026-01-15T08:00:05Z",
                    "oldest_waiting_at": "2026-01-15T08:00:00Z",
                    "position": 4180,
                    "sink": "payroll"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SinkStatus"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every sink events are sent to, whose state could be read."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List sink deliveries",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/sinks/{id}": {
      "delete": {
        "description": "The install-level sinks' route, as the tenant route `/api/tenants/{tenant}/sinks/{id}` is a tenant's: an install-level sink is configured with the install and is sent every tenant's events (and the sources it names), where a tenant's sink is sent the events of its own endpoints and sync groups that name it, and of the sources it names.\n\nRemoves a sink: nothing more is sent to it, and its place in the events goes with it: a sink made again with its id starts as a new sink does, with the events stored from then on. A sink that an endpoint or a sync group names cannot be removed: take it off their `sinks` first. Recorded in the audit trail.",
        "operationId": "delete_sink_of_install",
        "parameters": [
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "punch"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://example.com/houradvantage"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "Removed: as it was."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sink 'payroll' is used by endpoint 'office'; take it off its endpoints first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "An endpoint or a sync group names it, or the settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Remove a sink",
        "tags": [
          "setup"
        ]
      },
      "get": {
        "description": "The install-level sinks' route, as the tenant route `/api/tenants/{tenant}/sinks/{id}` is a tenant's: an install-level sink is configured with the install and is sent every tenant's events (and the sources it names), where a tenant's sink is sent the events of its own endpoints and sync groups that name it, and of the sources it names.\n\nOne sink, the secret shown only as `secret_set`.",
        "operationId": "show_sink_of_install",
        "parameters": [
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "punch"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://example.com/houradvantage"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "As it is now."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a sink",
        "tags": [
          "setup"
        ]
      },
      "patch": {
        "description": "The install-level sinks' route, as the tenant route `/api/tenants/{tenant}/sinks/{id}` is a tenant's: an install-level sink is configured with the install and is sent every tenant's events (and the sources it names), where a tenant's sink is sent the events of its own endpoints and sync groups that name it, and of the sources it names.\n\nChanges a sink's settings. Its deliveries restart with the new settings on the instance delivering to it; a batch under way may be sent again. Where it is in the events does not change. Set `secret` to null to stop signing. Recorded in the audit trail, the secret left out.",
        "operationId": "update_sink_of_install",
        "parameters": [
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "events": [
                  "punch",
                  "user"
                ]
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "description": "A JSON merge patch (RFC 7396) of its settings: the fields to change. Objects merge, null removes a field (back to its default), arrays and values replace. `id` may only repeat the id it has.",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "punch",
                    "user"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://example.com/houradvantage"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "Changed: as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sink 'payroll': url must be http or https"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a JSON object, it changes the id, or the sink is not valid once patched (see `POST /api/tenants/{tenant}/sinks`)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the settings were changed elsewhere (another gateway instance) in the meantime; try again"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Change a sink",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/sinks/{id}/position": {
      "post": {
        "description": "The install-level sinks' route, as the tenant route `/api/tenants/{tenant}/sinks/{id}/position` is a tenant's: an install-level sink is configured with the install and is sent every tenant's events (and the sources it names), where a tenant's sink is sent the events of its own endpoints and sync groups that name it, and of the sources it names.\n\nMoves a sink along the events by hand: ahead, to skip what it refuses or no longer wants, or back, to have it\nsent events again from an earlier place. `{\"seq\": n}` makes the next event it is sent the first after `n`;\n`{\"seq\": \"latest\"}` skips every event stored so far. It clears `failing_since`. The instance delivering to it\ncarries on from the new place; a batch it was sending may still arrive. Recorded in the audit trail, saying from\nwhere to where, and told to the sinks with a `sink.moved` event: moving a sink ahead is the only way it loses\nevents it has not taken.",
        "operationId": "move_sink_of_install",
        "parameters": [
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "seq": "latest"
              },
              "schema": {
                "$ref": "#/components/schemas/PositionBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "from": 3950,
                  "sink": "payroll",
                  "to": 4181
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkMovedView"
                }
              }
            },
            "description": "Moved: from where to where."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no event 5000 yet: the newest is 4181"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`seq` is neither a sequence number of 0 or more nor \"latest\", or it is past the newest event."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id that an endpoint or a sync group sends events to."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Move a sink",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants": {
      "get": {
        "description": "Every tenant of the install: its id, name, status (`active`, `suspended` or `stopped`), what other systems know it\nby, its metadata and its own limits. A tenant's listeners, endpoints, sinks, sync groups, devices, jobs, vars and\nsecrets are under `/api/tenants/{tenant}/...`.",
        "operationId": "list_tenants",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "external_ids": {
                      "crm": "C-1042"
                    },
                    "id": "acme",
                    "limits": {
                      "devices": 50
                    },
                    "metadata": {
                      "region": "midwest"
                    },
                    "name": "Acme Manufacturing",
                    "status": "active"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/TenantConfig"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every tenant."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List tenants",
        "tags": [
          "tenants"
        ]
      },
      "post": {
        "description": "Adds a tenant: whoever operates clocks through this install (a dealer, a vendor, an employer). It starts with\nnothing: give it listeners, endpoints, sinks and sync groups under `/api/tenants/{tenant}/...` (or `hourctl apply\n--tenant <id>`), and a token of its own (`POST /api/tokens` with `scope` `connect:<id>`) for whoever runs it.\n`limits` overrides the install's defaults (`limits.tenants` in `PATCH /api/settings`). Recorded in the audit trail.",
        "operationId": "create_tenant",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "id": "acme",
                "name": "Acme Manufacturing"
              },
              "schema": {
                "$ref": "#/components/schemas/TenantConfig"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "external_ids": {
                    "crm": "C-1042"
                  },
                  "id": "acme",
                  "limits": {
                    "devices": 50
                  },
                  "metadata": {
                    "region": "midwest"
                  },
                  "name": "Acme Manufacturing",
                  "status": "active"
                },
                "schema": {
                  "$ref": "#/components/schemas/TenantConfig"
                }
              }
            },
            "description": "Added: the tenant."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "tenant id 'acme co' must be 1-64 characters of letters, digits, '-' or '_'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a tenant (an unknown field, no `id`), or it is not valid: an id that is not 1-64 letters, digits, '-' or '_'; external ids or metadata over their limits."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "tenant 'acme' already exists"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A tenant with that id exists, or the settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Add a tenant",
        "tags": [
          "tenants"
        ]
      }
    },
    "/api/tenants/{tenant}": {
      "delete": {
        "description": "Deletes a tenant and everything Connect keeps of it, on every instance: it is stopped first (nothing of it runs\nfrom then on), then its devices with their commands, actions and failures, its events, its sync groups' data, its\njobs, vars and secrets and its sinks' places are removed, and then its listeners (which stop), endpoints, sinks and\nsync groups and the tenant itself. Every token scoped to it (`connect:<tenant>`) is revoked first, as `DELETE\n/api/tokens/{name}` revokes one: a tenant made again with the same id is reached by none of them. It cannot be\nundone. Events that install-level sinks have not taken yet are removed with it: the deletion is refused (409,\nnaming the sinks and how many events) unless `force=true`. Recorded in the audit trail.",
        "operationId": "delete_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Delete although install-level sinks have not taken all of its\nevents: they are lost.",
            "in": "query",
            "name": "force",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "removed": {
                    "devices": 12,
                    "events": 48210,
                    "jobs": 2,
                    "rows": 340
                  },
                  "revoked_tokens": [
                    "acme-ops"
                  ],
                  "tenant": {
                    "external_ids": {
                      "crm": "C-1042"
                    },
                    "id": "acme",
                    "limits": {
                      "devices": 50
                    },
                    "metadata": {
                      "region": "midwest"
                    },
                    "name": "Acme Manufacturing",
                    "status": "active"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                }
              }
            },
            "description": "Deleted: the tenant as it was, and what was removed."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown tenant 'acme'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no tenant with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the default tenant cannot be deleted: suspend or stop it"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "It is the default tenant, which the install keeps; or install-level sinks have not taken some of its events (named, with how many), which deleting it removes for good: `force=true` deletes anyway; or the settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Delete a tenant",
        "tags": [
          "tenants"
        ]
      },
      "get": {
        "description": "One tenant (see `GET /api/tenants`).",
        "operationId": "show_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "external_ids": {
                    "crm": "C-1042"
                  },
                  "id": "acme",
                  "limits": {
                    "devices": 50
                  },
                  "metadata": {
                    "region": "midwest"
                  },
                  "name": "Acme Manufacturing",
                  "status": "active"
                },
                "schema": {
                  "$ref": "#/components/schemas/TenantConfig"
                }
              }
            },
            "description": "The tenant."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown tenant 'acme'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no tenant with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a tenant",
        "tags": [
          "tenants"
        ]
      },
      "patch": {
        "description": "Changes a tenant's name, external ids, metadata, limits or status, on every instance. Setting `status` to\n`suspended` or `stopped` stops everything Connect does for the tenant: its devices' requests are answered 503 (and\ntaken in by nobody, so a clock keeps what it has and sends it again), no command goes out to them, and none of its\njobs, sync groups or sinks runs; `active` resumes it all. Recorded in the audit trail.",
        "operationId": "update_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "status": "suspended"
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "description": "A JSON merge patch (RFC 7396) of the tenant: the fields to change. `id` may only repeat the id it has.",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "external_ids": {
                    "crm": "C-1042"
                  },
                  "id": "acme",
                  "limits": {
                    "devices": 50
                  },
                  "metadata": {
                    "region": "midwest"
                  },
                  "name": "Acme Manufacturing",
                  "status": "suspended"
                },
                "schema": {
                  "$ref": "#/components/schemas/TenantConfig"
                }
              }
            },
            "description": "Changed: the tenant as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the id cannot be changed; add a new one and remove this one"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a JSON object, it changes the id, or the tenant is not valid once patched."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown tenant 'acme'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no tenant with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the settings were changed elsewhere (another gateway instance) in the meantime; try again"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Change a tenant",
        "tags": [
          "tenants"
        ]
      }
    },
    "/api/tenants/{tenant}/actions": {
      "get": {
        "description": "The standard actions: device operations that mean the same on any\ndevice, whatever its maker, each with its parameters and the sync\ndomains it writes. A package offers those it can do; a device's own are\nthose its package offers and the device takes (`available_actions` on\n`GET /api/tenants/{tenant}/devices/{endpoint}/{device}`, or its catalog). The list is\npart of the gateway: it changes only with the gateway's version.",
        "operationId": "catalog",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "description": "Sets the device's clock: to the given instant, or to now.",
                    "domain": "device",
                    "name": "sync_time",
                    "params": [
                      {
                        "description": "The time to set; default: when the device is given it.",
                        "name": "time",
                        "required": false,
                        "sensitive": false,
                        "type": "rfc3339"
                      }
                    ],
                    "title": "Set the device's clock",
                    "writes": []
                  },
                  {
                    "description": "Unlocks a door for a moment.",
                    "domain": "device",
                    "name": "open_door",
                    "params": [
                      {
                        "description": "Which door, as the device numbers them; default: its only one.",
                        "name": "door",
                        "required": false,
                        "sensitive": false,
                        "type": "string"
                      },
                      {
                        "description": "How long; default: the device's own unlock time.",
                        "name": "seconds",
                        "required": false,
                        "sensitive": false,
                        "type": "integer"
                      }
                    ],
                    "title": "Open door",
                    "writes": []
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/StandardAction"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every standard action."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List the standard actions",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/tenants/{tenant}/devices": {
      "get": {
        "description": "The device register, a page at a time, in endpoint then device order,\neach device with its own labels. To read the next page, send `after`\nset to the last device of the page you have (`<endpoint>/<device>`); a\npage shorter than `limit` is the last. `select` keeps the devices a\nselector picks by their labels: the endpoint's, with the device's own\nover them, as a sync group's placement and a job's targets read them.\n\nWhen each device was last seen (and from where), when it was last\nrefused for its key, and what was counted of its messages (`health`)\nare as every running instance knows them: the other instances are\nasked, and the answer waits for each until it answers or its session\nends. An instance that ended without answering is named, with why, in the\n`X-Instances-Unanswered` header, and what the database holds is shown for\nwhat only it knew. A device that is held carries `held`.",
        "operationId": "devices",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only the devices of this endpoint.",
            "example": "office",
            "in": "query",
            "name": "endpoint",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only the devices with this status: `pending`, `allowed` or `blocked`.",
            "example": "allowed",
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/DeviceStatus"
            }
          },
          {
            "description": "How many devices at most: 1 to 10000, 1000 unless given.",
            "example": 1000,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "maximum": 10000,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "description": "The last device of the page before, as `<endpoint>/<device>`: the\npage starts after it. Leave it out for the first page.",
            "example": "office/CG0001",
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only the devices this selector picks by their labels (their\nendpoint's, with their own over them): `region ^= west/nevada and\nkind != kiosk` (`docs/selectors.md`).",
            "example": "region ^= west/nevada and kind != kiosk",
            "in": "query",
            "name": "select",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "device": "CG0001",
                    "endpoint": "office",
                    "first_seen": "2026-01-15T08:00:00Z",
                    "health": {
                      "errors": 1,
                      "last_error": {
                        "at": "2026-01-15T07:58:00Z",
                        "reason": "line 3: '2026-13-01 08:00:00' is not a time",
                        "route": "attlog"
                      },
                      "messages": 1520
                    },
                    "id": 42,
                    "info": {
                      "firmware": "3.4.0",
                      "punches": 1830,
                      "users": 25
                    },
                    "key": "active",
                    "key_presented": "registered",
                    "key_refused_at": null,
                    "labels": {
                      "site": "north"
                    },
                    "last_seen": "2026-01-15T08:05:00Z",
                    "params": {},
                    "remote_ip": "192.0.2.10",
                    "status": "allowed"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/LabelledDevice"
                  },
                  "type": "array"
                }
              }
            },
            "description": "At most `limit` devices, each with its own labels.",
            "headers": {
              "X-Instances-Unanswered": {
                "description": "The instances that ended without answering when devices were last seen, `name (why)`, comma separated: present only when there were any.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "limit must be 1 to 10000"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`limit` is 0 or more than 10000, or `after` is not `<endpoint>/<device>`, or `select` is not a selector (said at the column of the mistake). A `status` that is not `pending`, `allowed` or `blocked` is refused with 400 and a plain-text reason."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List devices",
        "tags": [
          "devices"
        ]
      },
      "post": {
        "description": "Adds a device to the register before it calls in, so it is let in (or\nrefused) on its first message as its `status` says, whatever its\nendpoint's `new_devices` says.\n\nWith `key`, the key is kept as the device's new key and the package is\nasked for the commands that give it to the device: they are queued and\nreturned in `commands`. The key is enforced once the device presents it.\n\nThe change is added to the audit trail.",
        "operationId": "register_device",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "device": "CG0002",
                "endpoint": "office",
                "status": "allowed"
              },
              "schema": {
                "$ref": "#/components/schemas/RegisterDevice"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "commands": [],
                  "device": {
                    "device": "CG0002",
                    "endpoint": "office",
                    "first_seen": null,
                    "health": {
                      "errors": 0,
                      "messages": 0
                    },
                    "id": 43,
                    "info": {},
                    "key": "none",
                    "key_presented": "none",
                    "key_refused_at": null,
                    "labels": {},
                    "last_seen": null,
                    "params": {},
                    "remote_ip": "",
                    "status": "allowed"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/DeviceChanged"
                }
              }
            },
            "description": "Registered: the device, with its own labels, and the commands queued to give it its key (none without `key`)."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "device 'CG0002' is already known on endpoint 'office'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The endpoint is not known, the device id is not acceptable, the device is registered already, or the key is not acceptable or the package cannot build the commands that give it. A body that is not JSON is refused with 400, and one with an unknown field or a value of the wrong type with 422."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Register a device",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/tenants/{tenant}/devices/{endpoint}/{device}": {
      "delete": {
        "description": "Removes a device from the register with everything kept for it: its\nrecord (with what its package keeps for it, such as cursors), its\ncommands, its actions, its labels and its hold. Should it call in again\nit is a new device, let in or not as its endpoint's `new_devices` says.\n\nThe change is added to the audit trail.",
        "operationId": "remove_device",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "204": {
            "description": "Forgotten."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "device not found"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The endpoint has no such device."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Forget a device",
        "tags": [
          "devices"
        ]
      },
      "get": {
        "description": "One device, with its keys (the only place they are shown), the\ncommands its package offers to be sent by name (`available_commands`:\nevery command but those only the package's own actions use) and the\nactions the device takes (`available_actions`: the package's actions\nthat, as the package judges from what the device reported, it takes).\n\nWhen it was last seen, and what was counted of its messages (`health`),\nare as every running instance knows them (an instance that ended without\nanswering is named in the `X-Instances-Unanswered` header). A device whose endpoint is\nnot configured shows no commands or actions.",
        "operationId": "device",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "available_actions": [
                    "get_info",
                    "open_door",
                    "reboot",
                    "sync_time",
                    "upsert_user"
                  ],
                  "available_commands": [
                    {
                      "description": "Unlocks the door for a moment.",
                      "implements": "open_door",
                      "key": "open_door",
                      "params": [
                        {
                          "description": "Which door, as the device numbers them; default: its only one.",
                          "name": "door",
                          "required": false,
                          "sensitive": false,
                          "type": "string"
                        },
                        {
                          "description": "How long; default: the device's own unlock time.",
                          "max": 60,
                          "min": 1,
                          "name": "seconds",
                          "required": false,
                          "sensitive": false,
                          "type": "integer"
                        }
                      ],
                      "quick": true,
                      "sensitive_result": false,
                      "success": "zero",
                      "title": "Open door",
                      "writes": []
                    }
                  ],
                  "commands": {
                    "in_hand": 2,
                    "unanswered": 0,
                    "waiting": 0
                  },
                  "device": {
                    "device": "CG0001",
                    "endpoint": "office",
                    "first_seen": "2026-01-15T08:00:00Z",
                    "health": {
                      "errors": 1,
                      "last_error": {
                        "at": "2026-01-15T07:58:00Z",
                        "reason": "line 3: '2026-13-01 08:00:00' is not a time",
                        "route": "attlog"
                      },
                      "messages": 1520
                    },
                    "id": 42,
                    "info": {
                      "firmware": "3.4.0",
                      "punches": 1830,
                      "users": 25
                    },
                    "key": "active",
                    "key_presented": "registered",
                    "key_refused_at": null,
                    "labels": {
                      "site": "north"
                    },
                    "last_seen": "2026-01-15T08:05:00Z",
                    "params": {},
                    "remote_ip": "192.0.2.10",
                    "status": "allowed"
                  },
                  "keys": {
                    "pending": null,
                    "presented": "example-key-1",
                    "registered": "example-key-1"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/DeviceDetail"
                }
              }
            },
            "description": "The device, its keys, what its package offers it, and what its commands add up to (`commands`: waiting, in its hand, and ended unanswered)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "device not found"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The endpoint has no such device."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a device",
        "tags": [
          "devices"
        ]
      },
      "patch": {
        "description": "Allows or blocks a device, gives it a new key or takes its key away,\nadopts the key it presents, or changes its own labels. Fields left out\nare not changed; the body is checked whole before anything changes.\n\nA new key is kept and the package is asked for the commands that give\nit to the device: they are queued and returned in `commands`. Until the\ndevice presents the new key it is let in with the one it had.\n\nA change to the labels is told to the device's sync group, whose\nplacement rules pick members by them.\n\nThe change is added to the audit trail.",
        "operationId": "update_device",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "labels": {
                  "floor": null,
                  "site": "north"
                },
                "status": "allowed"
              },
              "schema": {
                "$ref": "#/components/schemas/UpdateDevice"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "commands": [],
                  "device": {
                    "device": "CG0001",
                    "endpoint": "office",
                    "first_seen": "2026-01-15T08:00:00Z",
                    "health": {
                      "errors": 1,
                      "last_error": {
                        "at": "2026-01-15T07:58:00Z",
                        "reason": "line 3: '2026-13-01 08:00:00' is not a time",
                        "route": "attlog"
                      },
                      "messages": 1520
                    },
                    "id": 42,
                    "info": {
                      "firmware": "3.4.0",
                      "punches": 1830,
                      "users": 25
                    },
                    "key": "active",
                    "key_presented": "registered",
                    "key_refused_at": null,
                    "labels": {
                      "site": "north"
                    },
                    "last_seen": "2026-01-15T08:05:00Z",
                    "params": {},
                    "remote_ip": "192.0.2.10",
                    "status": "allowed"
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/DeviceChanged"
                }
              }
            },
            "description": "Changed: the device as it is now, with its own labels, and the commands queued to give it its new key (none unless `key` was set)."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the device has not presented a key"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not valid: a label value that is not text or null, a label name or value that is not acceptable, more than 64 labels, a key that is not acceptable or that the package cannot build the commands for, `adopt_key` for a device that has presented no key, or a device whose endpoint is not configured. A body that is not JSON is refused with 400, and one with an unknown field or a value of the wrong type with 422."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "device not found"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The endpoint has no such device."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Change a device",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/tenants/{tenant}/devices/{endpoint}/{device}/actions": {
      "get": {
        "description": "A device's actions, the latest 500, oldest first, each with its steps.\nA device that is not known has no actions: the answer is an empty list.",
        "operationId": "actions",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "action": "open_door",
                    "created_at": "2026-01-15T08:00:00Z",
                    "finished_at": "2026-01-15T08:00:04Z",
                    "id": 512,
                    "lane": "interactive",
                    "params": {
                      "seconds": 5
                    },
                    "status": "done",
                    "steps": [
                      {
                        "action": "open_door",
                        "action_id": 512,
                        "completed_at": "2026-01-15T08:00:04Z",
                        "created_at": "2026-01-15T08:00:00Z",
                        "id": 9001,
                        "lane": "interactive",
                        "params": {
                          "seconds": 5
                        },
                        "payload": "CONTROL DEVICE 01 05",
                        "result": "OK",
                        "result_code": 0,
                        "sent_at": "2026-01-15T08:00:02Z",
                        "status": "succeeded",
                        "tries": 1
                      }
                    ]
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/Action"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The device's latest 500 actions, oldest first."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List a device's actions",
        "tags": [
          "devices"
        ]
      },
      "post": {
        "description": "Queues an action for a device: a standard action or a package action\nthat the device's package offers, or one of its commands sent by name\n(an action of one step). The parameters are checked against what the\naction or command declares before anything is queued; the package then\nbuilds the steps, and they are queued all or none.\n\nThe steps go to the device in order, after what already waits in their\nlane, several actions to a batch. A step that fails fails the action,\nand its steps not yet handed out are skipped. A step the package marks\nas a gate goes out on its own and the steps after it wait for it to\npass; a gate that does not pass holds the device\n(`POST /api/tenants/{tenant}/devices/{endpoint}/{device}/release`).\n\nSend `key` to make the request safe to repeat: the same key for the\nsame device returns the action the first request queued, as it is now.\nA device may have at most 10000 commands waiting. Follow the action\nwith `GET /api/tenants/{tenant}/devices/{endpoint}/{device}/actions/{id}` or its\n`action.result` event. The change is added to the audit trail.",
        "operationId": "start_action",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "action": "show_message",
                "expires_at": "2026-01-15T09:00:00Z",
                "key": "welcome-CG0001-2026-01-15",
                "lane": "interactive",
                "params": {
                  "minutes": 10,
                  "text": "Welcome back"
                }
              },
              "schema": {
                "$ref": "#/components/schemas/StartAction"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "content": {
              "application/json": {
                "example": {
                  "commands": [
                    9002
                  ],
                  "id": 513,
                  "status": "queued"
                },
                "schema": {
                  "$ref": "#/components/schemas/ActionStarted"
                }
              }
            },
            "description": "Queued (or queued before, under the same key): the action's id, its status and its steps' command ids, in order."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "'teleport' is neither a standard action nor an action of package zk-push@3.4.0"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not valid: the endpoint or the device is not known, the package offers no such action or command, the device does not take the action, the command is one only the package's own actions use. A body that is not JSON is refused with 400."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "content": {
              "application/json": {
                "example": {
                  "error": "'set_biometric' carries biometric data of person '1001': the person is not allowed biometrics (allow_biometrics is false in their group)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "It carries (or enrols) templates or photos of a person whose sync group does not allow them biometrics. (A request refused for its Host or Origin header gets 403 without a body.)"
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "office/CG0001 is a member of sync group 'hq', which keeps its people: 'upsert_user' would write them behind the group's back. Write them through /api/tenants/default/sync/hq/people/{user_id} instead; or take 'people' out of the group, or move the device to an endpoint without it, to manage them by hand"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "It writes data the device's sync group keeps: write it through the sync API (the message names the route), take the domain out of the group, or move the device to an endpoint without one."
          },
          "422": {
            "content": {
              "application/json": {
                "example": {
                  "error": "action 'show_message': parameter 'text' is required",
                  "fields": [
                    {
                      "field": "text",
                      "message": "is required"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The parameters do not fit what the action or command declares: `fields` says what is wrong with each. Nothing was queued. A body with an unknown field, a value of the wrong type or a lane other than `interactive` or `bulk` is refused with 422."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Queue an action",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/tenants/{tenant}/devices/{endpoint}/{device}/actions/{id}": {
      "delete": {
        "description": "Takes back the steps of an action that have not been handed to the\ndevice: they never go (`cancelled`). Steps already handed out cannot be\nrecalled and report as usual (`already_sent`). An action that is\nfinished, or has nothing left to take back, is not changed: `cancelled`\nis empty.\n\nWhen steps are taken back and the action ends, its `action.result`\nevent is stored. The change is added to the audit trail.",
        "operationId": "cancel_action",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The action's id.",
            "example": 513,
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "description": "`true`: also give up on the steps already handed to the device that it has not answered (marked unanswered, each\nwith its `command.unanswered` event, and the action fails with them). For a device that is not coming back: nothing\nelse ends what it holds. Not given: such steps are left to the device.",
            "example": false,
            "in": "query",
            "name": "give_up",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "already_sent": [],
                  "cancelled": [
                    9002
                  ],
                  "id": 513,
                  "status": "cancelled"
                },
                "schema": {
                  "$ref": "#/components/schemas/ActionCancelled"
                }
              }
            },
            "description": "What the cancel did: the action's status now, the steps taken back and those already handed to the device."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "action not found"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The device has no action with this id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Cancel an action",
        "tags": [
          "devices"
        ]
      },
      "get": {
        "description": "One action of a device, with each step's command and status, and why\nit stopped when it failed, was cancelled or timed out.",
        "operationId": "action",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The action's id.",
            "example": 512,
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "action": "open_door",
                  "created_at": "2026-01-15T08:00:00Z",
                  "finished_at": "2026-01-15T08:00:04Z",
                  "id": 512,
                  "lane": "interactive",
                  "params": {
                    "seconds": 5
                  },
                  "status": "done",
                  "steps": [
                    {
                      "action": "open_door",
                      "action_id": 512,
                      "completed_at": "2026-01-15T08:00:04Z",
                      "created_at": "2026-01-15T08:00:00Z",
                      "id": 9001,
                      "lane": "interactive",
                      "params": {
                        "seconds": 5
                      },
                      "payload": "CONTROL DEVICE 01 05",
                      "result": "OK",
                      "result_code": 0,
                      "sent_at": "2026-01-15T08:00:02Z",
                      "status": "succeeded",
                      "tries": 1
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/Action"
                }
              }
            },
            "description": "The action, with its steps."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "action not found"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The device has no action with this id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get an action",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/tenants/{tenant}/devices/{endpoint}/{device}/catalog": {
      "get": {
        "description": "What one device takes: the actions of its package that it takes and the\ncommands it may be sent by name, as the package judges from what the\ndevice reported (firmware, capabilities), and the settings it has, each\ntyped and described. Use it to build the `params` of\n`POST /api/tenants/{tenant}/devices/{endpoint}/{device}/actions`, and the `values` of a\n`set_settings` action.",
        "operationId": "device_catalog",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "actions": [
                    {
                      "command": "open_door",
                      "name": "open_door",
                      "params": [
                        {
                          "description": "Which door, as the device numbers them; default: its only one.",
                          "name": "door",
                          "required": false,
                          "sensitive": false,
                          "type": "string"
                        },
                        {
                          "description": "How long; default: the device's own unlock time.",
                          "name": "seconds",
                          "required": false,
                          "sensitive": false,
                          "type": "integer"
                        }
                      ],
                      "standard": true,
                      "writes": []
                    }
                  ],
                  "commands": [
                    {
                      "description": "Unlocks the door for a moment.",
                      "implements": "open_door",
                      "key": "open_door",
                      "params": [
                        {
                          "description": "Which door, as the device numbers them; default: its only one.",
                          "name": "door",
                          "required": false,
                          "sensitive": false,
                          "type": "string"
                        },
                        {
                          "description": "How long; default: the device's own unlock time.",
                          "max": 60,
                          "min": 1,
                          "name": "seconds",
                          "required": false,
                          "sensitive": false,
                          "type": "integer"
                        }
                      ],
                      "quick": true,
                      "sensitive_result": false,
                      "success": "zero",
                      "title": "Open door",
                      "writes": []
                    }
                  ],
                  "device": "CG0001",
                  "endpoint": "office",
                  "package": "zk-push@3.4.0",
                  "revision": 7,
                  "settings": [
                    {
                      "access": "rw",
                      "description": "How loud the device speaks, in per cent.",
                      "max": 100.0,
                      "min": 0.0,
                      "name": "volume",
                      "native": "Volume",
                      "needs_reboot": false,
                      "sensitive": false,
                      "standard": "volume",
                      "title": "Volume",
                      "type": "integer"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/DeviceCatalog"
                }
              }
            },
            "description": "What the device takes, by the package that serves it."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "device not found"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The endpoint has no such device, or the endpoint is not configured."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a device's catalog",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/tenants/{tenant}/devices/{endpoint}/{device}/commands": {
      "get": {
        "description": "A device's commands, the latest 500, in the order they were queued:\nthe steps of its actions, each with its payload, status and result.\nQueue commands as actions (`POST /api/tenants/{tenant}/devices/{endpoint}/{device}/actions`).\nA device that is not known has no commands: the answer is an empty list.",
        "operationId": "commands",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "action": "open_door",
                    "action_id": 512,
                    "completed_at": "2026-01-15T08:00:04Z",
                    "created_at": "2026-01-15T08:00:00Z",
                    "id": 9001,
                    "lane": "interactive",
                    "params": {
                      "seconds": 5
                    },
                    "payload": "CONTROL DEVICE 01 05",
                    "result": "OK",
                    "result_code": 0,
                    "sent_at": "2026-01-15T08:00:02Z",
                    "status": "succeeded",
                    "tries": 1
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/Command"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The device's latest 500 commands, oldest first."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List a device's commands",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/tenants/{tenant}/devices/{endpoint}/{device}/release": {
      "post": {
        "description": "Takes a device's hold off. A device is held when a gate of one of its\nactions does not pass: nothing is handed to it until it is released,\nwhile what it sends is taken in all along. Once released, what waits\nfor it goes out again, in order; with `drop_queued`, every action and\ncommand still waiting for it is cancelled instead, each action saying\nwhy.\n\nThe body is optional: without one, nothing is dropped. One that is not\nJSON is refused with 400, one with an unknown field or a value of the\nwrong type with 422, and nothing is released. A\n`device.released` event is stored with the reason, who released the\ndevice and what was dropped, and the change is added to the audit trail.",
        "operationId": "release_device",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "drop_queued": false,
                "reason": "room for the users checked on site"
              },
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/ReleaseDevice"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "cancelled_commands": [],
                  "device": "CG0001",
                  "drop_queued": false,
                  "dropped_actions": [],
                  "endpoint": "office",
                  "released": {
                    "action_id": 512,
                    "held_at": "2026-01-15T08:00:04Z",
                    "reason": "gate step 1 (check_room) of action 512 (upsert_user) did not pass: the device answered -1",
                    "step": 1
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/DeviceReleased"
                }
              }
            },
            "description": "Released: the hold taken off and what was dropped."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the body cannot be read: expected value at line 1 column 1"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not JSON."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "device not found"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The endpoint has no such device."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "device 'CG0001' is not held"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The device is not held."
          },
          "422": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the body cannot be read: unknown field `drop`, expected `drop_queued` or                                      `reason` at line 1 column 7"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body has an unknown field or a value of the wrong type."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Release a held device",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/tenants/{tenant}/endpoints": {
      "get": {
        "description": "Every endpoint: its settings, the package version the instance that answers runs for it (`package_id`), whether it is stopped by hand, and why it is not served, if it is not (`unavailable`).",
        "operationId": "list_endpoints",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "delivery": "ack",
                    "id": "office",
                    "listener": "public",
                    "new_devices": "hold",
                    "options": {},
                    "package": "zk-push",
                    "package_id": "zk-push@3.4.0",
                    "path": "/office",
                    "reply_topic": null,
                    "sinks": [
                      "payroll"
                    ],
                    "stopped": false,
                    "sync_group": "office",
                    "topic": null
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/EndpointInfo"
                  },
                  "type": "array"
                }
              }
            },
            "description": "All of them."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List endpoints",
        "tags": [
          "setup"
        ]
      },
      "post": {
        "description": "Adds an endpoint on every instance: the devices that reach `listener` on `path` (http) or publish on `topic` (mqtt) are run by `package`, and their events are stored and sent to `sinks`. `new_devices` says what becomes of a device nobody registered: `hold` (the default) keeps it waiting for you to allow it, `allow` lets it in, `refuse` turns it away. An endpoint with no `sync_group` is put in a group of its own, named after it, that keeps nothing. An endpoint whose package no active revision provides is added, and shown with `unavailable` until a revision of the package is activated; one whose package is active and does not fit it is refused. Recorded in the audit trail.",
        "operationId": "create_endpoint",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "id": "office",
                "listener": "public",
                "new_devices": "hold",
                "package": "zk-push",
                "path": "/office",
                "sinks": [
                  "payroll"
                ]
              },
              "schema": {
                "$ref": "#/components/schemas/EndpointConfig"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "delivery": "ack",
                  "id": "office",
                  "listener": "public",
                  "new_devices": "hold",
                  "options": {},
                  "package": "zk-push",
                  "package_id": "zk-push@3.4.0",
                  "path": "/office",
                  "reply_topic": null,
                  "sinks": [
                    "payroll"
                  ],
                  "stopped": false,
                  "sync_group": "office",
                  "topic": null
                },
                "schema": {
                  "$ref": "#/components/schemas/EndpointInfo"
                }
              }
            },
            "description": "Added: as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "endpoint 'office' references unknown listener 'public'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not an endpoint (an unknown field, a missing `id`, `listener` or `package`), or the endpoint is not valid: an id that is not 1-64 letters, digits, '-' or '_'; an unknown listener, sink or sync group; a path or topic another endpoint on the listener already matches; a path on an mqtt listener or a topic on an http one; or its active package does not fit it."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "endpoint 'office' already exists"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "An endpoint with that id exists, or the settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Add an endpoint",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/endpoints/{id}": {
      "delete": {
        "description": "Removes an endpoint from every instance: its listener no longer routes anything to it, and whether it was stopped by hand is forgotten. Refused (409) while it has devices: they are not forgotten with it, so remove them first. Recorded in the audit trail.",
        "operationId": "delete_endpoint",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The endpoint's id.",
            "example": "office",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "delivery": "ack",
                  "id": "office",
                  "listener": "public",
                  "new_devices": "hold",
                  "options": {},
                  "package": "zk-push",
                  "package_id": "zk-push@3.4.0",
                  "path": "/office",
                  "reply_topic": null,
                  "sinks": [
                    "payroll"
                  ],
                  "stopped": false,
                  "sync_group": "office",
                  "topic": null
                },
                "schema": {
                  "$ref": "#/components/schemas/EndpointInfo"
                }
              }
            },
            "description": "Removed: as it was."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown endpoint 'office'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no endpoint with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "endpoint 'office' has devices: remove them first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The endpoint has devices, or the settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Remove an endpoint",
        "tags": [
          "setup"
        ]
      },
      "get": {
        "description": "One endpoint (see `GET /api/tenants/{tenant}/endpoints`).",
        "operationId": "show_endpoint",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The endpoint's id.",
            "example": "office",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "delivery": "ack",
                  "id": "office",
                  "listener": "public",
                  "new_devices": "hold",
                  "options": {},
                  "package": "zk-push",
                  "package_id": "zk-push@3.4.0",
                  "path": "/office",
                  "reply_topic": null,
                  "sinks": [
                    "payroll"
                  ],
                  "stopped": false,
                  "sync_group": "office",
                  "topic": null
                },
                "schema": {
                  "$ref": "#/components/schemas/EndpointInfo"
                }
              }
            },
            "description": "As it is now."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown endpoint 'office'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no endpoint with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get an endpoint",
        "tags": [
          "setup"
        ]
      },
      "patch": {
        "description": "Changes an endpoint's settings on every instance, from its next message on. A change that would leave it unable to serve (its package does not fit the new settings) is refused, and nothing changes. Moving it to a sync group that keeps data makes its allowed devices members, saved before the answer. Recorded in the audit trail.",
        "operationId": "update_endpoint",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The endpoint's id.",
            "example": "office",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "new_devices": "allow",
                "sinks": [
                  "payroll",
                  "audit"
                ]
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "description": "A JSON merge patch (RFC 7396) of its settings: the fields to change. Objects merge, null removes a field (back to its default), arrays and values replace. `id` may only repeat the id it has.",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "delivery": "ack",
                  "id": "office",
                  "listener": "public",
                  "new_devices": "allow",
                  "options": {},
                  "package": "zk-push",
                  "package_id": "zk-push@3.4.0",
                  "path": "/office",
                  "reply_topic": null,
                  "sinks": [
                    "payroll",
                    "audit"
                  ],
                  "stopped": false,
                  "sync_group": "office",
                  "topic": null
                },
                "schema": {
                  "$ref": "#/components/schemas/EndpointInfo"
                }
              }
            },
            "description": "Changed: as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "endpoint 'office' references unknown sink 'audit'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a JSON object, it changes the id, or the endpoint is not valid once patched (see `POST /api/tenants/{tenant}/endpoints`), or it would no longer be served."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown endpoint 'office'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no endpoint with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the settings were changed elsewhere (another gateway instance) in the meantime; try again"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Change an endpoint",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/endpoints/{id}/start": {
      "post": {
        "description": "Starts an endpoint that was stopped by hand, on every instance: its devices' messages reach the package again.\nStarting one that is not stopped changes nothing. Recorded in the audit trail.",
        "operationId": "start_endpoint",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The endpoint's id.",
            "example": "office",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "delivery": "ack",
                  "id": "office",
                  "listener": "public",
                  "new_devices": "hold",
                  "options": {},
                  "package": "zk-push",
                  "package_id": "zk-push@3.4.0",
                  "path": "/office",
                  "reply_topic": null,
                  "sinks": [
                    "payroll"
                  ],
                  "stopped": false,
                  "sync_group": "office",
                  "topic": null
                },
                "schema": {
                  "$ref": "#/components/schemas/EndpointInfo"
                }
              }
            },
            "description": "Started: the endpoint as it is now."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown endpoint 'office'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no endpoint with that id that this instance serves (an endpoint whose package it does not run is not one)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Start an endpoint",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/endpoints/{id}/stop": {
      "post": {
        "description": "Stops the endpoint on every instance: its listener keeps running, but every message from its devices is answered\n503 (`stopped`) and nothing of it reaches the package; a device that keeps its data sends it again once the endpoint\nis started. It stays stopped, across restarts too, until you start it. Recorded in the audit trail.",
        "operationId": "stop_endpoint",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The endpoint's id.",
            "example": "office",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "delivery": "ack",
                  "id": "office",
                  "listener": "public",
                  "new_devices": "hold",
                  "options": {},
                  "package": "zk-push",
                  "package_id": "zk-push@3.4.0",
                  "path": "/office",
                  "reply_topic": null,
                  "sinks": [
                    "payroll"
                  ],
                  "stopped": true,
                  "sync_group": "office",
                  "topic": null
                },
                "schema": {
                  "$ref": "#/components/schemas/EndpointInfo"
                }
              }
            },
            "description": "Stopped: the endpoint as it is now."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown endpoint 'office'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no endpoint with that id that this instance serves (an endpoint whose package it does not run is not one)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Stop an endpoint",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/events": {
      "get": {
        "description": "The events stored, oldest first, a page at a time, each with the sequence number it was stored under (`seq`).\nAn event is never returned before every event with a lower `seq` is in place, so reading on from `next` skips\nnothing: pass the answer's `next` as `after`. A page with no events means there are none newer yet, and `next`\nstays where it was. Events are kept for `retention_days` once every sink they go to has taken them, and until it\ndoes while one has not.",
        "operationId": "events",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only events after the one with this sequence number: pass the `next`\nof the previous answer to carry on from it. Default 0, from the\noldest kept.",
            "example": 4180,
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "description": "At most this many events: 100 unless given, at most 1000 (more is\nread as 1000).",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "description": "Only this endpoint's events.",
            "example": "office",
            "in": "query",
            "name": "endpoint",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only this device's events: its id, as its package identifies it.",
            "example": "CG0001",
            "in": "query",
            "name": "device",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only events of this type (\"punch\", \"user\", ...).",
            "example": "punch",
            "in": "query",
            "name": "type",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only events received at or after this time (RFC 3339). With\n`until`, the days outside are not read at all: events are kept by\nthe day they were received.",
            "example": "2026-01-15T00:00:00Z",
            "in": "query",
            "name": "since",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "Only events received before this time (RFC 3339): later than\n`since`.",
            "example": "2026-01-16T00:00:00Z",
            "in": "query",
            "name": "until",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "Only events whose data names this person (`\"user_id\"`): punches,\nenrolments. Looked for in the events the other filters leave (no\nindex): bound it with `since`, or a device, on a large store.",
            "example": "1001",
            "in": "query",
            "name": "user_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    {
                      "data": {
                        "dst_ambiguous": false,
                        "local_time": "2026-01-15 08:00:00",
                        "state_name": "check_in",
                        "time": "2026-01-15T08:00:00-06:00",
                        "time_zone": "America/Chicago",
                        "user_id": "1001",
                        "utc_offset": "-06:00",
                        "verify_name": "fingerprint",
                        "zoned": "2026-01-15T08:00:00-06:00[America/Chicago]"
                      },
                      "device": "CG0001",
                      "endpoint": "office",
                      "id": "3f2a9c1e7b6d4a0f8e5c2b1a9d8c7e6f",
                      "package": "zk-push@3.4.0",
                      "received_at": "2026-01-15T14:00:02Z",
                      "schema": 3,
                      "seq": 4181,
                      "tenant": "default",
                      "type": "punch"
                    }
                  ],
                  "next": 4181
                },
                "schema": {
                  "$ref": "#/components/schemas/EventsPage"
                }
              }
            },
            "description": "A page of events, oldest first."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "until must be later than since"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`until` is not later than `since`."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List events",
        "tags": [
          "events"
        ]
      },
      "post": {
        "description": "Events another system sends into the tenant (an ERP, a scheduling app, Time and Attendance, another install):\nkept in the tenant's events, as a device's are, and sent to the tenant's sinks that name their `source` in their\n`sources`, and to the install-level sinks. Each names its `source` and carries an `id` its source gives no other\nevent: posted again with the same source and id (a retry), it is taken once, and the answer lists it among the\n`duplicates`. A post holds 1 to 100 events, each with at most 16 KiB of `data`, and is kept all together or not\nat all: one event that is not as asked refuses the whole post, saying which. Kept, an event is in the standard\nenvelope: its `endpoint` is `source:<source>`, its `package` the source, its `device` what it is about. A\nsuspended or stopped tenant takes none (409). The live stream shows those kept. Posts are not recorded in the\naudit trail: they are data, as a device's messages are, not changes to the setup.",
        "operationId": "post_events",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "events": [
                  {
                    "data": {
                      "person": "104552",
                      "start": "2026-10-12"
                    },
                    "device": "104552",
                    "id": "erp-hire-20391",
                    "source": "erp",
                    "type": "employee.hired"
                  }
                ]
              },
              "schema": {
                "$ref": "#/components/schemas/PostedEvents"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "duplicates": [],
                  "stored": [
                    "erp-hire-20391"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PostedView"
                }
              }
            },
            "description": "Kept: the ids stored, and those posted before."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "event 0: its data is 20480 bytes as JSON: at most 16384"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The post is not as asked: no events or more than 100, or an event whose id, source, type or device is not as described (the sources `connect` and `attendance` are Connect's and Time and Attendance's own), or whose data is over 16 KiB."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "tenant 'acme' is suspended: it takes no events until it is resumed"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant is suspended or stopped."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The database cannot be used right now: post it again."
          }
        },
        "summary": "Post events",
        "tags": [
          "events"
        ]
      }
    },
    "/api/tenants/{tenant}/export": {
      "get": {
        "description": "Everything set through this API that makes up the tenant's setup: its listeners, endpoints, sinks and sync\ngroups, as every instance uses them. Listener passwords and sink secrets are left out: `password_set` and\n`secret_set` say whether one is set. Vars, secrets and devices are not part of it; the install's settings are in\n`GET /api/export`.",
        "operationId": "tenant_export",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "endpoints": [
                    {
                      "id": "office",
                      "labels": {
                        "site": "north"
                      },
                      "listener": "public",
                      "new_devices": "hold",
                      "options": {},
                      "package": "zk-push",
                      "path": "/office",
                      "sinks": [
                        "payroll"
                      ],
                      "sync_group": "hq"
                    }
                  ],
                  "listeners": [
                    {
                      "id": "public",
                      "listen": "0.0.0.0:8080",
                      "password_set": false,
                      "type": "http"
                    }
                  ],
                  "sinks": [
                    {
                      "events": [
                        "punch"
                      ],
                      "id": "payroll",
                      "secret_set": true,
                      "type": "webhook",
                      "url": "https://example.com/houradvantage/events"
                    }
                  ],
                  "sync_groups": [
                    {
                      "domains": [
                        "people",
                        "access"
                      ],
                      "id": "hq",
                      "lists": {
                        "authority": "group"
                      },
                      "people": {
                        "authority": "group",
                        "biometrics": false
                      },
                      "punches": {
                        "lockout_minutes": 0
                      },
                      "settings": {
                        "authority": "group"
                      },
                      "sinks": []
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/Export"
                }
              }
            },
            "description": "The tenant's setup."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Export the tenant's setup",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/failures": {
      "get": {
        "description": "Device messages that failed, newest first, a page at a time: the package raised an error, ran past its time or\nmemory limit, no route of it matched, or what the message changed could not be stored. Each says which device,\nwhich route, the error, and where in the package it happened when the error says. What the message and the reply\ncarried is never kept. Each instance writes its failures every 30 seconds or so, so the newest may take that long\nto appear. They are kept for `retention_days`. When a page is full, `next` is the id to pass as `before` for the\nnext one; null means there are no more.",
        "operationId": "failures",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only this endpoint's failures.",
            "example": "office",
            "in": "query",
            "name": "endpoint",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only this device's failures: its id, as its package identifies it.",
            "example": "CG0001",
            "in": "query",
            "name": "device",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only those at or after this time (RFC 3339).",
            "example": "2026-01-15T00:00:00Z",
            "in": "query",
            "name": "since",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "Only those older than the one with this id: the `next` of the page\nbefore. Absent: from the newest.",
            "example": 9120,
            "in": "query",
            "name": "before",
            "required": false,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "description": "At most this many: 100 unless given, 1 to 1000 (outside that, the\nnearest of the two).",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "failures": [
                    {
                      "at": "2026-01-15T14:00:02Z",
                      "device": "CG0001",
                      "endpoint": "office",
                      "error": "zk/attlog.lua:42: attempt to index a nil value (local 'fields')",
                      "id": 9121,
                      "instance": "gw-1",
                      "kind": "lua_error",
                      "request": "POST /office/iclock/cdata",
                      "route": "attlog",
                      "source": "zk/attlog.lua:42",
                      "status": 500
                    }
                  ],
                  "next": null
                },
                "schema": {
                  "$ref": "#/components/schemas/FailuresPage"
                }
              }
            },
            "description": "A page of failures, newest first."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List failed device messages",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/tenants/{tenant}/jobs": {
      "get": {
        "description": "The newest jobs first, each with how many of its devices are in each\nstate (`counts`). The devices themselves are not listed: get one job\nfor those.",
        "operationId": "list_jobs",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "How many jobs, newest first: 1 to 500, 500 unless given (0 counts as\n1, more than 500 as 500).",
            "example": 50,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "abort_seen": 0,
                    "counts": {
                      "cancelled": 0,
                      "failed": 0,
                      "queued": 0,
                      "running": 0,
                      "succeeded": 2,
                      "timed_out": 0,
                      "waiting_window": 0
                    },
                    "created_at": "2026-01-15T16:55:00Z",
                    "created_by": "admin",
                    "finished_at": "2026-01-15T17:01:10Z",
                    "id": 7,
                    "matched": 2,
                    "no_zone": 0,
                    "spec": {
                      "abort": {
                        "after": 5,
                        "failed_percent": 20
                      },
                      "action": "show_message",
                      "lane": "interactive",
                      "name": "Evening notice, north site",
                      "params": {
                        "minutes": 60,
                        "text": "The clocks restart at 22:00"
                      },
                      "rollout": {
                        "advance": "auto",
                        "max_concurrent": 10,
                        "waves": [
                          1,
                          "50%"
                        ]
                      },
                      "targets": {
                        "endpoints": [
                          "office"
                        ],
                        "select": "site = north"
                      },
                      "timeout": 1800,
                      "window": {
                        "days": [
                          "mon",
                          "tue",
                          "wed",
                          "thu",
                          "fri"
                        ],
                        "hours": "17:00-21:00"
                      }
                    },
                    "state": "completed",
                    "updated_at": "2026-01-15T17:01:10Z",
                    "wave": 1,
                    "waves": 2
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/JobView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "At most `limit` jobs, newest first, without their devices."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List jobs",
        "tags": [
          "jobs"
        ]
      },
      "post": {
        "description": "Runs one action on many devices, in waves. The devices are found now:\nthe allowed devices of `targets.endpoints` (every endpoint when none is\nnamed) that the selector `targets.select` picks by their labels, when\neither is given, and the devices listed in `targets.devices`. A listed\ndevice that is not known or not allowed is named in `missing`. A job\ntakes at most 100000 devices.\n\nEach device gets its execution and its wave, and the job starts at\nonce: devices start as the rollout, `max_concurrent` and the window\nallow, each running the action with the job's parameters. With\n`advance` `auto`, the next wave starts once every device of the current\none succeeded. A device's action that does not finish within `timeout`\nis taken back, and the device is `timed_out`. With `abort`, the job\npauses when too many devices fail.\n\nThe parameters may hold no value the package marks sensitive (a job\nkeeps them), and the action may not write data a device's sync group\nkeeps. A `job.started` event is stored for each endpoint the job has\ndevices on, and the change is added to the audit trail. The job goes on\nwhichever instance takes it up, and every instance answers for it.",
        "operationId": "create_job",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "abort": {
                  "after": 5,
                  "failed_percent": 20
                },
                "action": "show_message",
                "lane": "interactive",
                "name": "Evening notice, north site",
                "params": {
                  "minutes": 60,
                  "text": "The clocks restart at 22:00"
                },
                "rollout": {
                  "advance": "auto",
                  "max_concurrent": 10,
                  "waves": [
                    1,
                    "50%"
                  ]
                },
                "targets": {
                  "endpoints": [
                    "office"
                  ],
                  "select": "site = north"
                },
                "timeout": 1800,
                "window": {
                  "days": [
                    "mon",
                    "tue",
                    "wed",
                    "thu",
                    "fri"
                  ],
                  "hours": "17:00-21:00"
                }
              },
              "schema": {
                "$ref": "#/components/schemas/JobSpec"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "abort_seen": 0,
                  "counts": {
                    "cancelled": 0,
                    "failed": 0,
                    "queued": 2,
                    "running": 0,
                    "succeeded": 0,
                    "timed_out": 0,
                    "waiting_window": 0
                  },
                  "created_at": "2026-01-15T16:55:00Z",
                  "created_by": "admin",
                  "executions": [
                    {
                      "attempt": 1,
                      "device": "CG0001",
                      "endpoint": "office",
                      "seq": 0,
                      "state": "queued",
                      "wave": 0,
                      "zone": "America/Chicago"
                    },
                    {
                      "attempt": 1,
                      "device": "CG0002",
                      "endpoint": "office",
                      "seq": 1,
                      "state": "queued",
                      "wave": 1,
                      "zone": "America/Chicago"
                    }
                  ],
                  "id": 7,
                  "matched": 2,
                  "no_zone": 0,
                  "spec": {
                    "abort": {
                      "after": 5,
                      "failed_percent": 20
                    },
                    "action": "show_message",
                    "lane": "interactive",
                    "name": "Evening notice, north site",
                    "params": {
                      "minutes": 60,
                      "text": "The clocks restart at 22:00"
                    },
                    "rollout": {
                      "advance": "auto",
                      "max_concurrent": 10,
                      "waves": [
                        1,
                        "50%"
                      ]
                    },
                    "targets": {
                      "endpoints": [
                        "office"
                      ],
                      "select": "site = north"
                    },
                    "timeout": 1800,
                    "window": {
                      "days": [
                        "mon",
                        "tue",
                        "wed",
                        "thu",
                        "fri"
                      ],
                      "hours": "17:00-21:00"
                    }
                  },
                  "state": "running",
                  "updated_at": "2026-01-15T17:01:10Z",
                  "wave": 0,
                  "waves": 2
                },
                "schema": {
                  "$ref": "#/components/schemas/JobView"
                }
              }
            },
            "description": "Created and started: the job, with every device it runs on."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the targets match no allowed device"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not valid: a field that is not known or not of its type, no action, targets that select no device or match none, more than 100000 devices, an unknown endpoint, an action a device's package does not offer, one that writes data a device's sync group keeps, a sensitive parameter, a wave size, window, `max_concurrent`, `timeout` or `abort.failed_percent` out of range."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Create a job",
        "tags": [
          "jobs"
        ]
      }
    },
    "/api/tenants/{tenant}/jobs/{id}": {
      "get": {
        "description": "One job, with every device in `seq` order: its wave, state, zone, the\naction started on it, and what went wrong or what it waits for. A\ndevice held by a gate that did not pass shows `held`.",
        "operationId": "show_job",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The job's id.",
            "example": 7,
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "abort_seen": 0,
                  "counts": {
                    "cancelled": 0,
                    "failed": 0,
                    "queued": 0,
                    "running": 1,
                    "succeeded": 1,
                    "timed_out": 0,
                    "waiting_window": 0
                  },
                  "created_at": "2026-01-15T16:55:00Z",
                  "created_by": "admin",
                  "executions": [
                    {
                      "action_id": 600,
                      "attempt": 1,
                      "device": "CG0001",
                      "endpoint": "office",
                      "finished_at": "2026-01-15T17:01:10Z",
                      "seq": 0,
                      "started_at": "2026-01-15T17:00:05Z",
                      "state": "succeeded",
                      "wave": 0,
                      "zone": "America/Chicago"
                    },
                    {
                      "action_id": 601,
                      "attempt": 1,
                      "device": "CG0002",
                      "endpoint": "office",
                      "seq": 1,
                      "started_at": "2026-01-15T17:00:05Z",
                      "state": "running",
                      "wave": 1,
                      "zone": "America/Chicago"
                    }
                  ],
                  "id": 7,
                  "matched": 2,
                  "no_zone": 0,
                  "spec": {
                    "abort": {
                      "after": 5,
                      "failed_percent": 20
                    },
                    "action": "show_message",
                    "lane": "interactive",
                    "name": "Evening notice, north site",
                    "params": {
                      "minutes": 60,
                      "text": "The clocks restart at 22:00"
                    },
                    "rollout": {
                      "advance": "auto",
                      "max_concurrent": 10,
                      "waves": [
                        1,
                        "50%"
                      ]
                    },
                    "targets": {
                      "endpoints": [
                        "office"
                      ],
                      "select": "site = north"
                    },
                    "timeout": 1800,
                    "window": {
                      "days": [
                        "mon",
                        "tue",
                        "wed",
                        "thu",
                        "fri"
                      ],
                      "hours": "17:00-21:00"
                    }
                  },
                  "state": "running",
                  "updated_at": "2026-01-15T17:01:10Z",
                  "wave": 1,
                  "waves": 2
                },
                "schema": {
                  "$ref": "#/components/schemas/JobView"
                }
              }
            },
            "description": "The job, with every device."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no job 7"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no job with this id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a job",
        "tags": [
          "jobs"
        ]
      }
    },
    "/api/tenants/{tenant}/jobs/{id}/advance": {
      "post": {
        "description": "Moves a running or paused job to its next wave, whatever became of the\ncurrent one: the devices of that wave may start (in a paused job, once\nit is resumed). Use it for a job whose rollout advances by hand\n(`advance` `manual`), or to go past a wave with devices that did not\nsucceed. A `job.wave` event is stored and the change is added to the\naudit trail.",
        "operationId": "advance_job",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The job's id.",
            "example": 7,
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "abort_seen": 0,
                  "counts": {
                    "cancelled": 0,
                    "failed": 1,
                    "queued": 1,
                    "running": 0,
                    "succeeded": 0,
                    "timed_out": 0,
                    "waiting_window": 0
                  },
                  "created_at": "2026-01-15T16:55:00Z",
                  "created_by": "admin",
                  "executions": [
                    {
                      "action_id": 600,
                      "attempt": 1,
                      "device": "CG0001",
                      "endpoint": "office",
                      "finished_at": "2026-01-15T17:01:10Z",
                      "seq": 0,
                      "started_at": "2026-01-15T17:00:05Z",
                      "state": "failed",
                      "wave": 0,
                      "zone": "America/Chicago"
                    },
                    {
                      "attempt": 1,
                      "device": "CG0002",
                      "endpoint": "office",
                      "seq": 1,
                      "state": "queued",
                      "wave": 1,
                      "zone": "America/Chicago"
                    }
                  ],
                  "id": 7,
                  "matched": 2,
                  "no_zone": 0,
                  "spec": {
                    "abort": {
                      "after": 5,
                      "failed_percent": 20
                    },
                    "action": "show_message",
                    "lane": "interactive",
                    "name": "Evening notice, north site",
                    "params": {
                      "minutes": 60,
                      "text": "The clocks restart at 22:00"
                    },
                    "rollout": {
                      "advance": "auto",
                      "max_concurrent": 10,
                      "waves": [
                        1,
                        "50%"
                      ]
                    },
                    "targets": {
                      "endpoints": [
                        "office"
                      ],
                      "select": "site = north"
                    },
                    "timeout": 1800,
                    "window": {
                      "days": [
                        "mon",
                        "tue",
                        "wed",
                        "thu",
                        "fri"
                      ],
                      "hours": "17:00-21:00"
                    }
                  },
                  "state": "running",
                  "updated_at": "2026-01-15T17:01:10Z",
                  "wave": 1,
                  "waves": 2
                },
                "schema": {
                  "$ref": "#/components/schemas/JobView"
                }
              }
            },
            "description": "Advanced: the job, with every device."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no job 7"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no job with this id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "job 7 is at its last wave (2)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The job is at its last wave, completed or cancelled."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Advance a job",
        "tags": [
          "jobs"
        ]
      }
    },
    "/api/tenants/{tenant}/jobs/{id}/cancel": {
      "post": {
        "description": "Stops a job for good: devices not started are cancelled, and the\nactions of devices running are cancelled too (steps already handed out\nreport as usual, and each such device ends as its action does). The\njob's `reason` says who cancelled it. A `job.cancelled` event is stored\nand the change is added to the audit trail.",
        "operationId": "cancel_job",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The job's id.",
            "example": 7,
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "abort_seen": 0,
                  "counts": {
                    "cancelled": 1,
                    "failed": 0,
                    "queued": 0,
                    "running": 0,
                    "succeeded": 1,
                    "timed_out": 0,
                    "waiting_window": 0
                  },
                  "created_at": "2026-01-15T16:55:00Z",
                  "created_by": "admin",
                  "executions": [
                    {
                      "action_id": 600,
                      "attempt": 1,
                      "device": "CG0001",
                      "endpoint": "office",
                      "finished_at": "2026-01-15T17:01:10Z",
                      "seq": 0,
                      "started_at": "2026-01-15T17:00:05Z",
                      "state": "succeeded",
                      "wave": 0,
                      "zone": "America/Chicago"
                    },
                    {
                      "attempt": 1,
                      "detail": "the job was cancelled",
                      "device": "CG0002",
                      "endpoint": "office",
                      "finished_at": "2026-01-15T17:01:10Z",
                      "seq": 1,
                      "state": "cancelled",
                      "wave": 1,
                      "zone": "America/Chicago"
                    }
                  ],
                  "finished_at": "2026-01-15T17:01:10Z",
                  "id": 7,
                  "matched": 2,
                  "no_zone": 0,
                  "reason": "cancelled by admin",
                  "spec": {
                    "abort": {
                      "after": 5,
                      "failed_percent": 20
                    },
                    "action": "show_message",
                    "lane": "interactive",
                    "name": "Evening notice, north site",
                    "params": {
                      "minutes": 60,
                      "text": "The clocks restart at 22:00"
                    },
                    "rollout": {
                      "advance": "auto",
                      "max_concurrent": 10,
                      "waves": [
                        1,
                        "50%"
                      ]
                    },
                    "targets": {
                      "endpoints": [
                        "office"
                      ],
                      "select": "site = north"
                    },
                    "timeout": 1800,
                    "window": {
                      "days": [
                        "mon",
                        "tue",
                        "wed",
                        "thu",
                        "fri"
                      ],
                      "hours": "17:00-21:00"
                    }
                  },
                  "state": "cancelled",
                  "updated_at": "2026-01-15T17:01:10Z",
                  "wave": 0,
                  "waves": 2
                },
                "schema": {
                  "$ref": "#/components/schemas/JobView"
                }
              }
            },
            "description": "Cancelled: the job, with every device."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no job 7"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no job with this id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "job 7 is completed"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The job is completed or cancelled already."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Cancel a job",
        "tags": [
          "jobs"
        ]
      }
    },
    "/api/tenants/{tenant}/jobs/{id}/pause": {
      "post": {
        "description": "No device of the job starts until it is resumed; devices running go on\nto their end. The job's `reason` says who paused it. A `job.paused`\nevent is stored and the change is added to the audit trail.",
        "operationId": "pause_job",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The job's id.",
            "example": 7,
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "abort_seen": 0,
                  "counts": {
                    "cancelled": 0,
                    "failed": 0,
                    "queued": 1,
                    "running": 1,
                    "succeeded": 0,
                    "timed_out": 0,
                    "waiting_window": 0
                  },
                  "created_at": "2026-01-15T16:55:00Z",
                  "created_by": "admin",
                  "executions": [
                    {
                      "action_id": 600,
                      "attempt": 1,
                      "device": "CG0001",
                      "endpoint": "office",
                      "seq": 0,
                      "started_at": "2026-01-15T17:00:05Z",
                      "state": "running",
                      "wave": 0,
                      "zone": "America/Chicago"
                    },
                    {
                      "attempt": 1,
                      "device": "CG0002",
                      "endpoint": "office",
                      "seq": 1,
                      "state": "queued",
                      "wave": 1,
                      "zone": "America/Chicago"
                    }
                  ],
                  "id": 7,
                  "matched": 2,
                  "no_zone": 0,
                  "reason": "paused by admin",
                  "spec": {
                    "abort": {
                      "after": 5,
                      "failed_percent": 20
                    },
                    "action": "show_message",
                    "lane": "interactive",
                    "name": "Evening notice, north site",
                    "params": {
                      "minutes": 60,
                      "text": "The clocks restart at 22:00"
                    },
                    "rollout": {
                      "advance": "auto",
                      "max_concurrent": 10,
                      "waves": [
                        1,
                        "50%"
                      ]
                    },
                    "targets": {
                      "endpoints": [
                        "office"
                      ],
                      "select": "site = north"
                    },
                    "timeout": 1800,
                    "window": {
                      "days": [
                        "mon",
                        "tue",
                        "wed",
                        "thu",
                        "fri"
                      ],
                      "hours": "17:00-21:00"
                    }
                  },
                  "state": "paused",
                  "updated_at": "2026-01-15T17:01:10Z",
                  "wave": 0,
                  "waves": 2
                },
                "schema": {
                  "$ref": "#/components/schemas/JobView"
                }
              }
            },
            "description": "Paused: the job, with every device."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no job 7"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no job with this id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "job 7 is paused, not running"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The job is not running: paused, completed or cancelled."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Pause a job",
        "tags": [
          "jobs"
        ]
      }
    },
    "/api/tenants/{tenant}/jobs/{id}/resume": {
      "post": {
        "description": "Devices of a paused job start again as the rollout allows, whether it\nwas paused by hand or by its abort threshold; the threshold then pauses\nit again only on a new failure. A `job.resumed` event is stored and the\nchange is added to the audit trail.",
        "operationId": "resume_job",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The job's id.",
            "example": 7,
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "abort_seen": 0,
                  "counts": {
                    "cancelled": 0,
                    "failed": 0,
                    "queued": 1,
                    "running": 1,
                    "succeeded": 0,
                    "timed_out": 0,
                    "waiting_window": 0
                  },
                  "created_at": "2026-01-15T16:55:00Z",
                  "created_by": "admin",
                  "executions": [
                    {
                      "action_id": 600,
                      "attempt": 1,
                      "device": "CG0001",
                      "endpoint": "office",
                      "seq": 0,
                      "started_at": "2026-01-15T17:00:05Z",
                      "state": "running",
                      "wave": 0,
                      "zone": "America/Chicago"
                    },
                    {
                      "attempt": 1,
                      "device": "CG0002",
                      "endpoint": "office",
                      "seq": 1,
                      "state": "queued",
                      "wave": 1,
                      "zone": "America/Chicago"
                    }
                  ],
                  "id": 7,
                  "matched": 2,
                  "no_zone": 0,
                  "spec": {
                    "abort": {
                      "after": 5,
                      "failed_percent": 20
                    },
                    "action": "show_message",
                    "lane": "interactive",
                    "name": "Evening notice, north site",
                    "params": {
                      "minutes": 60,
                      "text": "The clocks restart at 22:00"
                    },
                    "rollout": {
                      "advance": "auto",
                      "max_concurrent": 10,
                      "waves": [
                        1,
                        "50%"
                      ]
                    },
                    "targets": {
                      "endpoints": [
                        "office"
                      ],
                      "select": "site = north"
                    },
                    "timeout": 1800,
                    "window": {
                      "days": [
                        "mon",
                        "tue",
                        "wed",
                        "thu",
                        "fri"
                      ],
                      "hours": "17:00-21:00"
                    }
                  },
                  "state": "running",
                  "updated_at": "2026-01-15T17:01:10Z",
                  "wave": 0,
                  "waves": 2
                },
                "schema": {
                  "$ref": "#/components/schemas/JobView"
                }
              }
            },
            "description": "Resumed: the job, with every device."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no job 7"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no job with this id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "job 7 is running, not paused"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The job is not paused: running, completed or cancelled."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Resume a job",
        "tags": [
          "jobs"
        ]
      }
    },
    "/api/tenants/{tenant}/jobs/{id}/retry-failed": {
      "post": {
        "description": "Queues every device of the job that failed or timed out again, as its\nnext attempt: a new action, started as the rollout allows (a paused job\nstays paused until it is resumed). A completed job runs again. The\nchange is added to the audit trail.",
        "operationId": "retry_failed_job",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The job's id.",
            "example": 7,
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "abort_seen": 0,
                  "counts": {
                    "cancelled": 0,
                    "failed": 0,
                    "queued": 1,
                    "running": 0,
                    "succeeded": 1,
                    "timed_out": 0,
                    "waiting_window": 0
                  },
                  "created_at": "2026-01-15T16:55:00Z",
                  "created_by": "admin",
                  "executions": [
                    {
                      "action_id": 600,
                      "attempt": 1,
                      "device": "CG0001",
                      "endpoint": "office",
                      "finished_at": "2026-01-15T17:01:10Z",
                      "seq": 0,
                      "started_at": "2026-01-15T17:00:05Z",
                      "state": "succeeded",
                      "wave": 0,
                      "zone": "America/Chicago"
                    },
                    {
                      "attempt": 1,
                      "device": "CG0002",
                      "endpoint": "office",
                      "seq": 1,
                      "state": "queued",
                      "wave": 1,
                      "zone": "America/Chicago"
                    }
                  ],
                  "id": 7,
                  "matched": 2,
                  "no_zone": 0,
                  "spec": {
                    "abort": {
                      "after": 5,
                      "failed_percent": 20
                    },
                    "action": "show_message",
                    "lane": "interactive",
                    "name": "Evening notice, north site",
                    "params": {
                      "minutes": 60,
                      "text": "The clocks restart at 22:00"
                    },
                    "rollout": {
                      "advance": "auto",
                      "max_concurrent": 10,
                      "waves": [
                        1,
                        "50%"
                      ]
                    },
                    "targets": {
                      "endpoints": [
                        "office"
                      ],
                      "select": "site = north"
                    },
                    "timeout": 1800,
                    "window": {
                      "days": [
                        "mon",
                        "tue",
                        "wed",
                        "thu",
                        "fri"
                      ],
                      "hours": "17:00-21:00"
                    }
                  },
                  "state": "running",
                  "updated_at": "2026-01-15T17:01:10Z",
                  "wave": 1,
                  "waves": 2
                },
                "schema": {
                  "$ref": "#/components/schemas/JobView"
                }
              }
            },
            "description": "Queued again: the job, with every device."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no job 7"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no job with this id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "job 7 has no failed or timed out device"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No device failed or timed out, or the job is cancelled."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Retry failed devices",
        "tags": [
          "jobs"
        ]
      }
    },
    "/api/tenants/{tenant}/listeners": {
      "get": {
        "description": "Every listener, with how it is doing on the instance that answers: whether it runs, the address it bound (http) or the broker it uses (mqtt), why it does not run, and the endpoints on it. The mqtt password is shown only as `password_set`. Each instance runs every listener; ask another instance to see how it is doing there.",
        "operationId": "list_listeners",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "address": "0.0.0.0:8080",
                    "endpoints": [
                      "office"
                    ],
                    "error": null,
                    "id": "public",
                    "listen": "0.0.0.0:8080",
                    "password_set": false,
                    "running": true,
                    "stopped": false,
                    "type": "http"
                  },
                  {
                    "address": "mqtts://mqtt.example.com:8883",
                    "broker": "mqtts://mqtt.example.com:8883",
                    "endpoints": [],
                    "error": null,
                    "id": "broker",
                    "password_set": true,
                    "running": true,
                    "stopped": false,
                    "type": "mqtt",
                    "username": "houradvantage",
                    "window": 100
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/ListenerInfo"
                  },
                  "type": "array"
                }
              }
            },
            "description": "All of them."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List listeners",
        "tags": [
          "setup"
        ]
      },
      "post": {
        "description": "Adds a listener, and starts it on every instance: an `http` listener binds `listen` (IP:port) and devices make HTTP requests to it; an `mqtt` listener connects to `broker` and takes the messages devices publish on the topics of its endpoints. Give it an endpoint (`POST /api/tenants/{tenant}/endpoints`) to route devices to a package. The port of a new http listener is taken before anything is saved, so a port in use refuses the change. A port no listener used before is answered with a `Warning` header: open it on your load balancer and firewall too. Recorded in the audit trail, the password left out.",
        "operationId": "create_listener",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "id": "public",
                "listen": "0.0.0.0:8080",
                "type": "http"
              },
              "schema": {
                "$ref": "#/components/schemas/ListenerConfig"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "address": "0.0.0.0:8080",
                  "endpoints": [],
                  "error": null,
                  "id": "public",
                  "listen": "0.0.0.0:8080",
                  "password_set": false,
                  "running": true,
                  "stopped": false,
                  "type": "http"
                },
                "schema": {
                  "$ref": "#/components/schemas/ListenerInfo"
                }
              }
            },
            "description": "Added: as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "listener 'public': listen must be IP:port, got '8080': invalid socket address syntax"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a listener (an unknown field, a missing `id` or `type`), or the listener is not valid: an id that is not 1-64 letters, digits, '-' or '_'; `listen` that is not IP:port; a broker URL that is not mqtt:// or mqtts://; http settings on an mqtt listener or the other way round; `proxy_protocol` while `trusted_proxies` is empty."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "listener 'public' already exists"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A listener with that id exists, its port is taken, or the settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Add a listener",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/listeners/{id}": {
      "delete": {
        "description": "Removes a listener from every instance: it stops (requests under way finish first) and is forgotten, with whether it was stopped by hand. A listener that an endpoint uses cannot be removed: remove the endpoint or move it to another listener first. Recorded in the audit trail.",
        "operationId": "delete_listener",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The listener's id.",
            "example": "public",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "address": "0.0.0.0:8080",
                  "endpoints": [],
                  "error": null,
                  "id": "public",
                  "listen": "0.0.0.0:8080",
                  "password_set": false,
                  "running": false,
                  "stopped": false,
                  "type": "http"
                },
                "schema": {
                  "$ref": "#/components/schemas/ListenerInfo"
                }
              }
            },
            "description": "Removed: as it was."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown listener 'public'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no listener with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "listener 'public' is used by endpoint 'office'; remove or move its endpoints first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "An endpoint uses it, or the settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Remove a listener",
        "tags": [
          "setup"
        ]
      },
      "get": {
        "description": "One listener, with how it is doing on the instance that answers (see `GET /api/tenants/{tenant}/listeners`).",
        "operationId": "show_listener",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The listener's id.",
            "example": "public",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "address": "0.0.0.0:8080",
                  "allow_from": [
                    "192.0.2.0/24"
                  ],
                  "endpoints": [
                    "office"
                  ],
                  "error": null,
                  "id": "public",
                  "listen": "0.0.0.0:8080",
                  "password_set": false,
                  "running": true,
                  "stopped": false,
                  "type": "http"
                },
                "schema": {
                  "$ref": "#/components/schemas/ListenerInfo"
                }
              }
            },
            "description": "As it is now."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown listener 'public'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no listener with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a listener",
        "tags": [
          "setup"
        ]
      },
      "patch": {
        "description": "Changes a listener's settings on every instance. A listener whose address, PROXY protocol setting or broker settings change is restarted (requests under way finish first); one whose address lists change carries on, and the new lists apply from the next request. A listener stopped by hand stays stopped. A change that would leave one of its endpoints unable to serve is refused. A port no listener used before is answered with a `Warning` header. Recorded in the audit trail, the password left out.",
        "operationId": "update_listener",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The listener's id.",
            "example": "public",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "allow_from": [
                  "192.0.2.0/24"
                ]
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "description": "A JSON merge patch (RFC 7396) of its settings: the fields to change. Objects merge, null removes a field (back to its default), arrays and values replace. `id` may only repeat the id it has.",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "address": "0.0.0.0:8080",
                  "allow_from": [
                    "192.0.2.0/24"
                  ],
                  "endpoints": [
                    "office"
                  ],
                  "error": null,
                  "id": "public",
                  "listen": "0.0.0.0:8080",
                  "password_set": false,
                  "running": true,
                  "stopped": false,
                  "type": "http"
                },
                "schema": {
                  "$ref": "#/components/schemas/ListenerInfo"
                }
              }
            },
            "description": "Changed: as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the id cannot be changed; add a new one and remove this one"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a JSON object, it changes the id, or the listener is not valid once patched (see `POST /api/tenants/{tenant}/listeners`), or the change would leave one of its endpoints unable to serve."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown listener 'public'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no listener with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "listener 'public' binding 0.0.0.0:8081: Address already in use (os error 98)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Its new port is taken, or the settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Change a listener",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/listeners/{id}/start": {
      "post": {
        "description": "Starts a listener that was stopped by hand, or that failed to start, on every instance: an http listener binds\nits port, an mqtt listener connects to its broker. Starting one that runs already changes nothing. The listener\ncounts as started even when it cannot start on this instance: the 409 says why, `GET /api/tenants/{tenant}/listeners/{id}` shows\nit in `error`, and starting it again tries again. Recorded in the audit trail.",
        "operationId": "start_listener",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The listener's id.",
            "example": "public",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "address": "0.0.0.0:8080",
                  "endpoints": [
                    "office"
                  ],
                  "error": null,
                  "id": "public",
                  "listen": "0.0.0.0:8080",
                  "password_set": false,
                  "running": true,
                  "stopped": false,
                  "type": "http"
                },
                "schema": {
                  "$ref": "#/components/schemas/ListenerInfo"
                }
              }
            },
            "description": "Started: the listener as it is now."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown listener 'public'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no listener with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "listener 'public' binding 0.0.0.0:8080: Address already in use (os error 98)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "It could not start on this instance: its port is taken, or (mqtt) its broker settings do not work. `error` says why."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Start a listener",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/listeners/{id}/stop": {
      "post": {
        "description": "Stops the listener on every instance: an http listener closes its port once the requests under way have\nfinished (5 seconds at most), an mqtt listener disconnects from its broker. Its devices cannot reach the gateway\nuntil it is started again, and commands for them wait. It stays stopped, across restarts too, until you start it.\nStopping a listener that is stopped already changes nothing. Recorded in the audit trail.",
        "operationId": "stop_listener",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The listener's id.",
            "example": "public",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "address": "0.0.0.0:8080",
                  "endpoints": [
                    "office"
                  ],
                  "error": null,
                  "id": "public",
                  "listen": "0.0.0.0:8080",
                  "password_set": false,
                  "running": false,
                  "stopped": true,
                  "type": "http"
                },
                "schema": {
                  "$ref": "#/components/schemas/ListenerInfo"
                }
              }
            },
            "description": "Stopped: the listener as it is now."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown listener 'public'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no listener with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Stop a listener",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/packages": {
      "get": {
        "description": "Every line of the tenant's own policy packages (a name with a\nmajor.minor version, such as `clocks@1.0`): the revision active for it,\nhow many revisions are kept, and what this instance runs of it.",
        "operationId": "tenant_packages",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "active": {
                      "activated_at": "2026-10-07T08:00:00Z",
                      "activated_by": "dealer-ops",
                      "hash": "sha256:9f2c...",
                      "revision": 2,
                      "version": "1.0.1"
                    },
                    "line": "clock-lifecycle@1.0",
                    "name": "clock-lifecycle",
                    "revisions": 2,
                    "running": {
                      "id": "clock-lifecycle@1.0.1",
                      "revision": 2
                    }
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/PackageLine"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The tenant's package lines, in line order."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List the tenant's packages",
        "tags": [
          "packages"
        ]
      },
      "post": {
        "description": "Takes a bundle of a policy package built with `hourctl pkg build`,\nchecks it as `POST /api/packages` checks a bundle (its files and hash,\nthe host API, the Lua compiled, its hooks, its scenarios run and\npassing) and keeps it as the tenant's package's next revision. A\nprotocol package is the install's, and is refused here. With\n`activate=true` the revision is also activated. The change is added to\nthe audit trail.",
        "operationId": "tenant_push",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "`true` makes it the active revision of its line at once, as\nactivating it does (for development: push, activate, try). False\nunless given.",
            "example": true,
            "in": "query",
            "name": "activate",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/gzip": {
              "schema": {
                "items": {
                  "format": "int32",
                  "minimum": 0,
                  "type": "integer"
                },
                "type": "array"
              }
            }
          },
          "description": "The bundle (.tar.gz).",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "hash": "sha256:9f2c...",
                  "host_api": 2,
                  "line": "clock-lifecycle@1.0",
                  "name": "clock-lifecycle",
                  "new": false,
                  "pushed_at": "2026-10-07T08:00:00Z",
                  "pushed_by": "dealer-ops",
                  "revision": 1,
                  "scenarios": 1,
                  "size": 1201,
                  "version": "1.0.0"
                },
                "schema": {
                  "$ref": "#/components/schemas/Pushed"
                }
              }
            },
            "description": "Pushed before: the revision it was."
          },
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "hash": "sha256:9f2c...",
                  "host_api": 2,
                  "line": "clock-lifecycle@1.0",
                  "name": "clock-lifecycle",
                  "new": true,
                  "pushed_at": "2026-10-07T08:00:00Z",
                  "pushed_by": "dealer-ops",
                  "revision": 1,
                  "scenarios": 1,
                  "size": 1201,
                  "version": "1.0.0"
                },
                "schema": {
                  "$ref": "#/components/schemas/Pushed"
                }
              }
            },
            "description": "Kept as a new revision."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "zk-push@3.4.0 is a protocol package, which is the install's: push it to /api/packages"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Refused: not a bundle, a protocol package, a host API this build does not run, Lua that does not compile, a hook that is not one, or a scenario that fails."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Push a policy package bundle",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/tenants/{tenant}/packages/adopted": {
      "get": {
        "description": "Each with what the tenant adopted (a major version it follows, or the\nversion it pins) and the version that takes now.",
        "operationId": "adopted",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "adopted": "2",
                    "follows": true,
                    "name": "overtime",
                    "version": "2.4.0"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/AdoptedPackage"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The tenant's adoptions, by name."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List the shared packages the tenant adopted",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/tenants/{tenant}/packages/adopted/{name}": {
      "delete": {
        "description": "The tenant no longer adopts the shared package. Refused while one of\nits endpoints names it as its `policy`. The change is added to the\naudit trail.",
        "operationId": "drop_adopted",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The shared package's name.",
            "example": "overtime",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "adopted": "2",
                  "follows": true,
                  "name": "overtime",
                  "version": "2.4.0"
                },
                "schema": {
                  "$ref": "#/components/schemas/AdoptedPackage"
                }
              }
            },
            "description": "Dropped: what the tenant had adopted."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "endpoint 'office': no policy package of the tenant matches 'overtime@2' (push it with `hourctl pkg push`, or adopt a shared one with `hourctl pkg adopt`)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "An endpoint of the tenant names it as its policy."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the tenant has not adopted the shared package overtime"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant has not adopted it."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Drop a shared package",
        "tags": [
          "packages"
        ]
      },
      "put": {
        "description": "Follows a major version of a shared package (`{\"version\": \"2\"}`), or\npins one version (`{\"version\": \"2.3.1\"}`), in place of what the tenant\nadopted of it before. The tenant's endpoints then name it as their\n`policy` (`overtime@2`). A version that takes nothing published yet is\nrefused, and so is a change that leaves an endpoint without its policy.\nA tenant that takes another version for it is sent `package.updated`,\nkept with the change. The change is added to the audit trail.",
        "operationId": "adopt",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The shared package's name.",
            "example": "overtime",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "version": "2"
              },
              "schema": {
                "$ref": "#/components/schemas/Adopt"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "adopted": "2",
                  "follows": true,
                  "name": "overtime",
                  "version": "2.4.0"
                },
                "schema": {
                  "$ref": "#/components/schemas/AdoptedPackage"
                }
              }
            },
            "description": "Adopted: what it takes now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "'2.3' is neither a major version to follow (2) nor a version to pin (2.3.1)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a major version or a whole version, or an endpoint naming the package would no longer find it."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "no version of the shared package overtime is published that overtime@3 takes"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No shared package of that name is published at a version it takes."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Adopt a shared package",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/tenants/{tenant}/packages/{name}": {
      "get": {
        "description": "Every revision kept, each active line with what every instance runs of\nit, and the catalog of what this instance runs: for a policy package,\nits manifest and its hooks.",
        "operationId": "tenant_package",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The package's name.",
            "example": "clock-lifecycle",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "catalog": [
                    {
                      "actions": [],
                      "commands": [],
                      "hash": "sha256:9f2c...",
                      "hooks": [
                        "back",
                        "joined",
                        "moved"
                      ],
                      "id": "clock-lifecycle@1.0.0",
                      "line": "clock-lifecycle@1.0",
                      "manifest": {
                        "delivery": "ack",
                        "description": "A clock is set up when it joins.",
                        "host_api": 2,
                        "kind": "policy",
                        "name": "clock-lifecycle",
                        "transports": [
                          "http"
                        ],
                        "vendor": "",
                        "version": "1.0.0"
                      },
                      "options": [],
                      "revision": 1,
                      "routes": [],
                      "settings": []
                    }
                  ],
                  "lines": [
                    {
                      "activated_at": "2026-10-07T08:00:00Z",
                      "activated_by": "dealer-ops",
                      "hash": "sha256:9f2c...",
                      "instances": [
                        {
                          "error": null,
                          "instance": "houradvantage-0",
                          "running": 1,
                          "wanted": 1
                        }
                      ],
                      "line": "clock-lifecycle@1.0",
                      "revision": 1
                    }
                  ],
                  "name": "clock-lifecycle",
                  "revisions": [
                    {
                      "active": true,
                      "hash": "sha256:9f2c...",
                      "host_api": 2,
                      "line": "clock-lifecycle@1.0",
                      "name": "clock-lifecycle",
                      "pushed_at": "2026-10-07T08:00:00Z",
                      "pushed_by": "dealer-ops",
                      "revision": 1,
                      "size": 1201,
                      "version": "1.0.0"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/PackageDetail"
                }
              }
            },
            "description": "The package: its revisions, its active lines and its catalog."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "no package 'clock-lifecycle'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The tenant has no such package."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get one of the tenant's packages",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/tenants/{tenant}/packages/{name}/revisions/{revision}/activate": {
      "post": {
        "description": "Makes a kept revision the one every instance runs for its line, as\n`POST /api/packages/{name}/revisions/{revision}/activate` does: this\ninstance loads it and checks that every endpoint of the tenant naming\nit as its `policy` still finds it. Rolling back is activating an\nearlier revision. The change is added to the audit trail.",
        "operationId": "tenant_activate",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The package's name.",
            "example": "clock-lifecycle",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The revision, counted per package from 1 in the order pushed.",
            "example": 2,
            "in": "path",
            "name": "revision",
            "required": true,
            "schema": {
              "format": "int32",
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": true,
                  "changes": [
                    "clock-lifecycle@1.0 revision 2 (1.0.1) active",
                    "endpoint 'office' now uses policy clock-lifecycle@1.0.1"
                  ],
                  "line": "clock-lifecycle@1.0",
                  "name": "clock-lifecycle",
                  "revision": 2,
                  "version": "1.0.1"
                },
                "schema": {
                  "$ref": "#/components/schemas/Activated"
                }
              }
            },
            "description": "Active: what changed."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Refused: this instance cannot run the revision, or an endpoint naming its line would no longer find it."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "package clock-lifecycle has no revision 8"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The package has no such revision."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Activate a revision of the tenant's package",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/tenants/{tenant}/packages/{name}/revisions/{revision}/bundle": {
      "get": {
        "description": "The bundle of a kept revision, byte for byte as it was pushed.",
        "operationId": "tenant_bundle",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The package's name.",
            "example": "clock-lifecycle",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The revision.",
            "example": 2,
            "in": "path",
            "name": "revision",
            "required": true,
            "schema": {
              "format": "int32",
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/gzip": {
                "schema": {
                  "items": {
                    "format": "int32",
                    "minimum": 0,
                    "type": "integer"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The bundle (.tar.gz)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "package clock-lifecycle has no revision 8"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The package has no such revision."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Download a revision's bundle of the tenant's package",
        "tags": [
          "packages"
        ]
      }
    },
    "/api/tenants/{tenant}/peer/seen": {
      "post": {
        "description": "What this instance knows from memory of when the given devices were last seen and last refused, and what it has\ncounted of their messages and not yet written: for the instance listing devices (`GET\n/api/tenants/{tenant}/devices`), which asks every instance and keeps the latest. Devices this instance does not hold\nin memory are left out. It takes an instance token (`Authorization: Bearer cgp1...`) as well as the login.",
        "operationId": "peer_seen",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "devices": [
                  "office/CG0001",
                  "office/CG0002"
                ]
              },
              "schema": {
                "$ref": "#/components/schemas/SeenAsk"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "device": "CG0001",
                    "endpoint": "office",
                    "health": {
                      "errors": 0,
                      "messages": 12
                    },
                    "key_refused_at": null,
                    "last_seen": "2026-01-15T14:00:02Z",
                    "params": {},
                    "remote_ip": "192.0.2.10"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/Sighting"
                  },
                  "type": "array"
                }
              }
            },
            "description": "What this instance knows of each device it holds."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get this instance's sightings",
        "tags": [
          "instance"
        ]
      }
    },
    "/api/tenants/{tenant}/peer/stream": {
      "get": {
        "description": "What happens on this instance, as it happens, one JSON object per line (`application/x-ndjson`): for the instance\nrelaying `GET /api/tenants/{tenant}/stream`, which opens it on every instance with an instance token\n(`Authorization: Bearer cgp1...`) or the caller's own login. The lines are those of `GET\n/api/tenants/{tenant}/stream`, from this instance alone. It runs until the reader goes.",
        "operationId": "peer_stream",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/x-ndjson": {
                "example": {
                  "data": {
                    "records": 12
                  },
                  "instance": "gw-2",
                  "kind": "dropped"
                },
                "schema": {
                  "$ref": "#/components/schemas/LiveLine"
                }
              }
            },
            "description": "One JSON object per line."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Stream this instance's events",
        "tags": [
          "instance"
        ]
      }
    },
    "/api/tenants/{tenant}/peer/wire": {
      "get": {
        "description": "This instance's part of a live wire capture, for the instance relaying `GET /api/tenants/{tenant}/wire/live`, which\nopens it on every instance with an instance token (`Authorization: Bearer cgp1...`, made from the shared\n`HOURADVANTAGE_SECRET_KEY`, good for that one request for 30 seconds) or, without a secret key, the caller's own\nlogin. The lines are those of `GET /api/tenants/{tenant}/wire/live`, from this instance alone, ending with an `end`\nline. Opened with a login or an API token instead of an instance token, it is recorded in the audit trail; use `GET\n/api/tenants/{tenant}/wire/live` to watch every instance.",
        "operationId": "peer_wire",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only the requests that name this device, and their answers (as\n`/api/tenants/{tenant}/wire/live`).",
            "example": "CG0001",
            "in": "query",
            "name": "device",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only the requests for this endpoint, and their answers.",
            "example": "office",
            "in": "query",
            "name": "endpoint",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "How long, in milliseconds: what is left of the relay's capture.\n900000 (15 minutes) unless given, at most 7200000 (2 hours).",
            "example": 299000,
            "in": "query",
            "name": "for_ms",
            "required": false,
            "schema": {
              "format": "int64",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "description": "How many bytes of device traffic: what is left of the relay's\ncapture. At most 67108864 (64 MiB), which is also the default.",
            "example": 67108864,
            "in": "query",
            "name": "max_bytes",
            "required": false,
            "schema": {
              "format": "int64",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/x-ndjson": {
                "example": {
                  "data": {
                    "bytes": 18234,
                    "reason": "time"
                  },
                  "instance": "gw-2",
                  "kind": "end"
                },
                "schema": {
                  "$ref": "#/components/schemas/LiveLine"
                }
              }
            },
            "description": "One JSON object per line, until the capture ends."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown endpoint 'office'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`endpoint` names no endpoint this instance serves."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Capture this instance's wire",
        "tags": [
          "instance"
        ]
      }
    },
    "/api/tenants/{tenant}/requests": {
      "get": {
        "description": "The device messages the instance that answers is handling now, the oldest first, and what each is doing: the\nroute the package chose, and the phase it is in (`pool_wait`, `mailbox_wait`, `package_run`, `store_writes`...),\nwith how long it has been in hand (real seconds, and on the instance's clock, which stands still where time is\nvirtual). A message that is in hand for longer than the slow line has something it waits for; this says what.\nAll of them are listed, the oldest first: what is in hand is what the instance is handling at once, which is bounded\nby its work, and a list that is cut would leave out the one that is stuck. Each instance has its own.",
        "operationId": "requests",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "clock_seconds": 0.8,
                    "device": "CG0001",
                    "doing": "store_writes",
                    "endpoint": "office",
                    "real_seconds": 0.8,
                    "route": "attlog"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/RequestInHand"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The messages in hand, the oldest first."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List the requests in hand",
        "tags": [
          "instance"
        ]
      }
    },
    "/api/tenants/{tenant}/resume": {
      "post": {
        "description": "Sets a suspended or stopped tenant's status to `active`, on every instance: its devices are taken in again (and\nsend what they kept), and its commands, jobs, sync groups and sinks carry on where they were. Only an install token\nreaches this route. Recorded in the audit trail.",
        "operationId": "resume_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "external_ids": {
                    "crm": "C-1042"
                  },
                  "id": "acme",
                  "limits": {
                    "devices": 50
                  },
                  "metadata": {
                    "region": "midwest"
                  },
                  "name": "Acme Manufacturing",
                  "status": "active"
                },
                "schema": {
                  "$ref": "#/components/schemas/TenantConfig"
                }
              }
            },
            "description": "Resumed: the tenant as it is now."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown tenant 'acme'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no tenant with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the settings were changed elsewhere (another gateway instance) in the meantime; try again"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Resume a tenant",
        "tags": [
          "tenants"
        ]
      }
    },
    "/api/tenants/{tenant}/secrets": {
      "get": {
        "description": "Every secret's name, scope and dates, never its value: the tenant's first, then each package's, by package and\nname. Packages read them with `secrets.get(name)`, a package's own value of a name before the tenant's.",
        "operationId": "list_secrets",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "name": "api_key",
                    "updated_at": "2026-01-15T08:00:00Z",
                    "updated_by": "admin"
                  },
                  {
                    "name": "api_key",
                    "package": "zk-push",
                    "updated_at": "2026-01-15T08:05:00Z",
                    "updated_by": "admin"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SecretView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every secret, without its value."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List secrets",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/secrets/{name}": {
      "delete": {
        "description": "Deletes a secret of the tenant or, with `?package=`, of one package. Refused while a package in use requires it\n(`[requires]` in its package.toml) and the other scope does not give it: activate a revision that does not\nrequire it first. Recorded in the audit trail.",
        "operationId": "delete_secret",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The secret's name.",
            "example": "api_key",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The package (by name, every version of it) the value is for: 1 to 64\nletters, digits, '_', '-' or '.'. Absent: the tenant's, for every package.",
            "example": "zk-push",
            "in": "query",
            "name": "package",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted. No body."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "a secret name is 1 to 64 letters, digits, '_', '-' or '.'; 'api key' is not"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The name or the package is not 1 to 64 letters, digits, '_', '-' or '.'."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no secret 'api_key'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no such secret in that scope."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "secret 'api_key' cannot be deleted: package zk-push@3.4.0 requires it ([requires] in its package.toml) and would be left without it; activate a revision that does not require it first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A package in use requires it and would be left without it."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Delete a secret",
        "tags": [
          "setup"
        ]
      },
      "put": {
        "description": "Sets a secret, for the tenant or, with `?package=`, for one package (every version of it), adding it or\nreplacing its value. The value is sealed at rest and never given back by the API; the audit trail records who\nset which secret, never the request's body. The instance that answers reads the new value before it answers; the\nothers read it when they take in the config version the change makes (`houradvantage-config-version`).",
        "operationId": "set_secret",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The secret's name: 1 to 64 letters, digits, '_', '-' or '.'.",
            "example": "api_key",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The package (by name, every version of it) the value is for: 1 to 64\nletters, digits, '_', '-' or '.'. Absent: the tenant's, for every package.",
            "example": "zk-push",
            "in": "query",
            "name": "package",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "value": "a-long-random-string"
              },
              "schema": {
                "$ref": "#/components/schemas/NewValue"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "name": "api_key",
                  "updated_at": "2026-01-15T08:00:00Z",
                  "updated_by": "admin"
                },
                "schema": {
                  "$ref": "#/components/schemas/SecretView"
                }
              }
            },
            "description": "Set: the secret as listed, without its value."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "a value is at most 64 KiB"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not `{\"value\": \"...\"}`, the name or the package is not 1 to 64 letters, digits, '_', '-' or '.', or the value is over 64 KiB."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "secret 'api_key' is gone again"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "It was deleted again by another request before it could be read back."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Set a secret",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/sinks": {
      "get": {
        "description": "Every sink: where it sends events and which ones. The signing secret is shown only as `secret_set`. `GET /api/tenants/{tenant}/sinks/status` shows how each one's deliveries are going.",
        "operationId": "list_sinks",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "events": [
                      "punch"
                    ],
                    "id": "payroll",
                    "secret_set": true,
                    "type": "webhook",
                    "url": "https://example.com/houradvantage"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SinkView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "All of them."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List sinks",
        "tags": [
          "setup"
        ]
      },
      "post": {
        "description": "Adds a sink: a `webhook` that the events of the endpoints and sync groups naming it in their `sinks` are posted to, as `{\"events\": [...]}`, in order, each batch until it answers 2xx. With `secret`, each post is signed: `x-houradvantage-timestamp` carries the Unix time in seconds and `x-houradvantage-signature` carries `v1=` and the hex HMAC-SHA256, keyed with the secret, of the timestamp, a '.', and the body. `events` limits it to those event types; empty or absent, it is sent the default set: every type but the detailed ones sent only when named (the Events reference lists them). A sink is sent nothing until an endpoint or a sync group names it (`PATCH /api/tenants/{tenant}/endpoints/{id}`); it then starts with the events stored from that moment on. Recorded in the audit trail, the secret left out.",
        "operationId": "create_sink",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "events": [
                  "punch"
                ],
                "id": "payroll",
                "secret": "a-long-random-string",
                "type": "webhook",
                "url": "https://example.com/houradvantage"
              },
              "schema": {
                "$ref": "#/components/schemas/SinkConfig"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "punch"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://example.com/houradvantage"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "Added: as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "webhook sink 'payroll' needs url"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a sink (an unknown field, a missing `id` or `type`), or the sink is not valid: an id that is not 1-64 letters, digits, '-' or '_' (or is `status`); a type other than `webhook`; a missing `url`, or one that is not http or https."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sink 'payroll' already exists"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A sink with that id exists, or the settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Add a sink",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/sinks/status": {
      "get": {
        "description": "How each sink that an endpoint or a sync group sends events to is getting on: how many events wait for it, since\nwhen, when it last took some, whether it is refusing them and why, and where it is in the events. A sink nothing\nsends events to is not listed. One sink is delivered to by one instance at a time; this\nreads what that instance has recorded, so any instance gives the same answer. A sink that refuses is tried again\nuntil it takes the events, however long that takes: nothing is skipped unless you move it (`POST\n/api/tenants/{tenant}/sinks/{id}/position`). A sink whose state cannot be read from the\ndatabase right now is left out of the answer.",
        "operationId": "sink_status",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "behind": 12,
                    "delivered_at": "2026-01-15T07:59:30Z",
                    "dropped": null,
                    "error": "sink 'payroll': webhook returned 503 Service Unavailable",
                    "failing_since": "2026-01-15T08:00:05Z",
                    "oldest_waiting_at": "2026-01-15T08:00:00Z",
                    "position": 4180,
                    "sink": "payroll"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SinkStatus"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every sink events are sent to, whose state could be read."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List sink deliveries",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/sinks/{id}": {
      "delete": {
        "description": "Removes a sink: nothing more is sent to it, and its place in the events goes with it: a sink made again with its id starts as a new sink does, with the events stored from then on. A sink that an endpoint or a sync group names cannot be removed: take it off their `sinks` first. Recorded in the audit trail.",
        "operationId": "delete_sink",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "punch"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://example.com/houradvantage"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "Removed: as it was."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sink 'payroll' is used by endpoint 'office'; take it off its endpoints first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "An endpoint or a sync group names it, or the settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Remove a sink",
        "tags": [
          "setup"
        ]
      },
      "get": {
        "description": "One sink, the secret shown only as `secret_set`.",
        "operationId": "show_sink",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "punch"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://example.com/houradvantage"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "As it is now."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a sink",
        "tags": [
          "setup"
        ]
      },
      "patch": {
        "description": "Changes a sink's settings. Its deliveries restart with the new settings on the instance delivering to it; a batch under way may be sent again. Where it is in the events does not change. Set `secret` to null to stop signing. Recorded in the audit trail, the secret left out.",
        "operationId": "update_sink",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "events": [
                  "punch",
                  "user"
                ]
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "description": "A JSON merge patch (RFC 7396) of its settings: the fields to change. Objects merge, null removes a field (back to its default), arrays and values replace. `id` may only repeat the id it has.",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "events": [
                    "punch",
                    "user"
                  ],
                  "id": "payroll",
                  "secret_set": true,
                  "type": "webhook",
                  "url": "https://example.com/houradvantage"
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkView"
                }
              }
            },
            "description": "Changed: as it is now."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sink 'payroll': url must be http or https"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a JSON object, it changes the id, or the sink is not valid once patched (see `POST /api/tenants/{tenant}/sinks`)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the settings were changed elsewhere (another gateway instance) in the meantime; try again"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Change a sink",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/sinks/{id}/position": {
      "post": {
        "description": "Moves a sink along the events by hand: ahead, to skip what it refuses or no longer wants, or back, to have it\nsent events again from an earlier place. `{\"seq\": n}` makes the next event it is sent the first after `n`;\n`{\"seq\": \"latest\"}` skips every event stored so far. It clears `failing_since`. The instance delivering to it\ncarries on from the new place; a batch it was sending may still arrive. Recorded in the audit trail, saying from\nwhere to where, and told to the sinks with a `sink.moved` event: moving a sink ahead is the only way it loses\nevents it has not taken.",
        "operationId": "move_sink",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sink's id.",
            "example": "payroll",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "seq": "latest"
              },
              "schema": {
                "$ref": "#/components/schemas/PositionBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "from": 3950,
                  "sink": "payroll",
                  "to": 4181
                },
                "schema": {
                  "$ref": "#/components/schemas/SinkMovedView"
                }
              }
            },
            "description": "Moved: from where to where."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no event 5000 yet: the newest is 4181"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`seq` is neither a sequence number of 0 or more nor \"latest\", or it is past the newest event."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sink 'payroll'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no sink with that id that an endpoint or a sync group sends events to."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Move a sink",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/stop": {
      "post": {
        "description": "Sets the tenant's status to `stopped`: as suspending it does, for a tenant that is to stay stopped (being moved\nout, or about to be deleted). Only an install token reaches this route. Recorded in the audit trail.",
        "operationId": "stop_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "external_ids": {
                    "crm": "C-1042"
                  },
                  "id": "acme",
                  "limits": {
                    "devices": 50
                  },
                  "metadata": {
                    "region": "midwest"
                  },
                  "name": "Acme Manufacturing",
                  "status": "stopped"
                },
                "schema": {
                  "$ref": "#/components/schemas/TenantConfig"
                }
              }
            },
            "description": "Stopped: the tenant as it is now."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown tenant 'acme'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no tenant with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the settings were changed elsewhere (another gateway instance) in the meantime; try again"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Stop a tenant",
        "tags": [
          "tenants"
        ]
      }
    },
    "/api/tenants/{tenant}/stream": {
      "get": {
        "description": "What happens on every instance, as it happens, as server-sent events: each event's data is one JSON object with\nits `kind`, the `instance` it happened on, and its `data`. `traffic` is a device message as `GET /api/tenants/{tenant}/traffic`\nshows it, `event` a stored event, `device` a device whose record changed, `command` a command whose state\nchanged. The instance that answers relays every other one's; one it cannot reach is said so (`peer`, with\n`\"state\": \"unreachable\"`) and the view is partial, and one that joins is picked up (`peer`, `\"state\":\n\"connected\"`). A reader too slow to keep up skips ahead, told how many it missed (`dropped`). The stream starts\nwith what happens after it is opened, keeps the connection alive with comments while nothing happens, and runs\nuntil you close it.",
        "operationId": "stream",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/event-stream": {
                "example": {
                  "data": {
                    "at": "2026-01-15T14:00:02Z",
                    "device": "CG0001",
                    "duration_ms": 3,
                    "endpoint": "office",
                    "error": null,
                    "events": 0,
                    "method": "GET",
                    "path": "/office/iclock/getrequest",
                    "query": "SN=CG0001",
                    "remote_ip": "192.0.2.10",
                    "request_body": "",
                    "request_bytes": 0,
                    "response_body": "OK",
                    "route": "getrequest",
                    "seq": 81234,
                    "status": 200
                  },
                  "instance": "gw-1",
                  "kind": "traffic"
                },
                "schema": {
                  "$ref": "#/components/schemas/LiveLine"
                }
              }
            },
            "description": "An event stream (`text/event-stream`); each event's data is one of these."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Watch the live stream",
        "tags": [
          "instance"
        ]
      }
    },
    "/api/tenants/{tenant}/suspend": {
      "post": {
        "description": "Sets the tenant's status to `suspended`, on every instance: everything Connect does for it stops. Its devices'\nrequests are answered 503 and taken in by nobody (an MQTT message is not acknowledged), so a clock keeps what it\nhas and sends it again once the tenant is resumed; no command goes out to them; none of its jobs, sync groups or\nsinks runs. Nothing it has is removed. Suspending a suspended tenant changes nothing. Only an install token reaches\nthis route. Recorded in the audit trail.",
        "operationId": "suspend_tenant",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "external_ids": {
                    "crm": "C-1042"
                  },
                  "id": "acme",
                  "limits": {
                    "devices": 50
                  },
                  "metadata": {
                    "region": "midwest"
                  },
                  "name": "Acme Manufacturing",
                  "status": "suspended"
                },
                "schema": {
                  "$ref": "#/components/schemas/TenantConfig"
                }
              }
            },
            "description": "Suspended: the tenant as it is now."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown tenant 'acme'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no tenant with that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the settings were changed elsewhere (another gateway instance) in the meantime; try again"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The settings were changed on another instance at the same moment (send it again)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Suspend a tenant",
        "tags": [
          "tenants"
        ]
      }
    },
    "/api/tenants/{tenant}/sync": {
      "get": {
        "description": "Every sync group, in the order the settings keep them: its settings,\nthe endpoints that name it, and how many members it has. Every endpoint\nis in a group: an endpoint added without one gets a group of its own,\nnamed after it, with no domains. A group with no domains keeps nothing\nthe same and has no members.",
        "operationId": "list_groups",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "domains": [
                      "people",
                      "access",
                      "lists",
                      "settings",
                      "punches"
                    ],
                    "endpoints": [
                      "office"
                    ],
                    "id": "hq",
                    "lists": {
                      "authority": "group"
                    },
                    "members": 2,
                    "people": {
                      "authority": "group",
                      "biometrics": false
                    },
                    "punches": {
                      "lockout_minutes": 0
                    },
                    "settings": {
                      "authority": "group"
                    },
                    "sinks": [
                      "payroll"
                    ]
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SyncGroupView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every sync group."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List sync groups",
        "tags": [
          "sync"
        ]
      },
      "post": {
        "description": "Adds a group to the settings, which every instance then uses. Only\n`id` is required: every domain is off and every authority is `group`\nunless you say otherwise. Access is always the group's and has no\nsetting. Devices join the group when their endpoint names it (the endpoint's `sync_group`); until then it has no members.\nA group that keeps templates and photos (`people.biometrics` with the\n`people` domain) needs `HOURADVANTAGE_SECRET_KEY` on the instance that\nmakes the change. The change is recorded in the audit trail.",
        "operationId": "create_group",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "domains": [
                  "people",
                  "access",
                  "lists",
                  "settings",
                  "punches"
                ],
                "id": "hq",
                "people": {
                  "authority": "group",
                  "biometrics": false
                },
                "punches": {
                  "lockout_minutes": 5
                },
                "sinks": [
                  "payroll"
                ]
              },
              "schema": {
                "$ref": "#/components/schemas/SyncGroupConfig"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "domains": [
                    "people",
                    "access",
                    "lists",
                    "settings",
                    "punches"
                  ],
                  "endpoints": [],
                  "id": "hq",
                  "lists": {
                    "authority": "group"
                  },
                  "members": 0,
                  "people": {
                    "authority": "group",
                    "biometrics": false
                  },
                  "punches": {
                    "lockout_minutes": 5
                  },
                  "settings": {
                    "authority": "group"
                  },
                  "sinks": [
                    "payroll"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncGroupView"
                }
              }
            },
            "description": "Added: the group as it now is."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq': unknown domain 'badges' (domains are people, access, lists, settings, punches)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not valid: not a sync group (a field it does not have, no `id`), an id that is not 1-64 letters, digits, '-' or '_', an unknown or repeated domain, an unknown sink, a negative `punches.lockout_minutes`, a placement rule that is not valid, or templates kept without HOURADVANTAGE_SECRET_KEY."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' already exists"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A sync group with that id exists."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Add a sync group",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}": {
      "delete": {
        "description": "Removes the group from the settings. Refused while an endpoint names\nit: put its endpoints in another group first. Refused too while the\ngroup keeps any row (deleted ones included), unless you pass\n`confirm_delete_data=true`, which deletes that data with the group.\nNothing is deleted from devices. The change is recorded in the audit\ntrail.",
        "operationId": "delete_group",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "`true`: delete everything the group keeps (its rows, deleted ones\nincluded, credentials, members' states, punch state and old user\nids) along with the group. Default `false`: a group that keeps any\nrow is not removed.",
            "example": true,
            "in": "query",
            "name": "confirm_delete_data",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "domains": [
                    "people"
                  ],
                  "endpoints": [],
                  "id": "hq",
                  "lists": {
                    "authority": "group"
                  },
                  "members": 0,
                  "people": {
                    "authority": "group",
                    "biometrics": false
                  },
                  "punches": {
                    "lockout_minutes": 0
                  },
                  "settings": {
                    "authority": "group"
                  },
                  "sinks": []
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncGroupView"
                }
              }
            },
            "description": "Removed: the group as it was."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' is used by endpoint 'office'; take it off its endpoints first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "An endpoint names the group, or the group keeps data and `confirm_delete_data=true` was not given."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' was removed, but its data could not be deleted: connection closed"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The database cannot be used right now; or, with `confirm_delete_data=true`, the group was removed from the settings but its data could not be deleted."
          }
        },
        "summary": "Remove a sync group",
        "tags": [
          "sync"
        ]
      },
      "get": {
        "description": "The group's settings, its endpoints and member count, and for each\ndomain it keeps (`status`): how many rows it keeps (deleted rows not\ncounted), and how many of its members' rows are in each state, over\nevery member. Members that left the group and are still remembered\ncount too.",
        "operationId": "show_group",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "domains": [
                    "people",
                    "settings"
                  ],
                  "endpoints": [
                    "office"
                  ],
                  "id": "hq",
                  "lists": {
                    "authority": "group"
                  },
                  "members": 2,
                  "people": {
                    "authority": "group",
                    "biometrics": false
                  },
                  "punches": {
                    "lockout_minutes": 0
                  },
                  "settings": {
                    "authority": "group"
                  },
                  "sinks": [
                    "payroll"
                  ],
                  "status": {
                    "people": {
                      "members": {
                        "in_sync": 236,
                        "pending": 3,
                        "unsupported": 1
                      },
                      "rows": 120
                    },
                    "settings": {
                      "members": {
                        "in_sync": 8
                      },
                      "rows": 4
                    }
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncGroupDetail"
                }
              }
            },
            "description": "The group and how it stands."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a sync group",
        "tags": [
          "sync"
        ]
      },
      "patch": {
        "description": "The body is a JSON merge patch (RFC 7396) of the group's settings:\nmembers you give are set, `null` puts one back to its default, and the\nrest stay as they are. A list (`domains`, `sinks`, `placement`) is\nreplaced whole. Taking a domain out stops its syncing at once: nothing\nis deleted from devices, and the group keeps its rows. The id cannot be\nchanged. The change is recorded in the audit trail.",
        "operationId": "update_group",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "domains": [
                  "people",
                  "lists"
                ],
                "lists": {
                  "authority": "shared"
                }
              },
              "schema": {
                "type": "object"
              }
            }
          },
          "description": "A merge patch of the group's settings, which take the fields of SyncGroupConfig.",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "domains": [
                    "people",
                    "access",
                    "lists",
                    "settings",
                    "punches"
                  ],
                  "endpoints": [
                    "office"
                  ],
                  "id": "hq",
                  "lists": {
                    "authority": "group"
                  },
                  "members": 2,
                  "people": {
                    "authority": "group",
                    "biometrics": false
                  },
                  "punches": {
                    "lockout_minutes": 0
                  },
                  "settings": {
                    "authority": "group"
                  },
                  "sinks": [
                    "payroll"
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncGroupView"
                }
              }
            },
            "description": "Changed: the group as it now is."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "the id cannot be changed; add a new one and remove this one"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not a JSON object, it changes the id, or the group it makes is not valid (as for adding one)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Change a sync group",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/access/{kind}/{key}": {
      "delete": {
        "description": "Deletes the row from the registry, leaving a tombstone until every\nmember confirmed the delete, and so from every member. Deleting a row\nthe group does not have changes nothing (`changed`: 0). Stores an\n`access.changed` event (`deleted`: true) and is recorded in the audit\ntrail.",
        "operationId": "delete_access",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The kind of access row: schedule, holiday, access_group or zone.",
            "example": "schedule",
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The row's key.",
            "example": "day",
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 1,
                  "members": {
                    "applies": 2,
                    "not_applicable": 0,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 42
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Deleted: the version of the delete, and how it fares on the members."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "'shift' is not a kind of access row (schedule, holiday, access_group, zone)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`kind` is not a kind of access row."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep access: add 'access' to its domains first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep access."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Delete an access row",
        "tags": [
          "sync"
        ]
      },
      "get": {
        "description": "One access row of the group: a schedule, holiday, access group or\nzone, with its version and, for kinds devices number, its group-wide\nslot. A deleted row is not found.",
        "operationId": "get_access",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The kind of access row: schedule, holiday, access_group or zone.",
            "example": "schedule",
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The row's key, which you choose when you write it. At most 128 characters: it is indexed, and a longer one is refused (400).",
            "example": "day",
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed_at": "2026-01-15T08:00:00Z",
                  "changed_by": "api:admin",
                  "deleted": false,
                  "domain": "access",
                  "fields": {
                    "days": {
                      "mon": [
                        [
                          "08:00",
                          "17:00"
                        ]
                      ],
                      "tue": [
                        [
                          "08:00",
                          "17:00"
                        ]
                      ]
                    },
                    "name": "Day shift"
                  },
                  "key": "day",
                  "kind": "schedule",
                  "slot": 1,
                  "version": 17
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncRowView"
                }
              }
            },
            "description": "The row."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "'shift' is not a kind of access row (schedule, holiday, access_group, zone)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`kind` is not a kind of access row."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "no schedule 'day' in 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id, or the group has no such row (or it is deleted)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get an access row",
        "tags": [
          "sync"
        ]
      },
      "put": {
        "description": "Writes an access row to the registry, and so to every member that\ntakes its kind. The fields by kind, each with `name`:\n\n- `schedule`: `days` (day name `mon`..`sun` to a list of\n  `[\"HH:MM\", \"HH:MM\"]` intervals) and `holiday`.\n- `holiday`: `from`, `to`, `type`.\n- `access_group`: `schedules` (schedule keys) and `doors`.\n- `zone` (anti-passback): `readers` (each `endpoint`, `device`,\n  `reader`, `direction` in or out), `rule` (`anti_passback`, the\n  default, or `timed`), `minutes`, `reset` (`HH:MM`), `mode` (`soft`,\n  or hard by default).\n\nFields you give are set, `null` clears one, those you leave out stay.\nSchedules, holidays and access groups get a group-wide slot when first\nwritten. Writing the same values again changes nothing. Stores an\n`access.changed` event and is recorded in the audit trail.",
        "operationId": "put_access",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The kind of access row: schedule, holiday, access_group or zone.",
            "example": "schedule",
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The row's key, which you choose. At most 128 characters: it is indexed, and a longer one is refused (400).",
            "example": "day",
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "fields": {
                  "days": {
                    "mon": [
                      [
                        "08:00",
                        "17:00"
                      ]
                    ],
                    "tue": [
                      [
                        "08:00",
                        "17:00"
                      ]
                    ]
                  },
                  "name": "Day shift"
                },
                "if_version": 16
              },
              "schema": {
                "$ref": "#/components/schemas/PutRow"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 1,
                  "members": {
                    "applies": 2,
                    "not_applicable": 0,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 42
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Written: the row's version, and how it fares on the members."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "'shift' is not a kind of access row (schedule, holiday, access_group, zone)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`kind` is not a kind of access row."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "access/schedule/day is at version 17, not 16: it was changed in the meantime"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep access, or the row is no longer at `if_version`."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Add or change an access row",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/batch": {
      "post": {
        "description": "Makes up to 10000 changes to the registry in one transaction: all or\nnone. Upserts are made first, in order, then deletes. An `if_version`\nthat does not match, or any row the registry refuses, refuses the\nwhole batch. Sent again, a batch changes nothing more: the same values\nwritten again are no change. People, access, list and settings rows\ncan be written; credentials are written one at a time. A setting's\nvalue goes in `fields.value`; one that any member of its class marks\nsensitive is kept as a secret (sealed, never shown), as the settings\nroute keeps it. Each changed row stores its event\n(`person.changed`, `access.changed`, ...); the batch is recorded in the\naudit trail.",
        "operationId": "batch",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "delete": [
                  {
                    "domain": "people",
                    "key": "1002",
                    "kind": "person"
                  }
                ],
                "upsert": [
                  {
                    "domain": "people",
                    "fields": {
                      "cards": [
                        {
                          "number": "12345"
                        }
                      ],
                      "name": "Ana Diaz"
                    },
                    "key": "1001",
                    "kind": "person",
                    "secrets": {
                      "keypad_pin": "4321"
                    }
                  },
                  {
                    "domain": "lists",
                    "fields": {
                      "name": "Cleaning"
                    },
                    "key": "100",
                    "kind": "work_code"
                  },
                  {
                    "domain": "settings",
                    "fields": {
                      "value": 60
                    },
                    "key": "*/volume",
                    "kind": "setting"
                  }
                ]
              },
              "schema": {
                "$ref": "#/components/schemas/Batch"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 4,
                  "members": {
                    "applies": 8,
                    "not_applicable": 0,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 61
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Written: the newest version, how many rows changed, and how the rows fare on the members."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "people rows in a batch are persons; write credentials one at a time"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No changes or more than 10000, a domain without rows, a kind that is not one of the domain's (a credential, say), a field a person does not have, or a secret other than `keypad_pin` and `password`."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep access"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A domain the group does not keep, or a row no longer at its `if_version`."
          },
          "422": {
            "content": {
              "application/json": {
                "example": {
                  "error": "card 12345 is held by person 1003 of the group"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The registry refuses a row: a card or an external id another person of the group holds, say. Nothing is written."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Write many rows at once",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/changes": {
      "get": {
        "description": "Every row of the group's registry (people, credentials, access, lists,\nsettings) changed after a version, in version order, deletes included\n(`deleted`: true, kept until every member confirmed them). Secrets and\ncredential bytes are never shown. To follow the group, keep the `next`\nof each page and pass it as `after` next time: a page that comes back\nempty means you are up to date.",
        "operationId": "changes",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only rows changed after this version: pass the `next` of the page\nbefore. Default 0: from the start.",
            "example": 0,
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "description": "How many rows at most: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changes": [
                    {
                      "changed_at": "2026-01-15T08:00:00Z",
                      "changed_by": "api:admin",
                      "deleted": false,
                      "domain": "access",
                      "fields": {
                        "days": {
                          "mon": [
                            [
                              "08:00",
                              "17:00"
                            ]
                          ],
                          "tue": [
                            [
                              "08:00",
                              "17:00"
                            ]
                          ]
                        },
                        "name": "Day shift"
                      },
                      "key": "day",
                      "kind": "schedule",
                      "slot": 1,
                      "version": 17
                    },
                    {
                      "changed_at": "2026-01-15T08:00:00Z",
                      "changed_by": "api:admin",
                      "deleted": false,
                      "domain": "lists",
                      "fields": {
                        "name": "Cleaning"
                      },
                      "key": "100",
                      "kind": "work_code",
                      "version": 21
                    },
                    {
                      "changed_at": "2026-01-15T08:00:00Z",
                      "changed_by": "api:admin",
                      "deleted": true,
                      "domain": "people",
                      "fields": {},
                      "key": "1002",
                      "kind": "person",
                      "version": 22
                    }
                  ],
                  "next": 22
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncChangesPage"
                }
              }
            },
            "description": "A page of changed rows. `next` is the newest version among them, or `after` when the page is empty."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Read the change feed",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/lists/{kind}/{key}": {
      "delete": {
        "description": "Deletes the item from the registry, leaving a tombstone until every\nmember confirmed the delete, and so from every member. Deleting an item\nthe group does not have changes nothing (`changed`: 0). Stores a\n`list.changed` event (`deleted`: true) and is recorded in the audit\ntrail.",
        "operationId": "delete_list_item",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The list: work_code, job_code, tip_code or message.",
            "example": "work_code",
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The item's key.",
            "example": "100",
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 1,
                  "members": {
                    "applies": 2,
                    "not_applicable": 0,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 42
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Deleted: the version of the delete, and how it fares on the members."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "'pay_code' is not a kind of lists row (work_code, job_code, tip_code, message)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`kind` is not one of the lists."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep lists: add 'lists' to its domains first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep lists."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Delete a list item",
        "tags": [
          "sync"
        ]
      },
      "get": {
        "description": "One item of one of the group's lists: a work, job or tip code, or a\nmessage. A deleted item is not found.",
        "operationId": "get_list_item",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The list: work_code, job_code, tip_code or message.",
            "example": "work_code",
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The item's key: the code, or the message's id. At most 128 characters: it is indexed, and a longer one is refused (400).",
            "example": "100",
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed_at": "2026-01-15T08:00:00Z",
                  "changed_by": "api:admin",
                  "deleted": false,
                  "domain": "lists",
                  "fields": {
                    "name": "Cleaning"
                  },
                  "key": "100",
                  "kind": "work_code",
                  "version": 21
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncRowView"
                }
              }
            },
            "description": "The item."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "'pay_code' is not a kind of lists row (work_code, job_code, tip_code, message)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`kind` is not one of the lists."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "no work_code '100' in 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id, or the group has no such item (or it is deleted)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a list item",
        "tags": [
          "sync"
        ]
      },
      "put": {
        "description": "Writes a list item to the registry, and so to every member that takes\nthe list. A code has a `name`; a message has `text`, and may have\n`user_ids` (only those people are shown it), `from` and `minutes`. Each\nmember is sent the fields it takes; what it leaves out shows as\n`omitted` in its rows. Fields you give are set, `null` clears one,\nthose you leave out stay. Writing the same values again changes\nnothing. Stores a `list.changed` event and is recorded in the audit\ntrail.",
        "operationId": "put_list_item",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The list: work_code, job_code, tip_code or message.",
            "example": "work_code",
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The item's key: the code, or the message's id. At most 128 characters: it is indexed, and a longer one is refused (400).",
            "example": "100",
            "in": "path",
            "name": "key",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "fields": {
                  "name": "Cleaning"
                }
              },
              "schema": {
                "$ref": "#/components/schemas/PutRow"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 1,
                  "members": {
                    "applies": 2,
                    "not_applicable": 0,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 42
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Written: the item's version, and how it fares on the members."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "'pay_code' is not a kind of lists row (work_code, job_code, tip_code, message)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`kind` is not one of the lists."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep lists: add 'lists' to its domains first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep lists, or the item is no longer at `if_version`."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Add or change a list item",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/members": {
      "get": {
        "description": "Each member of the group, then each device that left it and is still\nremembered (`left_at` set). For each: its labels, what it takes and\nreports as its package declares it (`declaration`), its settings class,\nits rows counted by domain and state, an error one of its rows has,\nwhether intake from it is paused (the bulk-delete\nguard) and when it last took inventory, and the user id changes under\nway, failed or refused on it. A device that left is remembered until it confirms the\ndeletes it missed (`deletes_waiting`), or until you forget it.",
        "operationId": "members",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "counts": {
                      "people": {
                        "in_sync": 118,
                        "pending": 2
                      },
                      "settings": {
                        "in_sync": 4
                      }
                    },
                    "declaration": {
                      "people": {
                        "accept": {
                          "cards": {
                            "formats": [],
                            "max": 1
                          },
                          "credentials": {
                            "fingerprint": [
                              "zk:fingerprint:10"
                            ]
                          },
                          "delete_leaves_bytes": false,
                          "fields": {
                            "enabled": {},
                            "name": {
                              "max_length": 24
                            },
                            "role": {}
                          },
                          "keypad_pin": {
                            "max_length": 8
                          },
                          "rename": false,
                          "user_id": {
                            "pattern": "^[0-9]{1,9}$"
                          }
                        },
                        "report": {
                          "biometric": true,
                          "deleted": true,
                          "inventory": "query_users",
                          "photo": false,
                          "user": true
                        }
                      },
                      "settings": {
                        "catalog": {
                          "volume": {
                            "max": 100.0,
                            "min": 0.0,
                            "reboot": false,
                            "sensitive": false,
                            "standard": "volume",
                            "type": "integer"
                          }
                        },
                        "class": "zk-push@3.4",
                        "report": true
                      }
                    },
                    "deletes_waiting": null,
                    "device": "CG0001",
                    "endpoint": "office",
                    "id_changes": [],
                    "inventory": "query_users",
                    "inventory_at": "2026-01-15T08:00:00Z",
                    "labels": {
                      "floor": "1",
                      "site": "office"
                    },
                    "last_error": null,
                    "left_at": null,
                    "paused": null,
                    "settings_class": "zk-push@3.4"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SyncMemberView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The group's members, then the devices that left it."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List a group's members",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/members/{endpoint}/{device}": {
      "delete": {
        "description": "Forgets a device that left the group (`left_at` in the member list):\nthe deletes it never confirmed stop waiting for it, so their tombstones\ncan be purged. Should the device come back, it is a new member and is\nsent everything. Only a device that left can be forgotten; a member\nleaves when it is blocked, or its endpoint is put in another group.\nStores a `sync.member` event (`forgotten`) and is recorded in the audit\ntrail.",
        "operationId": "forget_member",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The endpoint of the device that left.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The device's id (its serial number, for most packages).",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "forgotten": true
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncForgottenView"
                }
              }
            },
            "description": "Forgotten."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "no member office/CG0001 that left 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id, or the group remembers no device that left with that endpoint and id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "office/CG0001 is a member of 'hq': take it out of the group first (block it, or move it to an endpoint without the group); only a member that left is forgotten"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The device is a member now: take it out of the group first."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Forget a member that left",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/members/{endpoint}/{device}/resume": {
      "post": {
        "description": "Takes what a member reports again after the bulk-delete guard paused\nintake from it (`paused` in the member list says why). Look at what the\ndevice reported deleting before you resume: once resumed, what it\nreports is taken as for any member. Resuming a member that is not\npaused does nothing (`resumed`: false). A resume stores a `sync.member`\nevent (`resumed`); the call is recorded in the audit trail.",
        "operationId": "resume",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The member's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The member's device id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "resumed": true
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncResumedView"
                }
              }
            },
            "description": "`resumed`: true if the member was paused and is not now; false if it was not paused."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Resume a paused member",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/members/{endpoint}/{device}/resync": {
      "post": {
        "description": "Forgets what the member was sent (of one domain, or of all): each of\nits rows goes back to pending, its errors and retries are cleared, and\nit takes inventory again at its next turn if its package can. Every\nrow is then sent again. The body is optional; without one, every\ndomain is reset. A device that is not a member resets nothing\n(`rows`: 0). Recorded in the audit trail.",
        "operationId": "resync",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The member's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The member's device id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "domain": "people"
              },
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/Resync"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "rows": 120
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncResyncView"
                }
              }
            },
            "description": "Reset: `rows` is how many of the member's rows will be sent again."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Send a member everything again",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/members/{endpoint}/{device}/retry": {
      "post": {
        "description": "A row that failed to reach a member stays failed: nothing sends it again\nby itself, however long it waits, until the registry's row changes. This\nputs the member's failed rows (of one domain, or all) back to pending\nso they are sent again; its other rows are left as they are. The body is\noptional. A device that is not a member, or one with no failed rows,\nretries nothing (`rows`: 0). Recorded in the audit trail.",
        "operationId": "retry",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The member's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The member's device id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "domain": "people"
              },
              "schema": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/Resync"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "rows": 3
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncRetryView"
                }
              }
            },
            "description": "Put back: `rows` is how many failed rows will be sent again."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Send a member's failed rows again",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/members/{endpoint}/{device}/rows": {
      "get": {
        "description": "Where the member is with each row the group sends it: its state, the\nversion it has, what its projection leaves out (`omitted`), why a row\nis unsupported or not applicable (`reason`), the last error and when a\nfailed row is sent again. A row being sent shows the action carrying\nit (`action`). A deleted row (`deleted: true`) shows where the member\nis with the delete. Filter by domain and state; the list is not paged\nbeyond `limit`. A device that is not a member answers an empty list.",
        "operationId": "member_rows",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The member's endpoint.",
            "example": "office",
            "in": "path",
            "name": "endpoint",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The member's device id.",
            "example": "CG0001",
            "in": "path",
            "name": "device",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only rows of this domain: people, access, lists, settings. Default:\nevery domain.",
            "example": "people",
            "in": "query",
            "name": "domain",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only rows in this state: pending, in_sync, failed, unsupported,\ndiverged, not_applicable, needs_reboot, not_placed,\nor deleted (a delete the member confirmed, whose tombstone the\ngroup still keeps). Default: every state.",
            "example": "failed",
            "in": "query",
            "name": "state",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "How many rows at most: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "applied_hash": "5d41402abc4b2a76b9719d911017c592",
                    "applied_version": 42,
                    "attempts": 0,
                    "domain": "people",
                    "key": "1001",
                    "kind": "person",
                    "state": "in_sync"
                  },
                  {
                    "action": {
                      "id": 311,
                      "sent_at": "2026-01-15T08:00:00Z",
                      "status": "in_progress"
                    },
                    "applied_version": 40,
                    "attempts": 0,
                    "domain": "people",
                    "key": "1002",
                    "kind": "person",
                    "last_command": 311,
                    "sending_hash": "7d793037a0760186574b0282f2f435e7",
                    "sending_version": 44,
                    "state": "pending"
                  },
                  {
                    "applied_version": 45,
                    "attempts": 0,
                    "domain": "people",
                    "key": "1003",
                    "kind": "person",
                    "reason": "name is longer than the device's 24 characters",
                    "state": "unsupported"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/SyncMemberRowView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The member's rows."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown state 'stuck'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`state` is not one of the states listed."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List a member's rows",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/people": {
      "get": {
        "description": "The group's people, a page at a time, in the order of their latest\nchange (version). Deleted people are left out (the change feed has\nthem). Secrets are never shown, only which are set (`secrets_set`). To\nread every person, start without `after` and pass each page's `next`\nas `after` until a page comes back empty. `external_id=payroll:104552`\nfinds the person another system knows by that id (an id in a system\nbelongs to one person of the group). `select` keeps the people a\nselector picks by their labels; a page then holds up to `limit` of\nthem, and `next` is where the page's reading stopped.",
        "operationId": "people",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only people changed after this version: pass the `next` of the page\nbefore. Default 0: from the start.",
            "example": 0,
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "format": "int64",
              "type": "integer"
            }
          },
          {
            "description": "How many people at most: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "description": "Only the people with this external id, `<system>:<id>`.",
            "example": "payroll:104552",
            "in": "query",
            "name": "external_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only the people this selector picks by their `labels`\n(`docs/selectors.md`): `role in (lead, manager) and site ^= west`.",
            "example": "role in (lead, manager) and site ^= west",
            "in": "query",
            "name": "select",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changes": [
                    {
                      "changed_at": "2026-01-15T08:00:00Z",
                      "changed_by": "api:admin",
                      "deleted": false,
                      "domain": "people",
                      "fields": {
                        "cards": [
                          {
                            "number": "12345"
                          }
                        ],
                        "enabled": true,
                        "external_ids": {
                          "payroll": "104552"
                        },
                        "labels": {
                          "site": "office"
                        },
                        "name": "Ana Diaz",
                        "role": "user"
                      },
                      "key": "1001",
                      "kind": "person",
                      "secrets_set": [
                        "keypad_pin"
                      ],
                      "version": 42
                    }
                  ],
                  "next": 42
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncChangesPage"
                }
              }
            },
            "description": "A page of people. `next` is the newest version among them, or `after` when the page is empty."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "an external id is looked up as <system>:<id>, not '104552'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`external_id` is not `<system>:<id>`, or `select` is not a selector (said at the column of the mistake)."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List people",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/people/{user_id}": {
      "delete": {
        "description": "Deletes the person from the registry, leaving a tombstone, and so from\nevery member, with their credentials, punch state and old ids. The\ntombstone is kept until every member confirmed the delete. Deleting a\nperson the group does not have changes nothing (`changed`: 0). Stores\na `person.deleted` event and is recorded in the audit trail.",
        "operationId": "delete_person",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's user id.",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 1,
                  "members": {
                    "applies": 2,
                    "not_applicable": 2,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 44
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Deleted: the version of the delete, whether the person changed (`changed`: 1, or 0 for a person the group did not have), and how the delete fares on the members."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep people: add 'people' to its domains first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep people."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Delete a person",
        "tags": [
          "sync"
        ]
      },
      "get": {
        "description": "The person's record (secrets only by name), their credentials'\nmetadata (deleted ones too, until every member confirmed the delete),\nand where each member of the group is with them: `state` in_sync,\npending (not looked at yet, or being sent: `action`), not_placed,\nunsupported (`reason`), failed (`error`, `attempts`) or\nnot_applicable; what a member leaves out is in `omitted`. A deleted\nperson is shown (`person.deleted`) until every member confirmed the\ndelete and the tombstone is purged, with where each member is with the\ndelete. `id_changes` shows each member's part in the change that gave\nthe person this id, if there was one.",
        "operationId": "person",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's user id.",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "credentials": [
                    {
                      "changed_at": "2026-01-15T08:00:00Z",
                      "changed_by": "device:office/CG0001",
                      "deleted": false,
                      "domain": "people",
                      "fields": {
                        "attrs": {},
                        "format": "zk:fingerprint:10",
                        "kind": "fingerprint",
                        "slot": 0,
                        "user_id": "1001"
                      },
                      "key": "1001/fingerprint/0/zk:fingerprint:10",
                      "kind": "credential",
                      "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                      "version": 43
                    }
                  ],
                  "id_changes": [],
                  "members": [
                    {
                      "applied_hash": "5d41402abc4b2a76b9719d911017c592",
                      "applied_version": 42,
                      "attempts": 0,
                      "device": "CG0001",
                      "endpoint": "office",
                      "state": "in_sync"
                    },
                    {
                      "applied_version": 40,
                      "attempts": 2,
                      "device": "CG0002",
                      "endpoint": "office",
                      "error": "upsert_user (command 311 sent at 2026-01-15T08:00:00Z) was not answered by the device",
                      "sending_version": 42,
                      "state": "failed"
                    }
                  ],
                  "person": {
                    "changed_at": "2026-01-15T08:00:00Z",
                    "changed_by": "api:admin",
                    "deleted": false,
                    "domain": "people",
                    "fields": {
                      "cards": [
                        {
                          "number": "12345"
                        }
                      ],
                      "enabled": true,
                      "external_ids": {
                        "payroll": "104552"
                      },
                      "labels": {
                        "site": "office"
                      },
                      "name": "Ana Diaz",
                      "role": "user"
                    },
                    "key": "1001",
                    "kind": "person",
                    "secrets_set": [
                      "keypad_pin"
                    ],
                    "version": 42
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/PersonView"
                }
              }
            },
            "description": "The person, their credentials, and where each member is with them."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "no person '1001' in 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id, or the group has no person with that id (a deleted one is shown until its tombstone is purged)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a person",
        "tags": [
          "sync"
        ]
      },
      "put": {
        "description": "Writes the person to the group's registry, and so to every member the\nperson is placed on. The body is `{\"fields\": {...}, \"secrets\": {...},\n\"if_version\": n}`, each part optional. Fields you give are set, `null`\nclears one, those you leave out stay as they are. `cards` replaces the\nperson's cards. `labels` (an object) and `devices`\n(`\"<endpoint>/<device>\"`: the members they are placed on, instead of\nthe group's rules) place the person. `biometrics: false` deletes the\nperson's templates and photos, from the members too. `external_ids`\n(`{\"payroll\": \"104552\"}`) replaces the ids other systems know the person\nby, each held by one person of the group, and is never sent to a device. Secrets\n(`keypad_pin`, `password`) are write-only: answers show only which are\nset. With `if_version`, the write is made only if the person is still\nat that version (0: only if the registry has no row for that id). Writing the\nsame values again changes nothing (`changed`: 0). Stores a\n`person.changed` event and is recorded in the audit trail.",
        "operationId": "put_person",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's user id.",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "fields": {
                  "cards": [
                    {
                      "number": "12345"
                    }
                  ],
                  "enabled": true,
                  "labels": {
                    "site": "office"
                  },
                  "name": "Ana Diaz",
                  "role": "user"
                },
                "if_version": 41,
                "secrets": {
                  "keypad_pin": "4321"
                }
              },
              "schema": {
                "$ref": "#/components/schemas/PutPerson"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 1,
                  "members": {
                    "applies": 2,
                    "not_applicable": 0,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 42
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Written: the newest version, how many rows changed, and how the person fares on the members."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "'name' belongs under \"fields\" or \"secrets\", not at the top level; a person is written as {\"fields\": {\"name\": \"Ann Lee\", \"cards\": [{\"number\": \"12345\"}]}, \"secrets\": {\"keypad_pin\": \"1234\"}, \"if_version\": 3}"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not a person write: the body is not an object, a field at the top level, a name that is not one of a person's fields or secrets, `if_version` that is not a whole number, or `labels` or `devices` that are not valid."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "people/person/1001 is at version 43, not 41: it was changed in the meantime"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep people, or the person is no longer at `if_version`."
          },
          "422": {
            "content": {
              "application/json": {
                "example": {
                  "error": "card 12345 is held by person 1002 of the group"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The registry cannot take it: a card or an external id another person of the group holds, a card without a number or listed twice, `cards` that is not a list, or `biometrics` that is not true or false."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Add or change a person",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/people/{user_id}/biometrics": {
      "get": {
        "description": "Whether the person may have biometric templates and photos in the\ngroup. Every group has the flag, whatever its domains, and for any user\nid: a person the group has no flag for, or does not have at all, is\nallowed.",
        "operationId": "get_biometrics",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's user id.",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "allow_biometrics": true,
                  "user_id": "1001"
                },
                "schema": {
                  "$ref": "#/components/schemas/BiometricsView"
                }
              }
            },
            "description": "The person's flag."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a person's biometrics flag",
        "tags": [
          "sync"
        ]
      },
      "put": {
        "description": "Sets whether the person may have biometric templates and photos in the\ngroup, whatever its domains. Refused, their templates and photos are\ndropped as devices send them (each device is told to delete them), and\nactions that carry them to the group's devices are refused. Allowed\nbefore and refused now, the gateway's copies go (the registry's\ncredentials, and the person's biometric events, delivered or not) and\nevery device of the group is sent the deletes, in the urgent lane:\n`withdrawn` says what went. For a person the group keeps, the flag is\nthe person's `biometrics` field, written as any change to the person\nis (a `person.changed` event). Setting the flag it already has changes\nnothing. Recorded in the audit trail.",
        "operationId": "put_biometrics",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's user id.",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "allow": false
              },
              "schema": {
                "$ref": "#/components/schemas/PutBiometrics"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "allow_biometrics": false,
                  "user_id": "1001",
                  "withdrawn": {
                    "deletes": [
                      {
                        "action": "delete_biometrics",
                        "action_id": 312,
                        "device": "CG0001",
                        "endpoint": "office"
                      },
                      {
                        "action": "delete_user_photo",
                        "action_id": 313,
                        "device": "CG0002",
                        "endpoint": "office"
                      }
                    ],
                    "events_purged": 3,
                    "undelivered_purged": 0
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/BiometricsSet"
                }
              }
            },
            "description": "Set: the person's flag now, and what was withdrawn if this refused biometrics that were allowed."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Allow or refuse a person biometrics",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/people/{user_id}/change-id": {
      "post": {
        "description": "Gives the person, and their credentials, a new user id in the registry\nat once. On the members it is done one member at a time: a member that\ncan rename a user does; the rest are given the person under the new\nid, which is checked, then the old user is deleted (steps settle,\ncreate, verify_new, delete_old, verify_old). A member that may hold\ntemplates the group does not have is refused the change, and keeps the\nold user, unless `allow_reenroll` is true. Follow each member's part in\n`id_changes` (on the person under the new id, and on the members);\ncarry on a failed or refused part with `retry-change-id`. The old id\nis kept as an alias for the retention period (`retention_days`), so\nlate punches under it are still the person's. Stores a\n`person.changed` event and is recorded in the audit trail.",
        "operationId": "change_id",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's current user id.",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "allow_reenroll": false,
                "new_user_id": "1101"
              },
              "schema": {
                "$ref": "#/components/schemas/ChangeId"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 1,
                  "members": {
                    "applies": 2,
                    "not_applicable": 0,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 42
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Changed in the registry: the version of the person under the new id, and how the person fares on the members."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "new_user_id must be given, and differ from the id the person has"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`new_user_id` is empty, or the id the person has."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep people: add 'people' to its domains first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep people."
          },
          "422": {
            "content": {
              "application/json": {
                "example": {
                  "error": "person '1101' is in the group already"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The registry cannot make the change: the group has no person with the current id, or already has one with the new id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Change a person's user id",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/people/{user_id}/credentials": {
      "delete": {
        "description": "Deletes every credential the group keeps for the person (templates,\nface photos and display photos), from the registry and so from every\nmember. Each leaves a tombstone until every member confirmed the\ndelete. With nothing to remove, nothing changes (`changed`: 0, and\n`version` is the person's). Stores a `person.changed` event and is\nrecorded in the audit trail.",
        "operationId": "delete_credentials",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's user id.",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 3,
                  "members": {
                    "applies": 6,
                    "not_applicable": 0,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 47
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Removed: the newest version, how many credentials were removed, and how the deletes fare on the members."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep people: add 'people' to its domains first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep people."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Remove a person's credentials",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/people/{user_id}/credentials/{kind}": {
      "delete": {
        "description": "Deletes every credential of the kind the group keeps for the person\n(every slot and format), from the registry and so from every member.\nWith nothing to remove (a kind that is not one included), nothing\nchanges (`changed`: 0, and `version` is the person's). Stores a\n`person.changed` event and is recorded in the audit trail.",
        "operationId": "delete_credential_kind",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's user id.",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The credential kind: fingerprint, face, face_photo, palm, finger_vein, iris or photo.",
            "example": "fingerprint",
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 2,
                  "members": {
                    "applies": 4,
                    "not_applicable": 0,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 46
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Removed: the newest version, how many credentials were removed, and how the deletes fare on the members."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep people: add 'people' to its domains first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep people."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Remove a person's credentials of one kind",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/people/{user_id}/credentials/{kind}/{slot}": {
      "delete": {
        "description": "Deletes one of the person's credentials, in every format the group\nkeeps it, from the registry and so from every member. With nothing to\nremove, nothing changes (`changed`: 0, and `version` is the person's).\nStores a `person.changed` event and is recorded in the audit trail.",
        "operationId": "delete_credential",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's user id.",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The credential kind: fingerprint, face, face_photo, palm, finger_vein, iris or photo.",
            "example": "fingerprint",
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Which one of the kind (a finger number for fingerprints).",
            "example": 0,
            "in": "path",
            "name": "slot",
            "required": true,
            "schema": {
              "format": "int32",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 1,
                  "members": {
                    "applies": 2,
                    "not_applicable": 0,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 45
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Removed: the version of the delete, how many rows were removed (one per format), and how the delete fares on the members."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep people: add 'people' to its domains first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep people."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Remove a credential",
        "tags": [
          "sync"
        ]
      },
      "put": {
        "description": "Writes one of a person's credentials: a biometric template, a face\nphoto or a display photo. The bytes are kept sealed, which needs\n`HOURADVANTAGE_SECRET_KEY`, and only in a group that keeps biometrics\n(`people.biometrics`). A credential of the same kind, slot and format\nis replaced. Members that take the kind and format are sent it. Stores\na `person.changed` event and is recorded in the audit trail.",
        "operationId": "put_credential",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's user id.",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The credential kind: fingerprint, face, face_photo, palm, finger_vein, iris or photo (a display photo).",
            "example": "fingerprint",
            "in": "path",
            "name": "kind",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Which one of the kind: a finger number for fingerprints, 0 where there is one.",
            "example": 0,
            "in": "path",
            "name": "slot",
            "required": true,
            "schema": {
              "format": "int32",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "attrs": {
                  "duress": false
                },
                "data_base64": "SGVsbG8gdGVtcGxhdGU=",
                "format": "zk:fingerprint:10"
              },
              "schema": {
                "$ref": "#/components/schemas/PutCredential"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 1,
                  "members": {
                    "applies": 2,
                    "not_applicable": 0,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 42
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Written: the credential's version, and how it fares on the members."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown credential kind 'retina' (fingerprint, face, face_photo, palm, finger_vein, iris, photo)"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "An unknown kind, `data_base64` that is empty or not base64, or no `format`."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep people: add 'people' to its domains first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep people."
          },
          "422": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep fingerprint credentials: set people.biometrics = true"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Not kept: the person is not allowed biometrics in the group, or withdrew consent (`biometrics`: false); the instance has no HOURADVANTAGE_SECRET_KEY; or the group does not keep biometrics (`people.biometrics`, which display photos need too)."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Add or replace a credential",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/people/{user_id}/retry-change-id": {
      "post": {
        "description": "Carries on a user id change on every member where its part failed or\nwas refused, from the step where it stopped. A part refused because the\nmember may hold templates the group does not have goes ahead now: those\ntemplates may have to be enrolled again. Parts still running or done\nare left as they are (`retried` is then empty). Recorded in the audit\ntrail.",
        "operationId": "retry_change_id",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The id the person had before the change (the old user id).",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "retried": [
                    {
                      "device": "CG0002",
                      "endpoint": "office",
                      "step": "create"
                    }
                  ]
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncRetriedView"
                }
              }
            },
            "description": "`retried`: the members where the change carries on, and the step it carries on from."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "no id change of '1001' in 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id, or there is no id change from that user id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep people: add 'people' to its domains first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep people."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Retry a user id change",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/people/{user_id}/routes": {
      "get": {
        "description": "The defaults (the endpoint's over the group's), the person's own\nroutes, and the candidates they make: exactly one, and a punch goes\nthere; none, and it is unrouted where routing is in use; several, and\nthe endpoint's policy decides (without one, unrouted).",
        "operationId": "person_routes",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's user id.",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The endpoint whose punches are meant: its defaults over the group's.\nWithout it, the group's alone.",
            "example": "office",
            "in": "query",
            "name": "endpoint",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "candidates": [
                    {
                      "person_id": "4471",
                      "system": "attendance",
                      "tenant": "acme"
                    }
                  ],
                  "defaults": [
                    {
                      "system": "attendance",
                      "tenant": "acme"
                    }
                  ],
                  "own": []
                },
                "schema": {
                  "$ref": "#/components/schemas/PersonRoutesView"
                }
              }
            },
            "description": "The defaults, the person's own routes and the candidates."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep people: add 'people' to its domains first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep people."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Show where a person's punches can go",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/punches/{user_id}": {
      "get": {
        "description": "The person's latest punch in the group, and the few before it, newest\nfirst: what members that ask (`last_punch`, anti-passback `check`) are\nanswered from, and what punch events are marked against. Kept for the\ngroup's punches domain only.",
        "operationId": "punches",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The person's user id.",
            "example": "1001",
            "in": "path",
            "name": "user_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "device": "CG0001",
                  "endpoint": "office",
                  "event_id": "0f3c2a9b8d7e6f5a4b3c2d1e0f9a8b7c",
                  "local": "2026-01-15 09:00:00",
                  "recent": [
                    {
                      "device": "CG0001",
                      "endpoint": "office",
                      "id": "0f3c2a9b8d7e6f5a4b3c2d1e0f9a8b7c",
                      "local": "2026-01-15 09:00:00",
                      "state_name": "check_in",
                      "time": "2026-01-15T09:00:00+01:00"
                    },
                    {
                      "device": "CG0002",
                      "endpoint": "office",
                      "id": "9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d",
                      "local": "2026-01-14 17:02:00",
                      "state_name": "check_out",
                      "time": "2026-01-14T17:02:00+01:00"
                    }
                  ],
                  "state_name": "check_in",
                  "time": "2026-01-15T08:00:00Z",
                  "user_id": "1001",
                  "work_code": null
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncPunchesView"
                }
              }
            },
            "description": "The latest punch, and the recent ones."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "no recent punch of '1001' in 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id, or the group has no recent punch of that person."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a person's recent punches",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/settings/{class}": {
      "get": {
        "description": "The setting values the group keeps for one settings class, each with\nits version. A member's class is in the member list (`settings_class`;\nby default its package and major.minor version, `zk-push@3.4`). Class\n`*` holds the standard names (volume, language, date_format,\ntime_format, screen_timeout_seconds, ntp_server, lock_seconds), for\nevery member that has them; asking for a class shows that class's own\nvalues only. A sensitive value is never shown, only its size. A class\nthe group keeps nothing for answers no values.",
        "operationId": "get_settings",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The settings class, or `*` for the standard names.",
            "example": "zk-push@3.4",
            "in": "path",
            "name": "class",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "class": "zk-push@3.4",
                  "values": {
                    "comm_key": "<redacted 6 bytes>",
                    "volume": 60
                  },
                  "versions": {
                    "comm_key": 31,
                    "volume": 30
                  }
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncSettingsView"
                }
              }
            },
            "description": "The class's values and their versions."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a settings class",
        "tags": [
          "sync"
        ]
      },
      "put": {
        "description": "Writes setting values for one class: each goes to every member of the\nclass whose catalog has the name. Class `*` takes standard names only\n(volume, language, date_format, time_format, screen_timeout_seconds,\nntp_server, lock_seconds) and reaches every member that has them,\nwhatever its class; a class's own value for the same setting wins. A\nsetting any member of the class marks sensitive is kept as a secret\n(sealed with `HOURADVANTAGE_SECRET_KEY` when set) and never shown. Names\nyou leave out stay as they are. Each changed value stores a\n`setting.changed` event (without a sensitive value); the write is\nrecorded in the audit trail.",
        "operationId": "put_settings",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The settings class, or `*` for the standard names. Not empty, and without '/'.",
            "example": "zk-push@3.4",
            "in": "path",
            "name": "class",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "values": {
                  "lock_seconds": null,
                  "volume": 60
                }
              },
              "schema": {
                "$ref": "#/components/schemas/PutSettings"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "changed": 1,
                  "members": {
                    "applies": 2,
                    "not_applicable": 0,
                    "not_placed": 0,
                    "unsupported": []
                  },
                  "version": 42
                },
                "schema": {
                  "$ref": "#/components/schemas/SyncWriteView"
                }
              }
            },
            "description": "Written: the newest version, how many values changed, and how they fare on the members."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "class '*' holds standard settings only (volume, language, date_format, time_format, screen_timeout_seconds, ntp_server, lock_seconds); 'comm_key' belongs to a class"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No values, a class that is empty or has '/', a setting name that is empty or has '/', or a name in class `*` that is not a standard one."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' does not keep settings: add 'settings' to its domains first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The group does not keep settings."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Set values for a settings class",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/unrouted": {
      "get": {
        "description": "The punches of the group's people that go nowhere until they are routed:\na person with no route where routing is in use (`no_route`), someone the\ngroup does not have (`unknown_person`), several routes and nothing to\ndecide between them (`ambiguous`), the policy's `route` hook leaving it\nunrouted (`policy`) or failing (`policy_failed`), or the hook deciding\nit (`deciding`). Each was stored as a punch event, and told of by a\n`punch.unrouted` event; once routed it goes out again with the same id.\nIn id order.",
        "operationId": "unrouted",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only this person's (their user id).",
            "example": "1001",
            "in": "query",
            "name": "user_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only those after this punch id: the last of the page before.",
            "example": "0f3c2a9b8d7e6f5a4b3c2d1e0f9a8b7c",
            "in": "query",
            "name": "after",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "How many at most: 100 unless given, at most 1000.",
            "example": 100,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "candidates": [
                      {
                        "codes": {
                          "work_code": "7"
                        },
                        "person_id": "11",
                        "system": "attendance",
                        "tenant": "agency-a"
                      },
                      {
                        "codes": {
                          "work_code": "8"
                        },
                        "person_id": "22",
                        "system": "attendance",
                        "tenant": "agency-b"
                      }
                    ],
                    "data": {
                      "state_name": "check_in",
                      "time": "2026-10-07T08:00:00-05:00",
                      "user_id": "1001"
                    },
                    "device": "T1",
                    "endpoint": "town",
                    "id": "0f3c2a9b8d7e6f5a4b3c2d1e0f9a8b7c",
                    "reason": "policy",
                    "received_at": "2026-10-07T08:00:05Z",
                    "user_id": "1001"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/UnroutedPunchView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The punches set aside, in id order."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List the group's unrouted punches",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/unrouted/route": {
      "post": {
        "description": "Works each of the group's unrouted punches (one person's, with\n`user_id`), however many, out again with the people's routes, the\ndefault routes and the endpoints' policies as they are now. One with a\nroute now goes out again, with the same id, marked with it; one still\nunrouted stays, and is told again when the reason changed. The answer\ncounts what became of them all, and why the unrouted still are. A\nperson added or changed has their punches worked out again by itself,\nand so has the group when its routes, or those of one of its endpoints,\nchange. Recorded in the audit trail.",
        "operationId": "route_again",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only this person's (their user id).",
            "example": "1001",
            "in": "query",
            "name": "user_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "passed": 0,
                  "reasons": {
                    "unknown_person": 3
                  },
                  "routed": 1200,
                  "total": 1203,
                  "unrouted": 3
                },
                "schema": {
                  "$ref": "#/components/schemas/ReroutedTotals"
                }
              }
            },
            "description": "What became of them, in total."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "unknown sync group 'hq'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Route the group's unrouted punches again",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/sync/{name}/unrouted/{id}/route": {
      "post": {
        "description": "Routes one of the group's unrouted punches: to the `route` given, or\nwith its `candidates` passed on; with neither, worked out again as\n`POST /sync/{name}/unrouted/route` does. Routed, it goes out again with\nthe same id, marked with where it goes, and is no longer unrouted.\nRecorded in the audit trail.",
        "operationId": "route_one",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The sync group's id.",
            "example": "hq",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The punch's id (its event's).",
            "example": "0f3c2a9b8d7e6f5a4b3c2d1e0f9a8b7c",
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "route": {
                  "person_id": "22",
                  "system": "attendance",
                  "tenant": "agency-b"
                }
              },
              "schema": {
                "$ref": "#/components/schemas/RouteBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "candidates": [
                    {
                      "codes": {
                        "work_code": "7"
                      },
                      "person_id": "11",
                      "system": "attendance",
                      "tenant": "agency-a"
                    },
                    {
                      "codes": {
                        "work_code": "8"
                      },
                      "person_id": "22",
                      "system": "attendance",
                      "tenant": "agency-b"
                    }
                  ],
                  "id": "0f3c2a9b8d7e6f5a4b3c2d1e0f9a8b7c",
                  "route": {
                    "codes": {
                      "work_code": "8"
                    },
                    "person_id": "22",
                    "system": "attendance",
                    "tenant": "agency-b"
                  },
                  "routing": "routed",
                  "user_id": "1001"
                },
                "schema": {
                  "$ref": "#/components/schemas/Rerouted"
                }
              }
            },
            "description": "What became of it."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "give a route or candidates, not both"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Both a route and candidates, a route that is not one, or candidates of several systems or none."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "sync group 'hq' has no unrouted punch '0f3c2a9b'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "No sync group has that id, or it has no such unrouted punch."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Route an unrouted punch",
        "tags": [
          "sync"
        ]
      }
    },
    "/api/tenants/{tenant}/traffic": {
      "get": {
        "description": "The last device messages the instance that answers handled, newest first: each request, what it was answered,\nthe route that took it, how many events it made and how long it took. Each instance keeps its last 1000 in\nmemory, and they are gone when it restarts; behind a load balancer, each instance has its own. Bodies are kept as\ntext up to `limits.traffic_body_bytes` each (16 KiB unless set; 0 keeps none), with control characters replaced\nand what is cut off counted; values the package marks secret are masked in the answer's body. Bodies can hold\ncredentials and biometric data.",
        "operationId": "traffic",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "At most this many: 100 unless given, at most 1000 (more is read as\n1000).",
            "example": 20,
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "description": "Only this endpoint's messages.",
            "example": "office",
            "in": "query",
            "name": "endpoint",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only this device's messages: its id, as its package identifies it.",
            "example": "CG0001",
            "in": "query",
            "name": "device",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "at": "2026-01-15T14:00:02Z",
                    "device": "CG0001",
                    "duration_ms": 3,
                    "endpoint": "office",
                    "error": null,
                    "events": 0,
                    "method": "GET",
                    "path": "/office/iclock/getrequest",
                    "query": "SN=CG0001",
                    "remote_ip": "192.0.2.10",
                    "request_body": "",
                    "request_bytes": 0,
                    "response_body": "OK",
                    "route": "getrequest",
                    "seq": 81234,
                    "status": 200
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/Traffic"
                  },
                  "type": "array"
                }
              }
            },
            "description": "The messages, newest first."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List recent traffic",
        "tags": [
          "instance"
        ]
      }
    },
    "/api/tenants/{tenant}/traffic/{seq}": {
      "get": {
        "description": "One device message from the traffic log of the instance that answers, by its `seq`. Sequence numbers are per\ninstance: behind a load balancer, ask the instance that listed it.",
        "operationId": "traffic_entry",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The entry's `seq`, as `GET /api/tenants/{tenant}/traffic` listed it.",
            "example": 81234,
            "in": "path",
            "name": "seq",
            "required": true,
            "schema": {
              "format": "int64",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "at": "2026-01-15T14:00:02Z",
                  "device": "CG0001",
                  "duration_ms": 7,
                  "endpoint": "office",
                  "error": null,
                  "events": 1,
                  "method": "POST",
                  "path": "/office/iclock/cdata",
                  "query": "SN=CG0001&table=ATTLOG",
                  "remote_ip": "192.0.2.10",
                  "request_body": "1001\t2026-01-15 08:00:00\t0\t1\t0\t0\n",
                  "request_bytes": 34,
                  "response_body": "OK: 1",
                  "route": "attlog",
                  "seq": 81234,
                  "status": 200
                },
                "schema": {
                  "$ref": "#/components/schemas/Traffic"
                }
              }
            },
            "description": "The entry."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "traffic entry not found"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "This instance does not keep an entry with that `seq`: it is older than its last 1000, or another instance handled it."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get a traffic entry",
        "tags": [
          "instance"
        ]
      }
    },
    "/api/tenants/{tenant}/vars": {
      "get": {
        "description": "Every var with its value: the tenant's first, then each package's, by package and name. Packages read them with\n`vars.get(name)`, a package's own value of a name before the tenant's.",
        "operationId": "list_vars",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "name": "site_code",
                    "updated_at": "2026-01-15T08:00:00Z",
                    "updated_by": "admin",
                    "value": "HQ-01"
                  },
                  {
                    "name": "site_code",
                    "package": "zk-push",
                    "updated_at": "2026-01-15T08:05:00Z",
                    "updated_by": "token:deploy",
                    "value": "HQ-02"
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/VarView"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every var."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List vars",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/vars/{name}": {
      "delete": {
        "description": "Deletes a var of the tenant or, with `?package=`, of one package. Refused while a package in use requires it\n(`[requires]` in its package.toml) and the other scope does not give it: activate a revision that does not\nrequire it first. Recorded in the audit trail.",
        "operationId": "delete_var",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The var's name.",
            "example": "site_code",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The package (by name, every version of it) the value is for: 1 to 64\nletters, digits, '_', '-' or '.'. Absent: the tenant's, for every package.",
            "example": "zk-push",
            "in": "query",
            "name": "package",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted. No body."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "'zk push' is not a package name"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The name or the package is not 1 to 64 letters, digits, '_', '-' or '.'."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no var 'site_code' of package 'zk-push'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no such var in that scope."
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "var 'site_code' cannot be deleted: package zk-push@3.4.0 requires it ([requires] in its package.toml) and would be left without it; activate a revision that does not require it first"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "A package in use requires it and would be left without it."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Delete a var",
        "tags": [
          "setup"
        ]
      },
      "put": {
        "description": "Sets a var, for the tenant or, with `?package=`, for one package (every version of it), adding it or replacing\nits value. The instance that answers reads the new value before it answers; the others read it when they take in\nthe config version the change makes (`houradvantage-config-version`). Recorded in the audit trail.",
        "operationId": "set_var",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The var's name: 1 to 64 letters, digits, '_', '-' or '.'.",
            "example": "site_code",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "The package (by name, every version of it) the value is for: 1 to 64\nletters, digits, '_', '-' or '.'. Absent: the tenant's, for every package.",
            "example": "zk-push",
            "in": "query",
            "name": "package",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "value": "HQ-01"
              },
              "schema": {
                "$ref": "#/components/schemas/NewValue"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": {
                  "name": "site_code",
                  "package": "zk-push",
                  "updated_at": "2026-01-15T08:00:00Z",
                  "updated_by": "admin",
                  "value": "HQ-01"
                },
                "schema": {
                  "$ref": "#/components/schemas/VarView"
                }
              }
            },
            "description": "Set: the var as kept."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "a var name is 1 to 64 letters, digits, '_', '-' or '.'; 'site code' is not"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not `{\"value\": \"...\"}`, the name or the package is not 1 to 64 letters, digits, '_', '-' or '.', or the value is over 64 KiB."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "var 'site_code' of package 'zk-push' is gone again"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "It was deleted again by another request before it could be read back."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Set a var",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tenants/{tenant}/wire/live": {
      "get": {
        "description": "Watches every byte the device listeners of every instance receive and send, as it is and as it happens:\nrequests that are not valid HTTP and connections that say nothing included. The answer is a stream of JSON\nobjects, one per line (`application/x-ndjson`), each naming the instance it came from. `wire` lines carry one\nrecord each: `at`, the connection number `conn`, the `listener`, the `endpoint` when it can be told, the client\naddress `peer`, `dir` (`open`, `rx`, `tx`, `eof`, `error`, `closed`), and for `rx` and `tx` the `bytes` count and\nthe `data`, escaped as ASCII. `peer` lines say an instance joined the capture or could not be reached (the\ncapture is then partial), `dropped` lines how many records an instance dropped because they came faster than\nthey were read, and the last line, `end`, why it ended (`time` or `bytes`), how much it showed, and whether it was\npartial. It ends after `for_secs`, after 64 MiB of device traffic across every instance, or when you close it.\nThe data includes device keys, PINs, card numbers and biometric templates, and is never stored anywhere; starting\na capture is recorded in the audit trail. The `x-houradvantage-instance` response header names the instance that\nrelays it.",
        "operationId": "wire_live",
        "parameters": [
          {
            "description": "The tenant's id.",
            "example": "acme",
            "in": "path",
            "name": "tenant",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only the requests that name this device (its id, as a whole word,\nanywhere in the request), and their answers.",
            "example": "CG0001",
            "in": "query",
            "name": "device",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only the requests for this endpoint, and their answers.",
            "example": "office",
            "in": "query",
            "name": "endpoint",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "How long to capture, in seconds: 900 (15 minutes) unless given, 1 to\n7200 (2 hours).",
            "example": 300,
            "in": "query",
            "name": "for_secs",
            "required": false,
            "schema": {
              "format": "int64",
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/x-ndjson": {
                "example": {
                  "data": {
                    "at": "2026-01-15T14:00:02Z",
                    "bytes": 64,
                    "conn": 3121,
                    "data": "GET /office/iclock/getrequest?SN=CG0001 HTTP/1.1\\r\\nHost: example.com\\r\\n\\r\\n",
                    "dir": "rx",
                    "endpoint": "office",
                    "listener": "public",
                    "note": null,
                    "peer": "192.0.2.10:51234"
                  },
                  "instance": "gw-1",
                  "kind": "wire"
                },
                "schema": {
                  "$ref": "#/components/schemas/LiveLine"
                }
              }
            },
            "description": "One JSON object per line, until the capture ends."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "for_secs must be at most 7200"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "`for_secs` is 0 or over 7200, or `endpoint` names no endpoint this instance serves."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Capture the wire, live",
        "tags": [
          "instance"
        ]
      }
    },
    "/api/tokens": {
      "get": {
        "description": "Every API token, by name, those revoked included (`revoked`, with when and by whom): who made it and when, and\nwhen it was last used. Their secrets are never shown: only a hash of each is kept. `last_used_at` is written at\nmost once a minute per instance, so it can be up to a minute behind.",
        "operationId": "list_tokens",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "example": [
                  {
                    "created_at": "2026-01-15T08:00:00Z",
                    "created_by": "admin",
                    "last_used_at": "2026-01-16T02:00:04Z",
                    "name": "backup-job",
                    "revoked": false
                  }
                ],
                "schema": {
                  "items": {
                    "$ref": "#/components/schemas/ApiToken"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Every token, by name."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "List API tokens",
        "tags": [
          "setup"
        ]
      },
      "post": {
        "description": "Makes a named API token for a program or a person to use the API with, sent as `Authorization: Bearer <token>`.\nEvery instance takes it at once, with or without an admin login configured. Without a `scope` it gives the same\naccess as the login: the whole install. With `connect:<tenant>` it reaches only that Connect tenant's routes\n(`/api/tenants/<tenant>/...`), with `attend:<tenant>` only that Time and Attendance tenant's\n(`/api/attendance/tenants/<tenant>/...`): a scoped token is refused (403) everywhere else, install-level\nroutes included. Only an install token (or the login) makes tokens, of any scope. The answer carries the token\nitself (`hadv_` and 43 more characters) once: keep it, as it cannot be shown again. Recorded in the audit trail,\nthe token never.",
        "operationId": "create_token",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "name": "acme-portal",
                "scope": "connect:acme"
              },
              "schema": {
                "$ref": "#/components/schemas/NewToken"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "example": {
                  "created_at": "2026-01-15T08:00:00Z",
                  "created_by": "admin",
                  "last_used_at": null,
                  "name": "acme-portal",
                  "revoked": false,
                  "scope": "connect:acme",
                  "token": "hadv_3q2-7wEXAMPLEonlyEXAMPLEonlyEXAMPLEonlyEXa"
                },
                "schema": {
                  "$ref": "#/components/schemas/CreatedToken"
                }
              }
            },
            "description": "Made: the token, and its secret this once."
          },
          "400": {
            "content": {
              "application/json": {
                "example": {
                  "error": "a token name is 1 to 64 letters, digits, '.', '_' or '-'; 'backup job' is not"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "The body is not `{\"name\": ...}`, or the name is not 1 to 64 letters, digits, '.', '_' or '-'."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is a token named 'backup-job' already"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is a token of that name already, or was: the name of a revoked token stays taken, so that the audit trail's `token:<name>` names one token only."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Create an API token",
        "tags": [
          "setup"
        ]
      }
    },
    "/api/tokens/{name}": {
      "delete": {
        "description": "Revokes a token: the instance that answers refuses it from the next request, the other instances within 60\nseconds (each takes a token that checked out for up to a minute without asking the database again). A request\nmade with the token that is under way finishes. The token stays in the list, flagged `revoked`, with when and by\nwhom, and its name stays taken. Recorded in the audit trail, naming the token, its scope, who made it and when\nit was last used.",
        "operationId": "revoke_token",
        "parameters": [
          {
            "description": "The token's name.",
            "example": "backup-job",
            "in": "path",
            "name": "name",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "204": {
            "description": "Revoked. No body."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "content": {
              "application/json": {
                "example": {
                  "error": "there is no token named 'backup-job'"
                },
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "There is no token of that name in use: none was made, or it is revoked already."
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Revoke an API token",
        "tags": [
          "setup"
        ]
      }
    },
    "/livez": {
      "get": {
        "description": "Answers 200 with `ok` whenever the process answers, from the moment the admin listener opens: for a liveness\nprobe and the container image's health check. It asks nothing of the database or of readiness, so a database\noutage or a drain never gets an instance restarted. It needs no login.",
        "operationId": "livez",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/plain": {
                "example": "ok\n",
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The process answers: `ok` and a line break."
          }
        },
        "security": [
          {}
        ],
        "summary": "Check liveness",
        "tags": [
          "probes"
        ]
      }
    },
    "/metrics": {
      "get": {
        "description": "The instance's metrics, in the Prometheus text format (version 0.0.4), for Prometheus to scrape: device messages\nby endpoint, route and status, sink deliveries, the database, and more. Each instance has its own; scrape each\none. Its labels name tenants and their endpoints, so it needs the admin login or an install API token (a token\nscoped to one tenant is refused), as the install's routes do: give Prometheus the token in its scrape\nconfiguration (`authorization: { credentials_file: ... }`). Without a login set, it answers on a loopback\naddress, as the whole API does. While the instance starts it answers too, to the login or, with none set, from a\nloopback address; an API token cannot be checked until it has started, and is answered 503.",
        "operationId": "metrics",
        "parameters": [
          {
            "$ref": "#/components/parameters/RequestId"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/plain": {
                "example": "# TYPE houradvantage_database_up gauge\nhouradvantage_database_up 1\n",
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The metrics, Prometheus text format."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyLogins"
          },
          "500": {
            "$ref": "#/components/responses/Failed"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "summary": "Get the metrics",
        "tags": [
          "probes"
        ]
      }
    }
  },
  "security": [
    {
      "basic": []
    },
    {
      "bearer": []
    }
  ],
  "servers": [
    {
      "description": "The default admin address (`--admin-listen`)",
      "url": "http://127.0.0.1:9090"
    }
  ],
  "tags": [
    {
      "description": "Liveness, health, readiness and metrics, for load balancers and monitoring. They need no login and say nothing beyond how the instance is doing.",
      "name": "probes"
    },
    {
      "description": "Tenants: whoever operates clocks through this install, each with its own listeners, endpoints, sinks, sync groups, devices, jobs, vars and secrets under `/api/tenants/{tenant}/...`.",
      "name": "tenants"
    },
    {
      "description": "Listeners, endpoints and sinks; the settings and the log level; vars, secrets and API tokens; the audit trail, the export of the whole setup, and this description.",
      "name": "setup"
    },
    {
      "description": "Package bundles: pushed as revisions, activated per line, rolled back by activating an earlier one.",
      "name": "packages"
    },
    {
      "description": "The device registry, the commands queued for each device, and the device messages that failed.",
      "name": "devices"
    },
    {
      "description": "Stored events, read a page at a time in the order they were stored.",
      "name": "events"
    },
    {
      "description": "Sync groups: their settings, members and the data they keep.",
      "name": "sync"
    },
    {
      "description": "Jobs: one action run over many devices, in waves.",
      "name": "jobs"
    },
    {
      "description": "Time and Attendance, where this instance runs it (`HOURADVANTAGE_ATTEND=on`): its tenants (each an employer, a hard boundary), and per tenant, under `/api/attendance/tenants/{tenant}`, ledgers as last worked out, the facts they are worked out from, who waits to be worked out again, the setup, policy layers and packages, and the delivery keys punches are delivered with.",
      "name": "attendance"
    },
    {
      "description": "What the instances see: the traffic log of the instance that answers, the live stream and wire capture of every instance, the instances running, scenario runs, and the routes instances use to relay live views to each other.",
      "name": "instance"
    }
  ]
}
