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"const ws = new WebSocket(
'wss://studio.facility.example/ws/telemetry',
['twinctl.telemetry.v1', `bearer.${TWINCTL_TOKEN}`],
);
ws.addEventListener('message', (event) => {
const msg = JSON.parse(event.data);
if (msg.type === 'Telemetry') {
for (const node of msg.nodes) {
console.log(node.id, node.status, node.temp, node.powerKw);
}
}
});# Inspect platform health and active protocol engines
twinctl status --api-url https://studio.facility.example
# Check facility specifications and pack integrity in CI
twinctl check --config ./facility.toml --strict| CLI command | Scope |
|---|---|
twinctl project / twinctl pack | Open, branch, and export .twinproj workspaces; install, activate, and roll back signed .twinpack bundles. |
twinctl design / twinctl interop | Run design rule checks, export quantities, and import/export schematic and catalogue interchange files. |
twinctl control / twinctl runtime | Compile IEC 61131-3 logic, inspect vPLC process images, run time-warped simulations, and manage Slot A/B deployments. |
twinctl operate / twinctl connect | Manage protocol adapters, attach canary shadow drivers, browse tags, validate connectivity bundles, and capture .pcapng diagnostics. |
twinctl commission / twinctl maintain | Generate and run L1–L5 IST suites, rehearse N-1 outages, apply digital LOTO locks, and export CMMS assets. |
twinctl apply / twinctl check | Commit 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.
/api/v1/projects/{id}/packsBearer tokenList active Domain Pack roots, pinned packs, and item pins for a facility project
| Parameter | In | Type | Description |
|---|---|---|---|
id * | path | string | Unique facility project identifier. |
Response
{
"projectId": "dc-east-01",
"packRoots": ["com.twinctl.pack.datacentre"],
"pinnedPacks": {
"com.twinctl.pack.datacentre": "2.4.0"
},
"pins": []
}/api/v1/projects/{id}/packs/applyBearer tokenActivate or deactivate signed .twinpack bundles on a governed project, returning updated project settings
| Parameter | In | Type | Description |
|---|---|---|---|
id * | path | string | Unique facility project identifier. |
activate | body | string[] | Pack root identifiers to activate on the project. |
deactivate | body | string[] | 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.
/api/projects/{project_id}/design-quantitiesBearer tokenRetrieve derived device counts, scaled page graphics, and source provenance standing for the project design model
| Parameter | In | Type | Description |
|---|---|---|---|
project_id * | path | string | Unique 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": []
}
}/api/v1/projects/repositories/{id}/design/studies/short-circuitBearer tokenExecute an IEC 60909 short-circuit study and breaker duty check on a repository design model
| Parameter | In | Type | Description |
|---|---|---|---|
id * | path | string | Project repository identifier. |
fault_duration_s * | body | number | Fault clearing duration in seconds for thermal current Ith calculation. |
voltage_tolerance_pct | body | number | Optional voltage tolerance up to 1 kV in percent (IEC 60909-0 Table 1). |
min_time_delay_s | body | number | Optional minimum breaking delay t_min in seconds for generator and motor decay. |
breaker_ratings * | body | array | Declared 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).
/api/v1/twincode/transpileBearer tokenTranspile IEC 61131-3 logic from a licensed source pack to a target pack with equivalence proof
| Parameter | In | Type | Description |
|---|---|---|---|
source_pack_id * | body | string | Licensed source PLC pack slug or ID (for example rockwell-logix, codesys-iec, siemens-tia). |
target_pack_id * | body | string | Licensed target PLC pack slug or ID (for example siemens-tia, codesys-iec, rockwell-logix). |
source * | body | string | Structured Text or native vendor source payload. |
run_equivalence_proof | body | boolean | Run 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": []
}
}/api/v1/ide/dap/deployBearer tokenCompile and stage IEC 61131-3 logic onto a vPLC Slot A/B runtime or deploy a declarative TwinSpec simulation node
| Parameter | In | Type | Description |
|---|---|---|---|
kind * | body | "vplc" | "twinspec" | Target deployment kind: "vplc" (compiled PLC program) or "twinspec" (declarative simulation node). |
node_id * | body | string | Target vPLC or simulation node identifier. |
pack_slug | body | string | Optional PLC dialect pack slug (for example codesys-iec, rockwell-logix, siemens-tia). |
source * | body | string | IEC 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"]
}/api/v1/vplc/debug/stepBearer tokenAdvance a paused vPLC or lockstep barrier group by a deterministic number of scans
| Parameter | In | Type | Description |
|---|---|---|---|
instanceId | body | string | Active vPLC debug instance identifier (defaults to "vplc-local-0"). |
steps | body | integer | Number of deterministic scans or lines to advance (default 1). |
action | body | string | Optional 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);
}
}
}
}# Run a time-warped fault scenario on a live twin fork
twinctl control warp-sim --seconds 600 --open-breaker mvb-01 --json
# Stage and commit a guarded mutation plan
twinctl apply --plan-id plan-88412 --actor operator@facility.example/api/v1/twincode/lsp/analyzeBearer tokenAnalyse TwinScript (.tws) or IEC 61131-3 source for syntax, TWS001–TWS005 diagnostics, UCUM units, and capability scopes
| Parameter | In | Type | Description |
|---|---|---|---|
language_id * | body | string | Language identifier ("twinscript" or IEC 61131-3 dialect). |
uri * | body | string | Document URI (for example "twin://scripts/trim.tws"). |
source * | body | string | TwinScript (.tws) source text. |
known_symbols | body | object | Optional 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.
/api/v1/telemetryBearer tokenRead current telemetry node values, status provenance, and setpoint bounds
| Parameter | In | Type | Description |
|---|---|---|---|
point | query | string | Optional case-insensitive substring filter matched against node id or name. |
project_id | query | string | Optional 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"
}
]/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.
/api/v1/plansBearer token · Clearance 3Create and shadow-qualify a fail-closed guardrail mutation plan without mutating hardware
| Parameter | In | Type | Description |
|---|---|---|---|
targetPoint * | body | string | Target point key to adjust. |
value * | body | number | Proposed engineering setpoint value. |
reason | body | string | Auditable 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
}/api/v1/plans/{id}/applyBearer token · Clearance 3 + PE sign-offCommit a PE-approved, shadow-qualified plan across a single-scan Slot A/B barrier with read-back verification
| Parameter | In | Type | Description |
|---|---|---|---|
id * | path | string | Qualified 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.
/api/v1/audit/chainBearer token · Installation AdminQuery paginated SHA-256 and Ed25519-sealed audit chain entries with live full-chain verification
| Parameter | In | Type | Description |
|---|---|---|---|
target | query | string | Optional target prefix filter (for example point:cdu-01). |
actor | query | string | Optional exact actor username filter. |
kind | query | string | Optional action prefix filter (guardrail, safety, auth, licence, corpus). |
from | query | string | Optional inclusive RFC 3339 start timestamp. |
to | query | string | Optional inclusive RFC 3339 end timestamp. |
before | query | integer | Sequence cursor for fetching older entries. |
limit | query | integer | Page 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
}