# Shift log API

> What the generated route list does not say about the eaxScada shift log routes (Enterprise only) - the order of the checks, the remote-access class, the behaviour on a read-only server, how a signature is prepared, ticketed and redeemed, the request bodies and answers of entries, corrections, closures, reviews and the handover, verification, the period export (ZIP layout, manifest, headers), the verification of an export against the audit trail (its checks and report), the settings document, the shift report starter, the error codes and the audit actions.

Product: eaxScada · Type: Reference · Editions: Enterprise
Source: https://eaxware.com/docs/eaxscada/reference/shift-log-api/
Verified against commit 07f0cdd.

The methods and the right each shift log route requires are listed, from the code, in [HTTP API routes, `/api/shiftlog`](/docs/eaxscada/reference/generated/http-api/#apishiftlog). This page adds what that list does not give. Concepts: [The signed shift log](/docs/eaxscada/explanation/shift-log/).

## How to read this page

- **Remote**: the class through eaxCloud remote access: V view, O operate, E engineer, never.
- Times in a query are RFC 3339 or Unix milliseconds. Request bodies are JSON of at most 512 KiB; a member the route does not know is refused (`400 SHIFTLOG_INVALID`), so a body can never name an author, a signer or a hash.
- An error answer is `{status, code, error}`, with `fields: [{field, error}]` for field errors. The `error` text is for people, the `code` for programs.

## The checks, in order

Every `/api/shiftlog` route checks:

1. **The route**: an unknown path answers `404 SHIFTLOG_NOT_FOUND`; a method the path does not offer `405` with `Allow`. `PUT` and `DELETE` on an entry answer `405` with `Allow: GET`: an entry is never edited or deleted.
2. **Sign-in** (`401`) and **security on** (`403 SHIFTLOG_SECURITY_OFF`).
3. **The edition**: Enterprise, decided at the server's start and kept until it restarts. Otherwise `403` with exactly `{"status":"edition_required","code":"EDITION","feature":"shift_log","required_edition":"enterprise","edition":"<current>","error":"The shift log requires an Enterprise licence or higher"}`. A server without an edition service refuses every route. On a server that started outside Enterprise with shift log records in its audit trail, the `GET` routes stay open (read-only) and every other method answers this `403`.
4. **A write** (any method but `GET`): never an API token or the AI co-pilot (`403 SHIFTLOG_SIGNER`), and never on an HA standby or a primary without quorum (`409 ha_standby`).
5. **The service running** (`503 SHIFTLOG_UNAVAILABLE` otherwise), which checks again: the licence, the read-only mode, the standby, the audit trail (`503 SHIFTLOG_NO_TRAIL` when it does not record, `503 AUDIT_NOT_WRITTEN` when it is down), the person (an inactive account `403 SHIFTLOG_SIGNER`), the log (a disabled log, or one whose calendar is missing, `409 SHIFTLOG_READ_ONLY`) and the right on the log (`403 SHIFTLOG_RIGHT`). A log you may not read answers `404 SHIFTLOG_NOT_FOUND`, as one that does not exist.

**A catch-all DENY refuses every shift log right.** A DENY feature rule whose pattern is `*`, `feature:*` or a prefix ending in `*` (`shiftlog_*`, `shift*`) refuses each right it covers, the Administrator's included. An ALLOW rule with such a pattern grants nothing: only an ALLOW that names the right (`shiftlog_view` or `feature:shiftlog_view`) grants it. The Analytics and Reports rights follow the same rule ([Analytics and Reports reference](/docs/eaxscada/reference/analytics-and-reports/)).

## Signing: prepare, ticket, write

Every password signature takes three requests. The server computes what is signed; the client never sends a hash of its own.

1. **`POST /api/shiftlog/prepare`** `{draft_id}` (an entry, a correction, a closure or a handover draft) or `{review: "<entry id>"}`. Answer `200`: `{object_ref, content_hash, meaning, decision, requires_signature, entry}`. `object_ref` is `shiftlog-entry:<draft id>` (a review: `shiftlog-entry:<entry id>`) or, for a handover, `shiftlog-handover:<log>/<shift start ms>`. `requires_signature: false` means the entry is attributed only: record it without a ticket.
2. **`POST /api/shiftlog/sign-ticket`** `{object_ref, content_hash, decision?, password}`. Answer `200`: `{ticket, expires_at, meaning, decision, object_ref, content_hash}`. The ticket starts with `eso_`, is valid for 60 seconds and is used once. The signer is the signed-in user. The decision and the meaning come from what the server prepared for this user (or, for `shiftlog_handover_in`, from the pending handover it holds): a `decision` in the body that differs is refused (`403 signature_rejected`), a hash that differs `409 SHIFTLOG_STALE`, nothing prepared `409 SHIFTLOG_STALE`. A handover object through remote access: `403 remote_never`.
3. **The write**, with the ticket (below). The server rebuilds the content and refuses it if its hash no longer matches (`409 SHIFTLOG_STALE`), redeems the ticket (used up whatever happens next), writes the audit record, and only then answers. A prepared entry older than 30 minutes is stale.

**The signature asked for at prepare is required at the write.** The prepare stores its decision with the prepared content, as the draft's `prepared_decision` (absent when the entry is attributed only). The write needs a ticket when that decision is set **or** when the log's current settings sign the entry's type. If the log stopped signing the type after the prepare, the write without a ticket is still refused. If it started signing the type after an attributed prepare, the write is refused too. Both answer `403 signature_rejected` ("a signature is required: sign with your password"), and nothing is recorded. In the second case, prepare again and sign. A draft prepared by an earlier build has no `prepared_decision` and follows the current settings.

Decisions and meanings:

| Decision | Meaning | Object |
|---|---|---|
| `shiftlog_record` | Recorded by | `shiftlog-entry:<draft id>` |
| `shiftlog_correct` | Corrected by | `shiftlog-entry:<draft id>` |
| `shiftlog_close` | Closed by | `shiftlog-entry:<draft id>` |
| `shiftlog_review` | Reviewed by | `shiftlog-entry:<entry id>` |
| `shiftlog_handover_out` | Shift handed over by | `shiftlog-handover:<log>/<start ms>` |
| `shiftlog_handover_in` | Shift taken over by | `shiftlog-handover:<log>/<start ms>` |

The meaning reads "\<label>: \<log name>, \<shift name> \<date> \<start>-\<end>" in the site time zone, followed by ", \<title>" for an entry. These decisions are issued and redeemed only over shift log objects, and no other decision is ever issued or redeemed over one.

Refused signatures: a wrong password `403 signature_rejected`; a locked account `429 signature_locked`; a missing password `400 SHIFTLOG_INVALID`; the author reviewing their own entry, or the outgoing operator taking over their own shift, `403 SHIFTLOG_SAME_PERSON`; the AI co-pilot `403 SHIFTLOG_SIGNER`; the signature record not written `503 AUDIT_NOT_WRITTEN`.

## Reads

| Path | Remote | Parameters and answer |
|---|---|---|
| `GET /api/shiftlog/logs` | V | `{logs, status}`. Each log: `id`, `name`, `calendar`, `current_shift`, `handover` (the state), `open_count`, `writable`, `read_only_reason`, `area` (`tag_prefixes` and `alarm_areas`, as in the settings document; `[]` when none), `entry_types` (each type with `enabled`, `sign`, `fields`), `handover_settings` (`required`, `inline_cosign`, `sign_out_window_minutes`, `grace_minutes`), and your rights now: `may_write`, `may_sign`, `may_review`, `may_admin`. `status`: `{writable, read_only_reason}` of this server |
| `GET /api/shiftlog/logs/{log}/shifts?from&to` | V | `{shifts: [{shift, handover, missing}]}`; default the 7 days before `to` (now) |
| `GET /api/shiftlog/logs/{log}/handover?shift_start` | V | The pending handover, or the shift's: `log`, `shift`, `state`, `missing`, `outgoing`, `incoming`, `content` (the handover entry that is signed), `late`, `frozen` and `frozen_reason` ("Not completed: the licence changed"). A read writes nothing: the state is worked out from the audit trail for the answer, and the shift log's watcher, which runs every minute on the server that writes the shift log, stores it for the current and the previous shift |
| `GET /api/shiftlog/entries?log&shift_start&from&to&type&open&author&q&include_void&cursor&limit` | V | `{entries, next_cursor}`, newest first, at most 200 a page (`limit` a positive number; above 200 gives 200). Voided entries only with `include_void=true` |
| `GET /api/shiftlog/entries/{id}` | V | `{entry, chain}`: the entry and its corrections, closures and reviews, in order. When the index does not hold the entry yet (it lags a commit by a moment), the server lets it catch up for at most 2 seconds and asks again; when it still does not, or the index is not available, the entry is read from the audit trail, in the logs you may read, and answered as `{entry}` without `state` and `chain`. An entry the trail holds is never answered `404` |

**An entry** holds `id` (`sle_...`), `log`, `type`, `shift` `{calendar, name, start, end}`, `occurred_at`, `recorded_at`, `author` `{user_id, username, full_name, role}`, `title`, `text`, `priority` (`info`, `normal`, `high`), `open`, `due`, `fields`, `refs` (each `{kind, id, activation_id?, params?, snapshot}`), `relation` `{kind: "corrects" or "closes", entry, reason}`, `ai_assisted`, `handover` (a handover's `entry_hashes`, `items` with their status `text`, and `late`), `content_hash`, `signatures` (each `{decision, user, meaning, at, ticket_hash, inline?, console?}`), `record` (the audit record: `hash`, `origin`, `origin_seq`, `node`, `action`, `at`) and `state` (`closed`, `closed_by`, `corrected_by`, `voided`, `expired`, `late`, `reviews`, `still_open`), which the index derives and which is not part of the record.

**References** (`refs`, at most 32): `tag` (snapshot `value`, `unit`, `quality`, `source_ts`), `alarm` with its `activation_id` (`state`, `priority`, `message`, `trip_time`, `tag`), `batch` (`recipe`, `state`, `start`, `end`), `screen` (`name`) and `entry` (`title`, `type`, `content_hash`). The server takes the snapshot through the author's read rights; something the author may not read is refused (`400`). `lot`, `unit` and `report_run` references are refused on this release (`400`), rather than recorded without a snapshot.

## Drafts

A draft is private to its author, expires after 14 days and is never a record. At most 100 per user.

| Path | Remote | Body and answer |
|---|---|---|
| `GET, POST /api/shiftlog/drafts` | V / O | GET: `{drafts}` (your own). POST: `{log, type, title, text, priority?, open?, due?, occurred_at?, fields?, refs?, relation?, item_status?}`, answer `201` with the draft |
| `GET, PUT, DELETE /api/shiftlog/drafts/{id}` | V / O | PUT: the same body, answer `200`; any change clears what was prepared. DELETE: `204`. A delete is a write like the others: refused on a read-only server, on a standby, to an API token and to the AI co-pilot |

**One commit of a draft at a time.** Recording a draft (an entry, a correction, a closure or a handover sign-out) first takes the draft's claim, one holder across the cluster, then checks the audit trail once more. A second request for the same draft while the first runs (a double click, a retry, two tabs) answers `409 SHIFTLOG_STALE` "this draft is being recorded by another request: reload it to see the entry", and so does a change, a prepare or a delete of that draft meanwhile. A later repeat answers `200` with the first entry. A draft is never recorded twice. A claim left behind by a request that ended without releasing it expires after 2 minutes.

The draft of an entry is checked when it is prepared: `title` 1 to 120 characters on one line (empty for a void), `text` at most 8,000 characters of plain text, `occurred_at` not in the future (60 seconds of clock tolerance) and not further back than the log's window (24 hours by default, at most 168), `open` and `due` only for types that can be open, `due` in the future, an instruction always with `due`, the log's fields per type (text at most 1,000 characters, a number, one of the choices, a date `YYYY-MM-DD` or an RFC 3339 time).

## Entries, corrections, closures, reviews

| Path | Remote | Body and answer |
|---|---|---|
| `POST /api/shiftlog/entries` | O | `{draft_id, ticket?, idempotency_key?}`. `201` with the entry; `200` with the first entry when the same draft was already recorded. A draft with a `relation` is refused: use the routes below |
| `POST /api/shiftlog/entries/{id}/corrections` | O | `{draft_id, reason, ticket?, idempotency_key?}`. The draft holds the corrected content (a void: an empty title and `fields.void: true`). Without a ticket: the server sets the relation, prepares, and records the correction when it needs no signature (`201`), or answers `200` `{status: "signature_required", draft_id, prepared}`. Sign it, then send the same route again with `draft_id` and `ticket` |
| `POST /api/shiftlog/entries/{id}/close` | O | `{text, reason?, draft_id?, ticket?, idempotency_key?}`. Without a ticket the server builds the closure (title "Closed: \<title>") and records it (`201`) or answers `200` `signature_required` with its `draft_id`. A signed closure is sent again with `draft_id` and `ticket` |
| `POST /api/shiftlog/entries/{id}/review` | O | `{ticket, comment?}` after `prepare {review: id}` and a `shiftlog_review` ticket. `200` with the entry. Needs `shiftlog_review` and `shiftlog_sign`; never the author (`403 SHIFTLOG_SAME_PERSON`); a handover is not reviewed. One review per reviewer: a person who already reviewed the entry as it is recorded gets `409 SHIFTLOG_ALREADY_REVIEWED`, read from the audit trail; so does a second review by the same person while the first is being recorded |

Who may:

- **A correction** needs `shiftlog_write`, and the author of the entry or `shiftlog_review`.
- **An instruction** is recorded with `shiftlog_review` only. It is closed or corrected by a reviewer of the log (`shiftlog_review`) or by its author, never by any other writer (`403 SHIFTLOG_RIGHT`). Its valid-until date (`due`) changes only with `shiftlog_review`: an author without it corrects the text and keeps the date. A correction of an instruction keeps a valid-until date (`400 SHIFTLOG_INVALID` on `due` without one); a void ends the instruction and needs none.
- **A signed write** also needs `shiftlog_sign`.

A correction or closure has the type of the entry it acts on; a handover is never corrected or closed; a closed, voided or expired item cannot be closed again, and a corrected item is closed through its latest correction (`400 SHIFTLOG_INVALID`). A closure is refused when the server cannot read the item's current state from the index (`503 SHIFTLOG_UNAVAILABLE`): an item is never closed without knowing whether it is still open.

## The handover

Every handover route is refused through eaxCloud remote access (`403 remote_never`).

| Path | Body and answer |
|---|---|
| `POST /api/shiftlog/logs/{log}/handover` | The outgoing signature: `{draft_id, item_status?, ticket}`. The draft is a handover draft (`type: "handover"`, `text`: the summary, `item_status: [{entry, text}]`, one line of at most 200 characters for every open item), prepared and signed with `shiftlog_handover_out`. Status lines sent here that differ from the draft's are refused (`409 SHIFTLOG_STALE`). `201` with the handover |
| `POST /api/shiftlog/logs/{log}/handover/accept` | The incoming signature: `{content_hash, ticket}` in the incoming operator's own session (a `shiftlog_handover_in` ticket over the pending handover's `content.content_hash`), or `{content_hash, cosigner, password}` at the outgoing operator's console. Both forms at once: `400`. `200` with the handover |
| `POST /api/shiftlog/logs/{log}/handover/decline` | `{content_hash, reason}`: signed in, not password-signed; never the outgoing operator. `200`; the shift goes back to due |
| `POST /api/shiftlog/logs/{log}/handover/withdraw` | `{reason}`: the outgoing operator only (`403 SHIFTLOG_RIGHT` otherwise). `200`; the shift goes back to due |

A reason is 1 to 1,000 characters of plain text.

`content_hash` is required on accept and on decline: the 64 lower-case hexadecimal digits of the pending handover's `content.content_hash`, the content you reviewed. Missing or of another form: `400 SHIFTLOG_INVALID` on `content_hash`. Another hash than the pending one: `409 SHIFTLOG_STALE`.

Sign-out: from the log's sign-out window before the shift end (60 minutes by default); before it, the previous shift if it was not handed over (a late handover), else `409 SHIFTLOG_HANDOVER_STATE`. A summary is required.

Take-over refusals:

- the incoming operator is the outgoing one, compared on the user id and on the user name without regard to case (at the console also the console's own user): `403 SHIFTLOG_SAME_PERSON`;
- no `shiftlog_sign` on the log, or a level below the log's minimum (40 by default): `403 SHIFTLOG_RIGHT`; co-signing at the console turned off for the log: `403 SHIFTLOG_RIGHT`;
- the AI co-pilot, an API token, an inactive account: `403 SHIFTLOG_SIGNER`;
- at the console, a wrong password `403 signature_rejected`, a locked account `429 signature_locked`, a remote session `403 cosign_inline_remote` (checked before any password);
- nothing waiting to be taken over, or it changed while you signed: `409 SHIFTLOG_HANDOVER_STATE`;
- an entry was added or an item closed since the outgoing signature, or the `content_hash` is not the pending one: `409 SHIFTLOG_STALE`;
- this server does not hold the outgoing record yet: `409 SHIFTLOG_HANDOVER_SYNCING`.

## Verification and the index

| Path | Remote | Parameters and answer |
|---|---|---|
| `GET /api/shiftlog/verify?log&from&to&skip_trail_chain` | never | One log you may read, or every log with `shiftlog_admin`. Reads every record again from the audit trail and compares the index: `{ok, records, entries, index_entries, problems: [{kind, ...}], trail_chain, checked_at}`. Kinds: `record`, `duplicate`, `chain`, `signature`, `index_missing`, `index_extra`, `index_differs`, `trail_chain`. Changes nothing. `trail_chain` (the audit trail's own hash chain, in the answer and as a problem kind) is checked and returned for a `shiftlog_admin` only: for anyone else the check is skipped, whatever `skip_trail_chain` says. Each user verifies at most once every 30 seconds and one at a time: sooner, `429 SHIFTLOG_BUSY` with `Retry-After` (seconds) |
| `GET /api/shiftlog/index/problems` | never | `shiftlog_admin`: `{problems: [{record_hash, position, at, action, resource, entry_id, status, problem}]}` (status `flagged` or `duplicate`) |
| `POST /api/shiftlog/index/rebuild` | never | `shiftlog_admin`, `{reason}` (required, at most 1,000 characters): replays the trail into the index and records `INDEX_REBUILT`. `{records, entries, flagged, reason, recorded}` |
| `POST /api/shiftlog/exports` | never | The period export of one log: a ZIP file. See [Period export](#period-export) |
| `POST /api/shiftlog/exports/verify` | never | `shiftlog_view`: checks an export's ZIP, or its `manifest.json`, against this server's audit trail and answers a report of named checks. See [Export verification](#export-verification) |

## Period export

`POST /api/shiftlog/exports` with the body `{log, from, to}`. `from` and `to` are RFC 3339 times or Unix milliseconds (a number or a string). `to` is excluded: a record at `to` is not in the export. The period is at most 366 days.

**What it holds.** Every `SHIFTLOG` record of the log whose audit record time is in [`from`, `to`), read from the audit trail (never from the index), in trail order, up to the newest shift log record of the trail when the export starts. Records appended while it runs are not in it.

**Who may export.**

- The node-wide rights `shiftlog_view` and `shiftlog_admin`, both (`403 SHIFTLOG_RIGHT`). A matching feature DENY refuses them to the Administrator too. Then the log: one you may not read answers `404 SHIFTLOG_NOT_FOUND`, and `shiftlog_admin` on the log is checked again (`403 SHIFTLOG_RIGHT`).
- A person only: never an API token or the AI co-pilot (`403 SHIFTLOG_SIGNER`), nor an inactive account.
- Enterprise, or a server read-only after a licence change (it started outside Enterprise with shift log records in its audit trail: the export stays open there, the other writes answer `403 EDITION`). Otherwise `403 EDITION`.
- Never on an HA standby or a primary without quorum (`409 ha_standby`): the export writes a record.
- Never through eaxCloud remote access (class never).

**Recorded before any byte is sent.** The server reads the records once to compute the SHA-256 and the size of each file, builds the manifest and commits the record `SHIFTLOG EXPORTED` (resource `shiftlog:<log>/export/<export id>`, `new_value` the export id, log, period, trail position, counts, file hashes and manifest SHA-256; `version_ref` the manifest SHA-256). If that record cannot be written the answer is `503 AUDIT_NOT_WRITTEN` and no ZIP is sent; a server whose audit trail does not record answers `503 SHIFTLOG_NO_TRAIL`. Then the ZIP is streamed. The records are read again for each file; a file that would not match its hash in the manifest stops the export before the manifest is written and the response is aborted, so a complete ZIP always matches its manifest.

**The answer** `200`, `Content-Type: application/zip`, `Content-Disposition: attachment; filename="shiftlog-<log>-<from>-<to>.zip"` (times in UTC, `20060102T150405Z`), `Cache-Control: no-store`, and:

| Header | Value |
|---|---|
| `X-Eax-Export-Id` | The export id, `slx_` followed by a ULID |
| `X-Eax-Manifest-Sha256` | The SHA-256 of `manifest.json`, as recorded |
| `X-Eax-Audit-Record` | The record hash of the `SHIFTLOG EXPORTED` record |

**The ZIP**, in this order:

| File | One line (JSON) per |
|---|---|
| `entries.jsonl` | Entry record (entries, corrections, voids, closures, handovers): `{position, record_hash, action, at, entry}`, the entry as the server reads it from its record with its content hash checked. A record that does not verify is a line with `problem` in place of `entry`, never left out |
| `records.jsonl` | Record of the period (the entries' records, reviews, expiries, handover steps, earlier exports): `{position, record}`, the audit record exactly as the trail holds it |
| `manifest.json` | One JSON document (canonical form) |

`manifest.json` holds `format` (`eaxscada.shiftlog.export.v1`), `export_id`, `log`, `log_name`, `from`, `to` (excluded), `range` (what the export holds, in words), `trail_position` (the newest shift log record when the export started; 0 when there is none), `exported_at`, `exporter`, `server_version`, `entries`, `records`, `problems` (entry records that do not verify) and `files`: `[{name, sha256, bytes, lines}]` for `entries.jsonl` and `records.jsonl`.

To check a file later: compute the SHA-256 of `manifest.json` and compare it with the `SHIFTLOG EXPORTED` record in the audit trail (or the value kept from `X-Eax-Manifest-Sha256`), then the SHA-256 of each `.jsonl` file with the manifest. The server does all of this, and compares the records with its trail, in the [export verification](#export-verification).

**Refusals**: `400 SHIFTLOG_INVALID` with `fields` (`log` missing; `from` or `to` missing or not a time; `to` not after `from`; a period longer than 366 days: "export it in parts"), and the codes above.

## Export verification

`POST /api/shiftlog/exports/verify` checks a period export against the audit trail of this server. The trail is the reference: nothing in the file counts until a check ties it to the trail. The answer is a report of named checks, never a bare yes.

**The body** is the export's ZIP as downloaded, or its `manifest.json` alone: as the raw body, or as the part named `file` of a `multipart/form-data` upload. The server tells them apart by their first bytes (`PK` for a ZIP, `{` for a manifest).

- At most 512 MiB: larger answers `413 SHIFTLOG_TOO_LARGE` ("the file is larger than 512 MiB: an export is verified as downloaded, or by its manifest.json alone"). A manifest is at most 1 MiB.
- The ZIP is never extracted to disk. It must hold exactly `entries.jsonl`, `records.jsonl` and `manifest.json`, each once and as a plain, unencrypted file; any other name, a directory, a path or a second copy answers `400 SHIFTLOG_INVALID` before anything is read. Each file is read as a stream, never further than the size recorded at the export (a little further for `records.jsonl`, so that a longer, edited file is still compared line by line).
- The manifest must be one JSON document of the export format (`eaxscada.shiftlog.export.v1`) with an `export_id` and a `log`, and no member it does not know. Otherwise `400 SHIFTLOG_INVALID`.
- An empty body, or one that is neither a ZIP nor a manifest: `400 SHIFTLOG_INVALID`.

**Who may verify.**

- The node-wide right `shiftlog_view` (`403 SHIFTLOG_RIGHT`). A matching feature DENY refuses it to the Administrator too.
- The log the manifest names must be one you may read: otherwise `404 SHIFTLOG_NOT_FOUND`, as a log that does not exist.
- A signed-in, active person, or an API token whose user holds the right: the verification only reads, so it is not a write for this route. Never the AI co-pilot (`403 SHIFTLOG_RIGHT`).
- Enterprise, or a server read-only after a licence change; otherwise `403 EDITION`. It also runs on an HA standby (it reads).
- A server whose audit trail does not record answers `503 SHIFTLOG_NO_TRAIL`.
- One verification per user at a time: a second one while the first runs answers `429 SHIFTLOG_BUSY` with `Retry-After: 5`.
- Never through eaxCloud remote access (class never).

**The checks**, in this order:

| `name` | Passes when | What it proves |
|---|---|---|
| `recorded` | The trail holds exactly one `SHIFTLOG EXPORTED` record of the manifest's export id on its log, and that record describes the export (id, log, manifest hash, the two files) | This server made the export. When there is none, the detail says "not recorded by this server" and every other check is skipped: there is no record to compare with |
| `manifest_hash` | The SHA-256 of the `manifest.json` given is the record's `version_ref` | The manifest is the one recorded at the export |
| `manifest_content` | The manifest's `export_id`, `log`, `from`, `to`, `trail_position`, `entries`, `records` and `files` are the record's | The manifest says what the record says; the detail names the members that differ |
| `file:entries.jsonl` | Its SHA-256, size and line count are the ones recorded | The entries file is unchanged |
| `file:records.jsonl` | The same for the records file | The records file is unchanged |
| `records_in_trail` | Every line of `records.jsonl` is, byte for byte, the trail's record at the line's position, and every record of the export's range on the trail is in the file | The records are the trail's own, with none added or left out; the detail lists the first 10 differences and counts the rest |
| `trail_reproduces` | The trail, read again over the recorded period up to the recorded trail position, gives both files' recorded hashes | The trail still holds what was exported |

The two file checks compare with the trail's `EXPORTED` record, never with the manifest: an edited manifest proves nothing. With the manifest alone, `file:entries.jsonl`, `file:records.jsonl` and `records_in_trail` are skipped ("not checked: only manifest.json was given"); `recorded`, the manifest checks and `trail_reproduces` still run.

**The answer** is `200` whether the export verifies or not, with `Cache-Control: no-store`:

```json
{
  "ok": true,
  "export_id": "slx_01JD...",
  "log": "line2", "log_name": "Line 2 - Filling",
  "form": "zip",
  "recorded_at": "2026-11-16T07:02:11Z",
  "exporter": { "user_id": "...", "username": "jdoe", "role": "Process_Supervisor" },
  "from": "2026-11-15T06:00:00Z", "to": "2026-11-16T06:00:00Z",
  "export_record": "<record hash of SHIFTLOG EXPORTED>",
  "manifest_sha256": "",
  "verified_at": "2026-11-16T09:30:00Z",
  "checks": [ { "name": "recorded", "ok": true, "detail": "SHIFTLOG EXPORTED record ... by jdoe" } ],
  "audit": { "recorded": true, "record_hash": "...", "detail": "recorded as SHIFTLOG EXPORT_VERIFIED" }
}
```

| Member | Meaning |
|---|---|
| `ok` | `true` only when the export is recorded and every check that ran passed |
| `form` | `zip` or `manifest` |
| `recorded_at`, `exporter`, `from`, `to`, `export_record` | From the `EXPORTED` record (zero times and no exporter when it is not recorded) |
| `checks` | `[{name, ok, skipped?, detail}]`. A skipped check is never `ok` |
| `audit` | Whether this verification was recorded, and why not |

**Recorded.** Each verification is recorded as `SHIFTLOG EXPORT_VERIFIED` (resource `shiftlog:<log>/export/<export id>`, `new_value` the export id, log, form, recorded, ok, the failed checks, the manifest SHA-256 and the export record; `version_ref` the manifest SHA-256) when this server records: not on a standby, nor with the audit trail down. A record that is not written never changes the result: `audit.recorded` is `false` and `audit.detail` says why.

**On HA, verify on the node that made the export.** Trail positions are each node's own: a replicated record takes its place in the receiving node's ledger order. On the other node `recorded` and the manifest and file checks can pass while `records_in_trail` and `trail_reproduces`, which compare positions, fail.

In the operator runtime: **More > Verify an export...** in the shift log panel ([Write in the shift log](/docs/eaxscada/how-to/write-in-the-shift-log/#7-verify-an-export)).

## Settings

`GET, PUT /api/dev/shiftlog/settings` (the Studio's **Project > Shift log...**). Remote: GET E, PUT never. Both answer `403 edition_required` outside Enterprise.

- **GET** (any signed-in user): `{doc, _rev, calendars, entry_types}` and an `ETag`. `calendars` are the `reports.shifts` calendar names.
- **PUT** (both the Lead_Engineer or Administrator level and the right `shiftlog_admin`; never an API token or the AI co-pilot, `403`): the settings decide every log's readers, writers, signers and reviewers, so a DENY on `shiftlog_admin` refuses the change to the Administrator too. On an installation upgraded from a release before this rule, only the Administrator holds `shiftlog_admin` until a rule grants it: grant it to your engineers ([Set up shift logs](/docs/eaxscada/how-to/set-up-shift-logs/#2-grant-the-rights)). The document as GET gave it, at most 1 MiB (`413`), with `If-Match` or its `_rev`. Answers: `200` with the saved document; `400 invalid` with `problems` (one line each); `409 stale` (changed since your revision); `409 has_entries` with `logs` (a log removed while it holds entries: disable it); `503 AUDIT_NOT_WRITTEN` (the record `SHIFTLOG_SETTINGS UPDATE` could not be written; nothing changed). On HA, the primary with quorum.

### Settings document

```json
{
  "version": 1,
  "logs": [
    {
      "id": "line2",
      "name": "Line 2 - Filling",
      "calendar": "default",
      "disabled": false,
      "area": { "tag_prefixes": ["line2/"], "alarm_areas": [] },
      "readers": [], "writers": [], "signers": ["role:Shift_Operator"], "reviewers": ["role:Process_Supervisor"],
      "entry_types": {
        "note": { "sign": false },
        "maintenance": { "fields": [ { "name": "equipment", "label": "Equipment", "kind": "text", "required": true } ] },
        "instruction": { "disabled": true }
      },
      "handover": { "required": true, "grace_minutes": 30, "inline_cosign": true, "sign_out_window_minutes": 60, "min_cosign_level": 40 },
      "past_window_hours": 24
    }
  ]
}
```

| Member | Rule |
|---|---|
| `version` | `1` |
| `logs` | At most 200 |
| `id` | `[a-z][a-z0-9_-]{0,31}`, unique |
| `name` | One line, 1 to 80 characters, no leading or trailing blanks |
| `calendar` | A calendar of `reports.shifts`, required |
| `disabled` | The log is read-only |
| `area.tag_prefixes`, `area.alarm_areas` | Up to 64 each, one line of 1 to 256 characters |
| `readers`, `writers`, `signers`, `reviewers` | Up to 200 each: `role:<name or id>`, `group:<name or id>` or `user:<username or id>`, no duplicates. Empty: no narrowing |
| `entry_types.<type>.disabled` | Not for `handover` |
| `entry_types.<type>.sign` | `note` and `maintenance` only, each on its own (the other types are always signed) |
| `entry_types.<type>.fields` | Up to 20: `name` `[a-z][a-z0-9_]{0,31}`, unique in the type, never `void` (reserved for corrections), `label` at most 80 characters, `kind` `text`, `number`, `choice` (1 to 50 `choices`, each 1 to 80 characters) or `date`, `required`. The Studio edits the fields of every type except `handover` |
| `handover.required` | Default `true` |
| `handover.inline_cosign` | Default `true` |
| `handover.grace_minutes`, `handover.sign_out_window_minutes` | 0 to 480; 0 means the default (30, 60) |
| `handover.min_cosign_level` | 0 to 1000; 0 means 40 |
| `past_window_hours` | 0 to 168; 0 means 24 |

An unknown member is refused, never dropped.

A saved document never changes a recorded entry: recorded entries keep their fields, values and signatures. A required field is checked on every entry, whichever client sends it: an entry without it answers `400 SHIFTLOG_INVALID` with `fields.<name>` "required". A void or a closure does not repeat the required fields.

## Shift report starter

`POST /api/reports/starters/shift-log` `{project_id?}` adds the starter report `rep_shift_log` and its six datasets `ds_shiftlog_*` to the project (the active one by default). An id that is taken is added under a new id (`_2`, `_3` ...), never replaced. Needs Enterprise (`403 EDITION`) and Analytics and Reports, a person with `datasets_edit`, `reports_design` and the engineer level (`403 REPORTS_RIGHT`, `403 ENGINEER_LEVEL`), never an API token (`403 REPORTS_TOKEN`) or the AI co-pilot (`403 REPORTS_AI`), the primary (`409`). A dataset that does not check refuses the whole apply (`422`, nothing added). The apply is recorded first (`PROJECT TEMPLATE_APPLY`; unwritten: `503 AUDIT_NOT_WRITTEN`). It is never allowed through eaxCloud remote access (class never), like a change of the settings: it writes datasets and a report to the project on this server.

A schedule runs the report after each handover with the trigger kind `shiftlog_handover` and the trigger's `log` ([Schedule a report](/docs/eaxscada/how-to/schedule-a-report/)).

## Error codes

| HTTP | `code` | When |
|---|---|---|
| 400 | `SHIFTLOG_INVALID` | Field errors, in `fields` |
| 403 | `EDITION` | Not Enterprise (the body above) |
| 403 | `SHIFTLOG_SECURITY_OFF` | Security is off |
| 403 | `SHIFTLOG_RIGHT` | A missing right on the log, a level below the log's minimum |
| 403 | `SHIFTLOG_SIGNER` | The AI co-pilot, an API token, an inactive account |
| 403 | `SHIFTLOG_SAME_PERSON` | The incoming operator is the outgoing one; the reviewer is the author |
| 403 | `signature_rejected` | A wrong password; a ticket for another object, hash, decision or person |
| 403 | `cosign_inline_remote`, `remote_never` | eaxCloud remote access |
| 404 | `SHIFTLOG_NOT_FOUND` | An unknown route, log or entry, or one you may not read |
| 405 | none | A method the path does not offer (`PUT`, `DELETE` on an entry) |
| 409 | `ha_standby` | A standby, or a primary without quorum |
| 409 | `SHIFTLOG_STALE` | The content changed since it was prepared, or since the outgoing signature; the `content_hash` of an accept or decline is not the pending one; the draft is being recorded by another request |
| 409 | `SHIFTLOG_ALREADY_REVIEWED` | You already reviewed this entry, or your review of it is being recorded |
| 409 | `SHIFTLOG_HANDOVER_STATE` | The handover is not in a state that allows the step |
| 409 | `SHIFTLOG_HANDOVER_SYNCING` | This server does not hold the outgoing record yet |
| 409 | `SHIFTLOG_READ_ONLY` | The log is disabled, or its shift calendar is missing |
| 429 | `signature_locked` | Signature lockout |
| 413 | `SHIFTLOG_TOO_LARGE` | An export to verify larger than 512 MiB |
| 429 | `SHIFTLOG_BUSY` | A verification by you ran less than 30 seconds ago, or is still running (an export verification: one at a time); `Retry-After` gives the seconds to wait |
| 503 | `AUDIT_NOT_WRITTEN` | The record could not be written; nothing stored, the draft kept |
| 503 | `SHIFTLOG_NO_TRAIL` | The audit trail does not record on this server |
| 503 | `SHIFTLOG_UNAVAILABLE` | The shift log, its index or its key-value store is not available; a closure whose item state cannot be read from the index |

## Audit actions

Category `SHIFTLOG`. Resource `shiftlog:<log>/<entry id>`, or `shiftlog:<log>/shift/<start ms>` for a handover step; resource name "\<log name>, \<shift name> \<date>"; `new_value` the canonical content, `version_ref` the content hash, the signature manifest "\<decision>|\<user>|\<meaning>|\<ticket hash>" (at the console: `inline:<console user>` in place of the ticket hash).

| Action | Recorded when |
|---|---|
| `ENTRY_RECORDED` | An entry is recorded |
| `ENTRY_CORRECTED` | A correction (`old_value`: the corrected entry's content hash) |
| `ENTRY_VOIDED` | A void |
| `ENTRY_REVIEWED` | A review signature |
| `ITEM_CLOSED` | A closure |
| `ITEM_EXPIRED` | An instruction passed its valid-until (the system) |
| `HANDOVER_SIGNED` | The outgoing signature |
| `HANDOVER_ACCEPTED` | The incoming signature (`old_value`: the outgoing record's hash) |
| `HANDOVER_DECLINED`, `HANDOVER_WITHDRAWN` | A decline, a withdrawal |
| `HANDOVER_MISSING` | The grace ended without a completed handover (the system) |
| `INDEX_REBUILT` | The index was rebuilt from the trail |
| `EXPORTED` | A period export, before it is sent (resource `shiftlog:<log>/export/<export id>`) |
| `EXPORT_VERIFIED` | A verification of an export, passed or failed (resource `shiftlog:<log>/export/<export id>`, or `shiftlog:<log>/export/unrecorded` for an id this server does not issue) |

A settings change is recorded as category `SHIFTLOG_SETTINGS`, action `UPDATE`.
