# Genealogy API

> What the generated route list does not say about the part and lot genealogy routes of eaxScada - remote-access class, behaviour after a licence downgrade, parameters, request bodies and answers - with the signed-request rules and the WebSocket messages.

Product: eaxScada · Type: Reference · Editions: Pro, Enterprise
Source: https://eaxware.com/docs/eaxscada/reference/genealogy-api/
Verified against commit 9d50b4d.

The methods and the role or right each genealogy route requires are listed, from the code, in [HTTP API routes, `/api/genealogy`](/docs/eaxscada/reference/generated/http-api/#apigenealogy). This page adds what that list does not give: the remote-access class, the behaviour after a licence downgrade, and the parameters and answers. Concepts: [Part and lot genealogy](/docs/eaxscada/explanation/genealogy/).

## How to read this page

- **Remote**: the class through eaxCloud remote access: V view, O operate, E engineer, E-live engineer applied live (refused when the site asks for a review), never.
- **Edition**: *reads* works after a licence downgrade; *licensed* needs genealogy in the licence, else `403` with `code: "EDITION"`.

**Signed requests** carry `password` (re-entered), `reason` and optionally `meaning`. The signer is always the session user: a `signer` that is not the session user is refused with `400 SIGNER_NOT_SESSION_USER`. API tokens cannot write records. Actions recorded first are refused with `503 AUDIT_NOT_WRITTEN` when the audit record cannot be written.

**A refused signature** (the signer's own, or a correction's second person's): a wrong password, an unknown or disabled signer answer `403` with `"status": "signature_refused"`; a locked account `429` (the fifth wrong password locks it for 15 minutes); a missing password `400`. `401` only means no session: a wrong password never signs the person out.

## Reads

| Path | Remote | Edition | Parameters and answer |
|---|---|---|---|
| `GET /api/genealogy/units?q=&type=&status=&limit=&before=` | V | reads | `q` exact: `{match:"exact",units,count}`; no exact hit: units whose ID starts with `q`, `{match:"prefix",units,count,truncated}` (at most 500); `q` empty: newest first, `{match:"list",units,count,next_before}` |
| `GET /api/genealogy/units/{key}` | V | reads | `{unit,state,operations,consumed_by,components,linked_units,links_truncated}` |
| `GET /api/genealogy/units/{key}/trace?dir=backward\|forward&depth=&nodes=` | V | reads | The units reached and the links; `depth` 1 to 100 (default 20), `nodes` up to 100,000 (default 5,000) |
| `GET /api/genealogy/units/{key}/timeline` | V | reads | `{unit,timeline}` |
| `GET /api/genealogy/units/{key}/operations` | V | reads | `{unit_key,operations}` |
| `GET /api/genealogy/units/{key}/events?limit=&before_seq=` | V | reads | The unit's records newest first, at most 500 a page: `{unit_key,events,count,next_before_seq}` |
| `GET /api/genealogy/operations/{opID}[/results]` | V | reads | `{operation,results}`; values of tags you may not read: `value_hidden: true` |
| `GET /api/genealogy/events/{id}` | V | reads | `{event,content_hash,payload_filtered}` |
| `POST /api/genealogy/recall` | V | reads | Body `{lot_type,lot_id,generation,finished_only,max_depth}`; answer: JSON lines, one unit per line, last line `{done,count}`; `429` while you already run one |
| `GET /api/genealogy/status` | V | reads | Recording, store, disk floor, trace index, writer and trigger figures |

## Configuration

| Path | Remote | Edition | Parameters and answer |
|---|---|---|---|
| `GET, POST /api/genealogy/types` | V / E-live | reads / licensed | GET: `{types,warnings}`; POST: a unit type, answer `{status,document,type,warnings}` |
| `GET, PUT, DELETE /api/genealogy/types/{name}` | V / E-live | reads / licensed | Same |
| `GET, POST /api/genealogy/triggers` | E / E-live | reads / licensed | GET: `{triggers,status,warnings}`; POST: a capture trigger, answer `{status,document,trigger,warnings}` |
| `GET, PUT, DELETE /api/genealogy/triggers/{id}` | E / E-live | reads / licensed | Same |
| `POST /api/genealogy/trigger-check` | E | reads | Checks a trigger, saves nothing: `{trigger,warnings,ok,error?,handshake:[{field,tag,ok,kind,error?,granted,grant_why}]}` |
| `GET, PUT /api/genealogy/settings` | E / never | - | `data/genealogy/settings.json`; a PUT answers `restart_required: true` (applies at the next start) |

**`warnings`** on a GET of the unit types or triggers is the check of the saved documents, keyed by type name or trigger id, each a list of texts (`{}` when nothing is wrong). It names fields that older configurations still carry but that have no effect: they load with their value ignored, and the next save of that type or trigger removes them. On a save, `warnings` is the list for the document just saved. A request that still sends such a field is accepted, and the field is ignored.

## Records

| Path | Remote | Edition | Body and answer |
|---|---|---|---|
| `POST /api/genealogy/records` | O | licensed | `{kind,occurred_ns,idem_key,unit,components,op,results,status,qty,uom,reason,password?}` with `kind` UNIT_CREATED, UNIT_RECEIVED, LINK, OP_START, OP_END, OP_RECORD or STATUS; a STATUS to or from QUARANTINED is signed. Answer `{status:"recorded"\|"duplicate",result}` |
| `POST /api/genealogy/corrections` | O | licensed | `{corrects,result?,operator?,start_ns?,end_ns?,results?,void_links?,add_components?,reason,password,second_signer?}`; a second signer is refused remotely |
| `POST /api/genealogy/voids` | O | licensed | `{corrects,reason,password}` |
| `POST /api/genealogy/import[?dry_run=1]` | E | licensed (dry run: reads) | `{format:"jsonl"\|"csv",table:"units"\|"links",file_name,content,reason,password}`; the dry run is unsigned and answers `{sha256,rows,invalid,errors}`, the import `{import_event,written,duplicates,refused}` |

## Exports, verification and purge

| Path | Remote | Edition | Parameters and answer |
|---|---|---|---|
| `GET /api/genealogy/export?what=trace&key=&dir=` | E | reads | File, `format=csv` or `jsonl` |
| `GET /api/genealogy/export?what=recall&lot_type=&lot_id=&finished_only=1` | E | reads | File |
| `GET /api/genealogy/export?what=range&from=&to=&kind=` | E | reads | The records with plant time in `[from, to)` (RFC 3339 or Unix nanoseconds), optionally of some kinds, with their hashes |
| `POST /api/genealogy/verify` | never | reads | The chain check, with `tombstones` and `purges`. When the chain anchors cannot be read from the audit trail: `500` `{"ok": false, "status": "anchors_unreadable", "error": "..."}`, nothing verified, recorded as `GENEALOGY_VERIFY` "not verified: anchors unreadable" |
| `POST /api/genealogy/purge[?dry_run=1]` | never | - | Needs `genealogy.write` too. The dry run is unsigned: `{status:"plan",plan,retention}`; the purge `{status:"purged"\|"nothing_to_purge",result}`. Refusals: `PURGE_ON_SITE`, `PURGE_ON_PRIMARY`, `NO_RETENTION`, `NO_RECOVERY_KEY` |
| `GET /api/genealogy/archives` | never | - | `{archives,encrypted_to}` |
| `GET /api/genealogy/archives/{file}` | never | - | The archive file (encrypted to the recovery key); recorded as `GENEALOGY_ARCHIVE_DOWNLOAD` |

There is no PDF route: the Studio's print layouts use the browser's print.

## WebSocket messages

`GENEALOGY_CAPTURE_EVENT`, `GENEALOGY_RECORDED`, `GENEALOGY_CONFIG_CHANGED` and `GENEALOGY_PURGED` are broadcast on the Studio's live socket.

## Related

- [HTTP API routes](/docs/eaxscada/reference/generated/http-api/): every route of the server, with its role.
- [Trace, recall and export genealogy](/docs/eaxscada/how-to/trace-recall-and-export-genealogy/)
