Historian CSV import API
The routes behind System Health > Historian storage > Review import…. How to use them from the studio: Import the CSV history into the store. The offline way is the command eaxscada historian-migrate-csv, with the server stopped.
Who may call them
Section titled “Who may call them”- A signed-in Administrator, in a login session. Every route answers
401without a session, and403for a user who is not an Administrator, for an API token and for the AI co-pilot account. - Never over remote access. The routes are not served to an eaxCloud remote session.
- Builds with the embedded database. A build without it has no columnar store to import into:
GETanswers503. - A server without user security answers
403(“the CSV history import needs user security”).
The routes
Section titled “The routes”| Method | Path | What it does |
|---|---|---|
| GET | /api/historian/migration |
The plan, the disk, the estimate (?estimate=1), the state and the per-day results. Writes nothing. |
| POST | /api/historian/migration/sign |
Signs a start or a retry with the password and a reason: a one-time ticket. |
| POST | /api/historian/migration/start |
Starts the import of the plan signed. |
| POST | /api/historian/migration/retry |
Plans the days kept for attention again and imports them. |
| POST | /api/historian/migration/pause |
Pauses the import after the day in progress. |
| POST | /api/historian/migration/resume |
Resumes a paused import. |
The HTTP API routes list them with the other historian routes.
GET /api/historian/migration
Section titled “GET /api/historian/migration”{ "node": "node-scada-4222", "decision": "historian_migrate", "status": { "state": "none", "approval": {"by": "", "source": "", "reason": "", "plan_hash": ""}, "units": 0, "deleted": 0, "imported": 0, "held": 0, "inserted": 0, "recovered": 0, "conflicts": 0, "freed_bytes": 0 }, "plan": { "units": [{"dir": "year=2026/month=11/day=05/tag=Plant_Processing_Tanks_TK101_Level", "day": "2026-11-05", "files": [{"name": "data.csv", "size": 132537, "mod_ns": 1794321621572545200}], "bytes": 132537}], "days": 5, "folders": 20, "files": 20, "bytes": 2686748, "first_day": "2026-11-01", "last_day": "2026-11-05", "est_rows": 33169, "disk_needed": 537020172, "hash": "d4a40439...a246e" }, "start_meaning": "Import 5 days of CSV history (2.6 MB, 20 folders, 2026-11-01 to 2026-11-05) into the columnar store of node node-scada-4222, and delete each day's CSV files after verification. Deleted files cannot be restored (plan d4a404391325)", "disk": {"known": true, "free": 95445536768, "critical_margin": 536870912, "needed": 537020172, "enough": true}, "estimate": {"low_s": 1.29, "high_s": 2.57}, "units": []}| Member | Meaning |
|---|---|
node |
This server’s node id. The plan, the meanings and the audit references name it. |
decision |
Always historian_migrate: the e-signature decision of the import. |
status.state |
none (no import approved), running (resumes after a restart), paused (by an administrator, or low disk), done (every day imported and deleted), attention (finished, some days kept). |
status.reason |
Why it is paused, for example “paused by an administrator” or the low-disk cause. |
status.approval |
Who approved the run: by, source (studio or cli), reason, plan_hash. |
status.units, deleted, imported, held |
Day folders in the approved run; imported and deleted; imported, files not deleted yet; kept for attention. |
status.inserted, recovered, conflicts, freed_bytes |
Points added to the store; of them, points the store lacked (recovered); keys where the store keeps another value; CSV bytes deleted. |
status.held_units |
[{unit, reason}]: each day folder kept for attention and why. |
plan |
The CSV history to import, newest day first. Only when the state is not running or paused. |
plan.units |
One entry per tag folder of one UTC day: dir (relative to the historian folder), day, files (name, size, mod_ns), other (files of the folder that are not partition files: kept), bytes. |
plan.days, folders, files, bytes, first_day, last_day |
The size of the CSV history. |
plan.est_rows |
Estimated points (the size divided by 81 bytes per row). |
plan.disk_needed |
The disk the import needs: the estimated store growth (the estimated points at the store’s own bytes per point, plus half) and 512 MB for staging. |
plan.skipped, plan.recent |
Folders left out; recent: written in the last 2 minutes (their older days are kept too). |
plan.hash |
What a start signs: the plan as shown. |
start_meaning |
The text an administrator signs to start. Only when the plan has days. |
disk |
known (free space readable on this system), free, critical_margin (historian.disk.critical_free), needed, enough (free covers needed plus the margin). Only when the plan has days. |
estimate |
With ?estimate=1 only: low_s and high_s, a duration range in seconds. One day folder is read (nothing written) to measure the read rate; the import, which also writes and verifies, takes 2 to 4 times the read. |
units |
The approved run’s day folders as the import left them (the per-day grid): unit, day, folder, tags, bytes, state (waiting, imported, deleted, held), reason, rows_csv, inserted, conflicts, recovered, torn, freed_bytes. |
held_hash, retry_meaning |
Only when days are kept for attention: what a retry signs, and the text an administrator signs. |
Errors: 401, 403 (above); 503 when the historian is not initialized or the plan cannot be read.
- Authentication
- Refusal
Read as text
An import starts as a reviewed plan. A signed start sets it running; a signed start that does not start is recorded as refused, and nothing is imported. A running import can be paused, by an administrator or by low disk, and stays paused until an administrator resumes it. A server shutdown stops it after the day in progress, and the next start of the server goes on. The run ends with every day imported and deleted, or with days kept for attention. Kept days can be retried with a new signature, which sets the import running again. In the grid each day is waiting, imported, imported and deleted, or kept for attention.
States
- Plan reviewed (state): nothing written yet
- Server stopped (state): the run has not ended
- Running (state): day by day, newest first
- Paused (state): stays until Resume
- Ended: all imported (state): HISTORIAN_MIGRATION_DONE
- Ended: days kept (state): HISTORIAN_MIGRATION_HELD
Transitions
- Start → Plan reviewed (transition)
- Plan reviewed → Running (authentication): signed start: HISTORIAN_MIGRATION_START. The audit record is written with the signature before anything is imported. If it cannot be written, nothing starts.
- Plan reviewed → Plan reviewed (refusal): signed, not started: HISTORIAN_MIGRATION_REFUSED. The disk is too full, or another start, retry or run is in progress. Nothing is imported. The start record HISTORIAN_MIGRATION_START is already written at that point, and HISTORIAN_MIGRATION_REFUSED follows it. A plan that changed since the dialog showed it, or no CSV history to import, is refused before the signature is used: the dialog shows the new plan.
- Running → Paused (transition): Pause, low disk. Pause stops after the day in progress and is recorded as HISTORIAN_MIGRATION_PAUSED. The import pauses by itself before a day that does not fit on the disk, and when the disk is critically full.
- Paused → Running (transition): Resume. An administrator resumes, with no new signature. It is recorded as HISTORIAN_MIGRATION_RESUMED.
- Running → Server stopped (transition): server stops. The day in progress is finished first.
- Server stopped → Running (transition): next start. The server goes on by itself. A paused import stays paused.
- Running → Ended: all imported (transition): every day imported and deleted
- Running → Ended: days kept (transition): days kept
- Ended: days kept → Running (authentication): Retry kept days, signed: HISTORIAN_MIGRATION_RETRY. The record is written before anything changes. The kept days are planned again as they are now.
- Ended: days kept → Ended: days kept (refusal): signed, not started: HISTORIAN_MIGRATION_REFUSED. Every kept day is still being written, the disk is too full, or another start, retry or run is in progress. Nothing changes.
- Ended: all imported → End (transition)
POST /api/historian/migration/sign
Section titled “POST /api/historian/migration/sign”{"purpose": "start", "password": "<your password>", "reason": "CSV history import after the upgrade", "hash": "<plan.hash>"}purpose:startorretry.hash: theplan.hashyou were shown (start), or theheld_hash(retry).reason: required, one line, at most 500 characters. Use the same reason in the start or retry request: the ticket is made over the hash and the reason.
The server builds the meaning (start_meaning or retry_meaning, then “; reason: …”). The signer is the caller. The answer is a one-time ticket, valid 60 seconds, bound to the object historian-csv-migration:<node>:start (or :retry), to that hash and reason, and to the decision historian_migrate:
{"ticket": {"ticket": "eso_...", "expires_at": "2026-11-10T16:44:24.70+01:00", "object": "historian-csv-migration:node-scada-4222:start", "hash": "...", "decision": "historian_migrate", "meaning": "Import 5 days of CSV history (...); reason: ..."}}The decision historian_migrate signs these references only, and they are signed with no other decision.
| HTTP | status |
When |
|---|---|---|
200 |
The ticket. | |
400 |
reason_required |
No reason, a reason over 500 characters or of more than one line. |
400 |
purpose is not start or retry, or the body is not JSON. |
|
403 |
signature_refused |
A wrong password, an API token, the AI co-pilot, or no login session. 429 when the account is locked. |
409 |
plan_changed |
The CSV history changed since the plan was shown (the answer holds the new plan): check it and sign again. |
409 |
held_changed |
The days kept for attention changed since they were shown. |
409 |
nothing_to_import, nothing_kept |
No CSV history to import; no day kept for attention (nothing_to_retry before a55d6af). |
503 |
refused, code AUDIT_NOT_WRITTEN |
The signature’s audit record could not be written. Nothing changed. |
POST /api/historian/migration/start
Section titled “POST /api/historian/migration/start”{"plan_hash": "<plan.hash>", "reason": "<the reason signed>", "signature_ticket": "<ticket.ticket>"}- The plan is computed again: it must still have the hash signed (
409 plan_changedotherwise). - The ticket is redeemed for exactly that plan and reason, by the administrator it was issued to.
HISTORIAN_MIGRATION_STARTis written to the audit trail, with the signature, before anything starts. If it cannot be written, nothing starts (503 AUDIT_NOT_WRITTEN).- The import is approved and runs in the background. It resumes after a restart.
Answer: 200 {"status": "running", "result": <the plan approved>}.
- Data store
- File or document
- Check or decision
- Data or telemetry
- Refusal
Read as text
A day folder of CSV history passes four checks in order. Every row of every file is read. The day is written to the columnar store in one transaction, and the rows are read back inside it. After the commit every CSV point is read back from the store once more. Then the files are deleted one by one, each only if it is unchanged. A day that fails any check is kept for attention as CSV.
Parts
- Day folder (file or document): the CSV files of one tag, one day
- Every row read (check or decision): both CSV readers agree?. A row that cannot be read keeps the day. Where the faster CSV reader of the trends can read the folder too, both readers must give the same points.
- One transaction (check or decision): rows read back inside it: as before, plus the import?
- Kept for attention (outcome): the day stays CSV. The files are kept and stay readable on trends. The older days of the same tag folder are kept with it.
- Columnar store (data store): holds the day's points
- After the commit (check or decision): every CSV point read back from the store?
- File by file (check or decision): size and time unchanged?
- Imported and deleted (outcome): the CSV files are gone. A file that cannot be deleted yet leaves the day as imported; the next run checks it again and deletes it.
Connections
- Start → Day folder (next step)
- Day folder → Every row read (next step)
- Every row read → One transaction (next step): yes
- Every row read → Kept for attention (refusal): no. Nothing of the day is imported.
- One transaction → Kept for attention (refusal): no. The transaction is rolled back: nothing of the day is imported.
- One transaction → Columnar store (data or telemetry): commit
- Columnar store → After the commit (data or telemetry): read back
- After the commit → Kept for attention (refusal): no. The imported rows stay in the store; the files are kept.
- After the commit → File by file (next step): yes
- File by file → Kept for attention (refusal): changed. A file whose size or time changed since it was read is kept, and the day with it.
- File by file → Imported and deleted (next step): yes
POST /api/historian/migration/retry
Section titled “POST /api/historian/migration/retry”{"held_hash": "<held_hash>", "reason": "<the reason signed>", "signature_ticket": "<ticket.ticket>"}Under the import’s lock, the days kept for attention, and the older days kept with them, are planned again as they are now:
- a file repaired since the approval is read with its new size and modification time;
- a folder now gone is marked gone (nothing to import or delete);
- a folder the approval left out because it was being written becomes a day to import once it is older than 2 minutes;
- a folder still written in the last 2 minutes stays out, and the older days of its tag stay kept with their reason: retry later.
The disk is checked for the retried bytes. Then HISTORIAN_MIGRATION_RETRY is written to the audit trail, listing each retried day folder with its files (retried: <folder> [data.csv <size> B mtime <ns>, ...]; ...), before anything changes. If it cannot be written, nothing changes (503 AUDIT_NOT_WRITTEN). The state change is one transaction, and the retried days are imported from the start with the same checks.
Answer: 200 {"status": "running", "result": {"days": <days retried>}}.
Refusals of start and retry
Section titled “Refusals of start and retry”| HTTP | status |
When |
|---|---|---|
400 |
reason_required |
No reason, or not one line. |
400 |
signature_required |
No signature_ticket. |
401, 403 |
Not a signed-in administrator, an API token, the AI co-pilot (see above). | |
403 |
signature_refused |
The ticket is unknown, expired, used, made for another plan, set of days or reason, or issued to another user. |
409 |
plan_changed |
The plan (start) or the days kept (retry: held_changed before the ticket is redeemed) changed since they were signed: check them and sign again. |
409 |
busy |
Another start, retry or run is in progress, or an import is already approved (running or paused). Two administrators clicking at once get one import. |
409 |
low_disk |
Free space is under what the import (or the retried days) needs plus historian.disk.critical_free. |
409 |
nothing_to_import, nothing_kept |
Nothing to do: no CSV history to import; no day kept for attention (retry). |
409 |
retry_later |
Retry only: every kept day is still kept, because a folder of its tag was written in the last 2 minutes. Nothing changed; retry later. |
409 |
not_approved |
Retry only: no import was approved. |
503 |
refused, code AUDIT_NOT_WRITTEN |
The audit record could not be written. Nothing changed. |
500 |
failed |
Another error (the message says which). |
Before eaxScada a55d6af, retry_later and not_approved answered 500 failed, and the signing step answered nothing_to_retry where it now answers nothing_kept.
A start or retry refused after its ticket was redeemed is recorded as HISTORIAN_MIGRATION_REFUSED with the error (“the signed start did not start”). A start refused there has its HISTORIAN_MIGRATION_START record before it.
POST /api/historian/migration/pause and /resume
Section titled “POST /api/historian/migration/pause and /resume”No body, no new signature: neither widens what was approved.
- pause: the import pauses after the day in progress. Recorded as
HISTORIAN_MIGRATION_PAUSED. - resume: a paused import runs again. Recorded as
HISTORIAN_MIGRATION_RESUMED. A resume when the import is not paused is refused:409 {"status": "refused"}.
Answer: 200 {"status": "ok"}. When the audit record could not be written, the action is still done and the answer carries a warning.
Audit records
Section titled “Audit records”| Action | Written |
|---|---|
HISTORIAN_MIGRATION_START |
Before a start, with the signature, the meaning and “<reason>; source studio”. |
HISTORIAN_MIGRATION_RETRY |
Before a retry, with the signature and the retried day folders with their files (name, size, modification time). |
HISTORIAN_MIGRATION_REFUSED |
A signed start or retry that did not start, with the error. |
HISTORIAN_MIGRATION_PAUSED, HISTORIAN_MIGRATION_RESUMED |
A pause or a resume from the studio. |
HISTORIAN_MIGRATION_DONE, HISTORIAN_MIGRATION_HELD |
When a run started or resumed by the server ends: DONE when every day is imported and deleted, HELD when days are kept. Once per run end, with the day folders imported and deleted, the rows imported, the points recovered, the conflicts kept, the days kept and the CSV freed, and “source studio; approved by <user>”. A paused run, or one stopped by a shutdown, has not ended: its resume (after a restart too) writes the record when it ends. |
The reference of the studio’s records is historian-csv-migration:<node>:start (or :retry); the run-end records have the target historian-csv-migration. The command line writes HISTORIAN_MIGRATION_DONE or HISTORIAN_MIGRATION_HELD at the end of its own run; see Import the CSV history into the store.
A shutdown during a run finishes the day in progress, then the run stops; it resumes at the next start. (Before a55d6af, a shutdown in the middle of a day rolled the day back and kept it for attention, with the older days of its tag.)