Documentation menu

API & CLI Reference

TwinControl exposes full API-to-UI parity across REST JSON endpoints, live WebSocket telemetry streams (twinctl.telemetry.v1), the TwinScript automation SDK, and the twinctl command-line interface. Every state-mutating request enforces role-based entitlements and fail-closed guardrail policies.

Authentication, conventions, and CLI overview

Authenticate REST and WebSocket requests using a bearer token or mutual TLS client certificate. Long-running operations (full-facility electrical studies, COBie 2.4 exports, and compliance dossiers) return HTTP 202 Accepted with a job resource identifier for polling or webhook delivery.

curl -sS https://studio.facility.example/api/v1/projects \
  -H "Authorization: Bearer $TWINCTL_TOKEN" \
  -H "Accept: application/json"
CLI commandScope
twinctl project / twinctl packOpen, branch, and export .twinproj workspaces; install, activate, and roll back signed .twinpack bundles.
twinctl design / twinctl interopRun design rule checks, export quantities, and import/export schematic and catalogue interchange files.
twinctl control / twinctl runtimeCompile IEC 61131-3 logic, inspect vPLC process images, run time-warped simulations, and manage Slot A/B deployments.
twinctl operate / twinctl connectManage protocol adapters, attach canary shadow drivers, browse tags, validate connectivity bundles, and capture .pcapng diagnostics.
twinctl commission / twinctl maintainGenerate and run L1–L5 IST suites, rehearse N-1 outages, apply digital LOTO locks, and export CMMS assets.
twinctl apply / twinctl checkCommit approved guardrail plans, validate facility specifications strictly, and verify audit chains.

Projects & Packs

Manage versioned .twinproj repositories and cryptographically signed .twinpack domain bundles. Equivalent CLI commands: twinctl project and twinctl pack.

GET/api/v1/projects/{id}/packsBearer token

List active Domain Pack roots, pinned packs, and item pins for a facility project

ParameterInTypeDescription
id *pathstringUnique facility project identifier.

Response

{
  "projectId": "dc-east-01",
  "packRoots": ["com.twinctl.pack.datacentre"],
  "pinnedPacks": {
    "com.twinctl.pack.datacentre": "2.4.0"
  },
  "pins": []
}
POST/api/v1/projects/{id}/packs/applyBearer token

Activate or deactivate signed .twinpack bundles on a governed project, returning updated project settings

ParameterInTypeDescription
id *pathstringUnique facility project identifier.
activatebodystring[]Pack root identifiers to activate on the project.
deactivatebodystring[]Pack root identifiers to deactivate on the project.

Request body

{
  "activate": ["com.twinctl.pack.nuclear-pwr"],
  "deactivate": []
}

Response

{
  "projectId": "dc-east-01",
  "name": "DC East 01",
  "tenantId": "default",
  "pinnedPacks": {
    "com.twinctl.pack.datacentre": "2.4.0",
    "com.twinctl.pack.nuclear-pwr": "1.3.0"
  },
  "packRoots": ["com.twinctl.pack.datacentre", "com.twinctl.pack.nuclear-pwr"],
  "sodFourEyesRequired": true,
  "vocabularyOverrides": {},
  "unitSystem": "SI",
  "frequencyHz": 50,
  "revision": 2,
  "updatedAtUtc": "2026-01-15T09:30:00Z"
}

Design & Studies

Query live engineering quantities, property updates, and asynchronous short-circuit, arc-flash, and thermal studies. Equivalent CLI commands: twinctl design and twinctl interop.

GET/api/projects/{project_id}/design-quantitiesBearer token

Retrieve derived device counts, scaled page graphics, and source provenance standing for the project design model

ParameterInTypeDescription
project_id *pathstringUnique facility project identifier.

Response

{
  "state": "current",
  "message": null,
  "derivations": [
    {
      "path": "design/model.json",
      "derived_sha256": "e3b0c44298fc1c14...",
      "current_sha256": "e3b0c44298fc1c14...",
      "standing": "current"
    }
  ],
  "quantities": {
    "devices": [
      { "component_type": "mv_switchgear", "count": 2 },
      { "component_type": "liquid_cdu", "count": 12 }
    ],
    "pages": [],
    "missing": []
  }
}
POST/api/v1/projects/repositories/{id}/design/studies/short-circuitBearer token

Execute an IEC 60909 short-circuit study and breaker duty check on a repository design model

ParameterInTypeDescription
id *pathstringProject repository identifier.
fault_duration_s *bodynumberFault clearing duration in seconds for thermal current Ith calculation.
voltage_tolerance_pctbodynumberOptional voltage tolerance up to 1 kV in percent (IEC 60909-0 Table 1).
min_time_delay_sbodynumberOptional minimum breaking delay t_min in seconds for generator and motor decay.
breaker_ratings *bodyarrayDeclared breaking_ka and making_ka ratings per breaker_id.

Request body

{
  "fault_duration_s": 0.5,
  "voltage_tolerance_pct": 10.0,
  "breaker_ratings": [
    { "breaker_id": "cb-mv-01", "breaking_ka": 40.0, "making_ka": 100.0 }
  ]
}

Response

{
  "buses": {
    "bus-mv-01": {
      "voltage_factor_c": 1.1,
      "ik3_double_prime_ka": 24.8,
      "ik2_double_prime_ka": 21.5,
      "ip3_peak_ka": 61.2,
      "ib_breaking_ka": 23.4,
      "ith_thermal_ka": 24.1,
      "kappa": 1.75,
      "thevenin_z_ohm": 0.465,
      "contributions": []
    }
  },
  "breakers": [
    {
      "breaker_id": "cb-mv-01",
      "bus_id": "bus-mv-01",
      "breaking": {
        "rating": "icu",
        "rated_ka": 40.0,
        "demand_ka": 23.4,
        "margin_pct": 41.5,
        "exceeded": false,
        "marginal": false
      },
      "making": {
        "rating": "icm",
        "rated_ka": 100.0,
        "demand_ka": 61.2,
        "margin_pct": 38.8,
        "exceeded": false,
        "marginal": false
      }
    }
  ],
  "unrated_breakers": [],
  "unconnected_generators": [],
  "table_verification": {},
  "violations_count": 0,
  "method": {
    "standard": "IEC 60909-0",
    "k_t_applied": false,
    "limitations": []
  }
}

TwinCode & vPLC

Transpile IEC 61131-3 logic across licensed dialects, control virtual PLC instances, and step deterministic debug sessions. Equivalent CLI command: twinctl control (alias twinctl vplc).

POST/api/v1/twincode/transpileBearer token

Transpile IEC 61131-3 logic from a licensed source pack to a target pack with equivalence proof

ParameterInTypeDescription
source_pack_id *bodystringLicensed source PLC pack slug or ID (for example rockwell-logix, codesys-iec, siemens-tia).
target_pack_id *bodystringLicensed target PLC pack slug or ID (for example siemens-tia, codesys-iec, rockwell-logix).
source *bodystringStructured Text or native vendor source payload.
run_equivalence_proofbodybooleanRun symbolic and scan-trace equivalence verification.

Request body

{
  "source_pack_id": "rockwell-logix",
  "target_pack_id": "siemens-tia",
  "source": "FUNCTION_BLOCK FB_CDU_LeadLag ... END_FUNCTION_BLOCK",
  "run_equivalence_proof": true
}

Response

{
  "source_pack_id": "com.twinctl.plc.rockwell-logix",
  "target_pack_id": "com.twinctl.plc.siemens-tia",
  "target_language_id": "siemens-scl",
  "target_filename": "FB_CDU_LeadLag.xml",
  "equivalence": {
    "verified": true,
    "method": "plc-equiv-tier2-roundtrip",
    "mismatches": []
  }
}
POST/api/v1/ide/dap/deployBearer token

Compile and stage IEC 61131-3 logic onto a vPLC Slot A/B runtime or deploy a declarative TwinSpec simulation node

ParameterInTypeDescription
kind *body"vplc" | "twinspec"Target deployment kind: "vplc" (compiled PLC program) or "twinspec" (declarative simulation node).
node_id *bodystringTarget vPLC or simulation node identifier.
pack_slugbodystringOptional PLC dialect pack slug (for example codesys-iec, rockwell-logix, siemens-tia).
source *bodystringIEC 61131-3 control program or TwinSpec (.twinspec) source text.

Request body

{
  "kind": "vplc",
  "node_id": "vplc-chiller-plant-01",
  "pack_slug": "codesys-iec",
  "source": "FUNCTION_BLOCK FB_ChillerValveLoop ... END_FUNCTION_BLOCK"
}

Response

{
  "node_id": "vplc-chiller-plant-01",
  "kind": "vplc",
  "ir_digest": "sha256:9c4a...18f2",
  "status": "deployed",
  "pack_id": "com.twinctl.plc.codesys-iec",
  "module_name": "FB_ChillerValveLoop",
  "tag_count": 5,
  "rung_count": 3,
  "debug_endpoints": ["/api/v1/ide/dap/step", "/api/v1/ide/dap/inspect"]
}
POST/api/v1/vplc/debug/stepBearer token

Advance a paused vPLC or lockstep barrier group by a deterministic number of scans

ParameterInTypeDescription
instanceIdbodystringActive vPLC debug instance identifier (defaults to "vplc-local-0").
stepsbodyintegerNumber of deterministic scans or lines to advance (default 1).
actionbodystringOptional stepping action: Continue, Pause, StepLine, or StepScan.

Request body

{
  "instanceId": "vplc-local-0",
  "steps": 10,
  "action": "StepScan"
}

Response

{
  "instanceId": "vplc-local-0",
  "cycleCount": 14820,
  "paused": true,
  "debugState": "Paused",
  "hitBreakpoints": [],
  "callStack": [],
  "watch": [],
  "inlineValues": {}
}

TwinScript & Scenarios

Analyse TwinScript (.tws) files with static UCUM and capability checking, or execute deterministic 100x+ stepped virtual facility scenarios. Equivalent CLI commands: twinctl control and twinctl check.

script GuardedSetpointAdjust {
    requires capability::ReadTelemetry;
    requires capability::ShadowSimulate;
    requires capability::ProposeWrite(scope: "chiller-01.*");

    on change(twin::point<"chiller-01.supply_temp">) every >= 200ms (fuel: 150) {
        let temp = twin::point<"chiller-01.supply_temp">.read();
        if temp > 9.5 degC {
            let plan = guardrail::plan_mutation("chiller-01.setpoint", 7.5 degC, "trim");
            if twin::shadow_qualify(plan, 60s) {
                guardrail::apply(plan);
            }
        }
    }
}
POST/api/v1/twincode/lsp/analyzeBearer token

Analyse TwinScript (.tws) or IEC 61131-3 source for syntax, TWS001–TWS005 diagnostics, UCUM units, and capability scopes

ParameterInTypeDescription
language_id *bodystringLanguage identifier ("twinscript" or IEC 61131-3 dialect).
uri *bodystringDocument URI (for example "twin://scripts/trim.tws").
source *bodystringTwinScript (.tws) source text.
known_symbolsbodyobjectOptional known facility symbols object (point_keys, protocol_slugs, overlay_ids, device_skus, vplc_symbols, extra_symbols).

Request body

{
  "language_id": "twinscript",
  "uri": "twin://scripts/trim.tws",
  "source": "script Trim { requires capability::ReadTelemetry; ... }",
  "known_symbols": {}
}

Response

{
  "kind": "twinscript",
  "uri": "twin://scripts/trim.tws",
  "pack_id": "com.twinctl.twinscript",
  "language_id": "twinscript",
  "diagnostics": [],
  "symbols": [],
  "completions": []
}

Connectivity & Telemetry

Browse live facility points, manage symmetric protocol adapters, attach canary shadow drivers, and stream live telemetry updates. Equivalent CLI commands: twinctl telemetry, twinctl operate, and twinctl connect.

GET/api/v1/telemetryBearer token

Read current telemetry node values, status provenance, and setpoint bounds

ParameterInTypeDescription
pointquerystringOptional case-insensitive substring filter matched against node id or name.
project_idquerystringOptional facility project identifier scope (also accepts facility_id).

Response

[
  {
    "id": "cdu-01.supply_temp",
    "name": "CDU-01 Supply Temp",
    "type": "sensor",
    "domain": "datacentre",
    "status": "normal",
    "statusSource": "live_readings",
    "load": null,
    "temp": 26.4,
    "flow": 18.2,
    "powerKw": null,
    "setpoint": 26.0,
    "setpointUnit": "degC",
    "protocol": "modbus"
  }
]
GET/ws/telemetrySec-WebSocket-Protocol: twinctl.telemetry.v1, bearer.<token>

WebSocket endpoint streaming tagged JSON event frames (Telemetry, SafetyUpdate, MeasuredMetrics, TwinSnapshot, TransactionJournal)

Response

{
  "type": "Telemetry",
  "nodes": [
    {
      "id": "cdu-01.supply_temp",
      "name": "CDU-01 Supply Temp",
      "type": "sensor",
      "domain": "datacentre",
      "status": "normal",
      "statusSource": "live_readings",
      "temp": 26.4
    }
  ]
}

Guardrailed Operations (plan / apply)

Stage plant mutations, enforce digital LOTO write-inhibits, and commit hardware writes only after shadow-plant verification and required four-eyes approvals. Equivalent CLI commands: twinctl apply, twinctl maintain, and twinctl commission.

POST/api/v1/plansBearer token · Clearance 3

Create and shadow-qualify a fail-closed guardrail mutation plan without mutating hardware

ParameterInTypeDescription
targetPoint *bodystringTarget point key to adjust.
value *bodynumberProposed engineering setpoint value.
reasonbodystringAuditable operational justification.

Request body

{
  "targetPoint": "cdu-01.valve_setpoint",
  "value": 30.0,
  "reason": "AI step-load pre-cooling trim"
}

Response

{
  "planId": "plan-88412",
  "targetPoint": "cdu-01.valve_setpoint",
  "proposedValue": 30.0,
  "interlocksPassed": true,
  "allowed": true,
  "requiresSecondApproval": true
}
POST/api/v1/plans/{id}/applyBearer token · Clearance 3 + PE sign-off

Commit a PE-approved, shadow-qualified plan across a single-scan Slot A/B barrier with read-back verification

ParameterInTypeDescription
id *pathstringQualified guardrail plan identifier.

Response

{
  "planId": "plan-88412",
  "outcomeStatus": "Applied",
  "verifiedReadback": true,
  "auditSeq": 1482,
  "auditRecorded": true,
  "message": "Committed and read back from the device"
}

Compliance Dossiers

Export sealed commissioning handover packs, COBie 2.4 deliverables, and EU CRA / NIS2 / IEC 62443 / NERC CIP audit chains. Equivalent CLI commands: twinctl commission and twinctl check.

GET/api/v1/audit/chainBearer token · Installation Admin

Query paginated SHA-256 and Ed25519-sealed audit chain entries with live full-chain verification

ParameterInTypeDescription
targetquerystringOptional target prefix filter (for example point:cdu-01).
actorquerystringOptional exact actor username filter.
kindquerystringOptional action prefix filter (guardrail, safety, auth, licence, corpus).
fromquerystringOptional inclusive RFC 3339 start timestamp.
toquerystringOptional inclusive RFC 3339 end timestamp.
beforequeryintegerSequence cursor for fetching older entries.
limitqueryintegerPage size (default 100, maximum 1000).

Response

{
  "verification": {
    "entries": 1482,
    "headHash": "4b21...90cd",
    "brokenAt": null,
    "reason": null,
    "authenticity": "localSigner",
    "expectedSealed": true
  },
  "entries": [
    {
      "seq": 1481,
      "at": 1768469400,
      "prevHash": "8e10...4f12",
      "hash": "4b21...90cd",
      "actor": "pe-lead@facility.example",
      "action": "guardrail.applied",
      "target": "point:cdu-01:valve_setpoint",
      "detail": "{}"
    }
  ],
  "nextBefore": 1481
}