# Deploy settings

> The two deploy settings eaxPLC enforces itself on every program load - Require e-signature to deploy and Require a signed review approval to deploy - with their defaults, who may change them, the API, the refusal codes, the PLC's deploy ledger and rollbacks, the trusted approval key, the approval's validity and the audit records.

Product: eaxPLC · Type: Reference · Editions: Free, Pro
Source: https://eaxware.com/docs/eaxplc/reference/deploy-settings/
Verified against commit f7b4d30.

Each eaxPLC project has two deploy settings, and a third for the untest of an online edit. eaxPLC enforces them itself, on every path that loads a new program: `POST /api/deploy` and `POST /api/rollback` over HTTP, the NATS API (`plc.<id>.api`), the older NATS subjects, and deploys that eaxScada forwards. A client cannot skip them.

## The settings

| Setting | Default, new project | Default, existing project | When on |
|---|---|---|---|
| **Require e-signature to deploy** | **On** | **On** (eaxPLC always required it: an upgrade changes nothing) | every deploy and rollback carries the user's e-signature: their password again, over a meaning that names the program and its sha256 |
| **Require a signed review approval to deploy** | **Off** | **Off** | the PLC refuses a program it has not deployed before unless the deploy carries a signed review approval of exactly that program (see below) |
| **Require e-signature to untest an online edit** | **Off** | **Off** | an untest (the accepted program put back during an online edit) carries the engineer's e-signature; off, the engineer and the reason are still recorded ([Make online edits](/docs/eaxplc/how-to/make-online-edits/)) |

They are kept in `data/deploy_policy.json` in the PLC's work directory, written with the defaults at the first start. A file that cannot be read fails closed: both deploy settings count as **on** until an engineer saves them again (signed); the untest setting stays off.

| | |
|---|---|
| **Who reads them** | any signed-in user |
| **Who changes them** | Lead_Engineer or Administrator (level 80 and above), never the AI co-pilot, always with their e-signature, whether a setting is turned on or off |
| **Audit** | every change is a `CONFIG` / `DEPLOY_POLICY` record in the PLC's audit trail, with the old and new settings and the reason; a refused signature is a `DEPLOY_POLICY_REFUSED` record |
| **Edition** | every edition |

## Where to change them

- **The eaxPLC Web Studio**: **File → Project Settings** ([Set the deploy settings](/docs/eaxplc/how-to/set-the-deploy-settings/)).
- **The API**: `POST /api/deploy/policy`.

The eaxScada review page of a PLC program shows the PLC's own settings in its **Deploy gate on PLC** card; it reads them, it never changes them.

## The review approval

With **Require a signed review approval to deploy** on, a deploy of a program whose sha256 is not in the PLC's deploy ledger must carry a `review_approval`: an attestation that an approved eaxScada review covers exactly this program for exactly this PLC.

| Check | The approval is refused when |
|---|---|
| Format | it is not a deploy approval v1 (unknown members are refused) |
| PLC | it names another PLC than this one (`--plc-id`) |
| Program | its `program_hash` is not the sha256 of the program being loaded |
| Review | it names no review or no approver |
| Validity | its validity is not between 1 second and 15 minutes; it is issued more than 2 minutes in the future; it has expired |
| Key | it is not signed by a key this PLC trusts, or the signature does not verify |

eaxScada issues approvals valid for **5 minutes**. The PLC's clock and eaxScada's clock must agree within about **2 minutes**: a PLC clock that is behind sees the approval as issued in the future, one that is ahead sees it expired sooner.

### Where an approval comes from

eaxScada signs approvals; it issues one only for a review of exactly this program (sha256) for exactly this PLC, approved under the site's review policy, and only to a Lead_Engineer or Administrator.

| Deploy from | How the approval gets there |
|---|---|
| **The eaxPLC Web Studio** | With *Require a signed review approval to deploy* on, the deploy dialog asks eaxScada for the approval of exactly the program you are deploying and attaches it. eaxScada issues one only when a review of this exact source (sha256) has been approved under the site's review policy, and only to a Lead_Engineer or Administrator. If there is none, the dialog says *No approved review for this program* and nothing is sent: request a review in eaxScada and deploy once it is approved. A program this PLC has deployed before needs no new approval. An approval is valid for 5 minutes; the PLC verifies it on every deploy. |
| **Through eaxScada** (deploys eaxScada forwards, the AI assistant, MCP clients) | eaxScada's review gate lets the program through on an approved review and adds the approval to the deploy, when the client sent none; a client's own approval is forwarded as sent and judged by the PLC. The assistant and MCP keep PLC source byte for byte (no whitespace trimming), so the deployed text is exactly the reviewed text. |

See [Review screens and PLC programs before deploy](/docs/eaxscada/how-to/review-before-deploy/#deploy-a-reviewed-plc-program).

### The trusted approval key

The PLC trusts one approval key: **eaxScada's PLC token key**, the key it already pins to verify eaxScada's sign-ins (`--token-pin`, default `data/security/scada_plc_token.pub`, or `--token-pubkey`). An approval and a sign-in token are signed for different purposes (the approval's signature starts with its own prefix), so one never passes as the other.

| PLC mode | Trusted approval key |
|---|---|
| Connected to eaxScada (`--scada-url`), key pinned | eaxScada's PLC token key, once the PLC trusts that same key for sign-ins |
| Connected, key not pinned yet | none until it is pinned; the PLC keeps looking |
| Standalone (`--standalone`), development mode (`EAX_DEV_MODE=1`), or no eaxScada configured | none |

With no trusted key, every approval is refused: with the review setting on, only a version the PLC deployed before can be loaded. `GET /api/deploy/policy` reports the state in `approval_trust`.

To accept a new eaxScada key (eaxScada reinstalled, or its key replaced), delete the pin file and restart the PLC: it fetches and pins the key again at its first contact with eaxScada.

## The deploy ledger and rollbacks

"Deployed before" means: the program's sha256 is in **this PLC's own deploy ledger**, the `DEPLOYED_PROGRAM` records that the PLC appends to its audit trail each time a program starts running. The chain must verify: when it does not, no program counts as deployed before (fail closed).

| Program being loaded | With the review setting on |
|---|---|
| A program never deployed on this PLC | needs a valid approval |
| A rollback to a version this PLC deployed before | allowed without a new review; still e-signed when **Require e-signature to deploy** is on; audited as a rollback |
| A rollback to a stored revision this PLC never ran | needs an approval, like a new program |

A refused deploy or rollback leaves the running program untouched.

## The API

### `GET /api/deploy/policy`

```json
{"plc": "plc-01", "require_esign": true, "require_review_approval": true, "require_esign_untest": false,
 "approval_trust": {"state": "configured", "keys": 1, "key_ids": ["e6205a0c"],
   "detail": "approvals signed by eaxScada's PLC token key (key id e6205a0c) are trusted"}}
```

`approval_trust.state` is `configured` or `none`. Any signed-in user.

### `POST /api/deploy/policy`

```json
{"require_review_approval": true, "reason": "MOC 2026-021", "signature_password": "..."}
```

`require_esign`, `require_review_approval` and `require_esign_untest` are optional (a missing one is unchanged); `reason` is recorded (at most 200 characters). Lead_Engineer or Administrator, with the e-signature (`signature_password`). Answers the settings with `success` and `changed`. Without the level or the signature: `403`.

### `POST /api/deploy/review-approval`

```json
{"source": "PROGRAM PumpStation\n..."}
```

The review approval for a deploy of `source` (the program exactly as the deploy will send it), fetched by the PLC from its eaxScada (`POST /api/collab/plc-approval`) with the caller's own credential. Lead_Engineer or Administrator only, never the AI co-pilot. The PLC decides nothing here: it hands the approval over as eaxScada signed it, and verifies it again when the deploy arrives. The Web Studio's deploy dialog uses it.

| HTTP | Answer |
|---|---|
| `200` | `{"plc", "program_sha256", "required": false, "detail"}`: the deploy needs no approval (the setting is off, or the program is in this PLC's deploy ledger: `"rollback": true`) |
| `200` | `{"plc", "program_sha256", "required": true, "review_approval", "review", "approvers", "expires_at"}`: attach `review_approval` to the deploy body as it is |
| `409` | `code` `no_approved_review` (eaxScada has no approved review of exactly this program for this PLC, or the PLC is not connected to an eaxScada that issues approvals), or `review_approval_invalid` (the approval eaxScada returned would be refused by this PLC, for example clocks apart) |
| `403` | the caller is not an engineer, or eaxScada refused the caller (`code` `no_approved_review`) |
| `400` | the body is not `{"source": ...}` |
| `502` | eaxScada could not be reached, or answered with another error |

### Deploy and rollback bodies

`POST /api/deploy` and `POST /api/rollback` take an optional `review_approval` member (the approval object). With **Require e-signature to deploy** on they also need `signature_password`, as before.

### Refusals

| HTTP | `code` | When |
|---|---|---|
| `409` | `review_approval_required` | the review setting is on, the program is not in the deploy ledger, and the deploy carries no approval |
| `403` | `review_approval_invalid` | the approval fails one of the checks above, or the PLC trusts no approval key |
| `403` | | a missing or wrong e-signature: eaxScada refused the signature (`403` or `400`, or an older eaxScada's `401` with a refusal text such as "invalid username or password"); the person stays signed in. A locked account is refused the same way (eaxScada answers `429` and counts the failures) |
| `401` | | not signed in to eaxScada: eaxScada has no session for the person (`401` with `code: "no_session"`, an older eaxScada's "a signed-in user is required to sign", or a `401` without a readable answer). The PLC answers "not signed in to eaxScada: sign in again to sign ..."; the Studio asks the person to sign in again and sends the request once more |
| `409` | `ai_safety_targets_missing` | the program is AI-made and this PLC has no safety-target list |
| `409` | `ai_program_does_not_compile` | the program is AI-made and its writes cannot be checked |
| `409` | `ai_safety_target_ambiguous` | the program is AI-made and an unscoped safety target (`Speed`) names a variable that a PROGRAM other than the main one also declares: list it with its program (`Line2.Speed`) ([AI guard](/docs/eaxplc/explanation/compiler-and-vm/#45-cross-reference-and-the-ai-guard)) |
| `409` | `ai_writes_safety_target` | the program is AI-made and writes a safety target, a part of one or storage shared with one |

The answer is `{"success": false, "code", "error", "program_sha256"}`.

## Audit records

| Category / action | When |
|---|---|
| `PROGRAM_DEPLOY` / `DEPLOYED_PROGRAM` | a program starts running (the deploy ledger) |
| `PROGRAM_DEPLOY` / `DEPLOY_REFUSED`, `ROLLBACK_REFUSED` | refused by the review gate (with the code and reason) or for a missing or wrong e-signature |
| `PROGRAM_DEPLOY` / `ROLLBACK` | a rollback, with the review gate's note when the setting is on |
| `CONFIG` / `DEPLOY_POLICY` | the settings changed |
| `PROGRAM_DEPLOY` / `DEPLOY_POLICY_REFUSED` | a change refused for a missing or wrong e-signature |

A deploy that the review gate let through records which review approved it, its approvers and the key, or that it was a rollback to a version deployed before. A deploy made with **Require e-signature to deploy** off records that no signature was required.

## Related

- [Set the deploy settings](/docs/eaxplc/how-to/set-the-deploy-settings/)
- [Review screens and PLC programs before deploy](/docs/eaxscada/how-to/review-before-deploy/)
- [Command-line flags](/docs/eaxplc/reference/generated/cli/)
