Skip to main content
The Bridge API is the interface between scripts running in the QuickJS sandbox and the Kodexa platform. Scripts access it through the kodexa.* namespace, where each sub-namespace corresponds to a capability gated by the form’s bridge permissions.

Bridge Permissions

The bridge property on a data form configures what scripts are allowed to do. The permissions array lists capability gates — a script that attempts to call a method without the required permission will receive a Permission denied error.
PermissionGrants access to
data:readRead data objects, attributes, tag metadata, taxonomies
data:writeModify data objects and attributes
document:readAccess the document proxy (kodexa.document)
navigationFocus attributes, scroll to nodes, switch views
formStateGet and set form state values, access node refs
http:getHTTP GET requests via kodexa.http
http:postHTTP POST requests via kodexa.http and service bridge calls
Additional bridge configuration:
  • apiBaseUrl — Base URL for kodexa.http and kodexa.serviceBridge calls. Defaults to "/api".
  • maxExecutionMs — Script execution timeout in milliseconds. Defaults to 1000.
{
  "bridge": {
    "permissions": ["data:read", "data:write", "navigation", "http:post"],
    "apiBaseUrl": "https://api.example.com",
    "maxExecutionMs": 2000
  }
}

kodexa.data

Requires data:read. Methods that modify data also require data:write.
MethodParametersReturnsPermission
getDataObjects(filter?){ path?: string, parentId?: string }DataObject[]data:read
getDataObject(uuid)uuid: stringDataObject | nulldata:read
getAttributes(dataObjectUuid)dataObjectUuid: stringAttribute[]data:read
getAttribute(dataObjectUuid, path)dataObjectUuid: string, path: stringanydata:read
setAttribute(dataObjectUuid, path, value)dataObjectUuid: string, path: string, value: anyvoiddata:write
addDataObject(parentUuid, path)parentUuid: string, path: stringDataObjectdata:write
deleteDataObject(uuid)uuid: stringvoiddata:write
getTagMetadata(path)path: stringTagMetadata | nulldata:read
getTaxonomies()Taxonomy[]data:read
// Read all line items under a parent object
const items = kodexa.data.getDataObjects({ parentId: parentUuid });
for (const item of items) {
  const amount = kodexa.data.getAttribute(item.uuid, "LineItem/Amount");
  kodexa.log.debug("Amount: " + amount);
}

// Set a computed total
kodexa.data.setAttribute(summaryUuid, "Invoice/Total", calculatedTotal);

kodexa.navigation

Requires navigation.
MethodParametersDescription
focusAttribute(dataObjectUuid, attributePath)dataObjectUuid: string, attributePath: stringHighlight an attribute in the document viewer
scrollToNode(ref)ref: stringScroll the document viewer to a content node
switchView(viewName)viewName: stringSwitch to a different form view
Note that focusAttribute takes dataObjectUuid as the first parameter and attributePath as the second.

kodexa.form

Requires formState.
MethodParametersReturnsDescription
get(key)key: stringanyRead a form state value
set(key, value)key: string, value: anyvoidWrite a form state value
getNodeRef(ref)ref: string{ setProps(props) }Get a UINode by ref for dynamic prop updates
Form state is ephemeral — it persists for the lifetime of the form session but is not saved to the server. Use it for UI-only concerns like toggling visibility, tracking selection state, or passing values between scripts.
// Toggle a detail panel
const expanded = kodexa.form.get("detailExpanded") || false;
kodexa.form.set("detailExpanded", !expanded);

// Dynamically update a node's props
const node = kodexa.form.getNodeRef("statusLabel");
node.setProps({ text: "Validated", variant: "success" });

kodexa.document

Requires document:read. The writable snapshot also requires data:write.
MethodReturnsDescription
snapshot()ScriptDocumentProxyRead-only proxy over the current document data
writableSnapshot()ScriptDocumentProxyWritable proxy — mutations flow through the workspace store
The ScriptDocumentProxy exposes getAllDataObjects(), getDataObjectByUUID(uuid), and getDataObjectsByPath(path). Each returns ScriptDataObjectProxy instances with methods like getAttributes(), getAttribute(label), getChildren(), and getPath(). Writable proxies additionally support addAttribute(), addChild(), and setValue() on attributes. This API is separate from loadDocument() available in inline or named scripts. kodexa.document provides Bridge API context tied to the current workspace session; loadDocument() is for standalone script execution.

kodexa.http

Requires http:get for GET requests, http:post for POST requests. Both are async.
MethodParametersReturns
get(path)path: stringPromise<any>
post(path, body?)path: string, body?: anyPromise<any>
Requests are sent to apiBaseUrl + path. The base URL defaults to "/api" if not configured.
// Call an external validation endpoint
const result = await kodexa.http.post("/validate", {
  invoiceNumber: invoiceNum,
  vendorId: vendorId
});

if (!result.valid) {
  kodexa.log.warn("Validation failed: " + result.reason);
}

kodexa.serviceBridge

Requires http:post.
MethodParametersReturns
call(ref, endpoint, body?)ref: string, endpoint: string, body?: anyPromise<any>
Service bridges are named proxy endpoints that connect the platform to external APIs with centralized authentication. The ref is the bridge slug (e.g., "cass-freight/data-entry-automation"), and endpoint is the endpoint name defined in the bridge YAML. The bridge manages an X-Bridge-Context header for session caching. On the first call, no context header is sent; the server runs any configured initScript and returns context in the response header. Subsequent calls attach the cached context, skipping re-initialization. Context expires after a configurable TTL (default 3600 seconds).
const carriers = await kodexa.serviceBridge.call(
  "cass-freight/data-entry-automation",
  "lookup-carrier",
  { scac: scacCode }
);

kodexa.log

No permission required.
MethodParameters
debug(message)message: string
warn(message)message: string
error(message)message: string
All log output is prefixed with [DataFormV2] and routed to the browser console.

Service Bridges on Panels

In addition to imperative kodexa.serviceBridge.call() from scripts, panels support declarative service bridge integration through the serviceBridge prop on v2:panel. This allows a component to declare an external API dependency without writing script code.

ServiceBridgeConfig

PropertyTypeDescription
refstringBridge reference (e.g., "cass-freight/data-entry-automation")
endpointstringEndpoint name from the bridge YAML
method"GET" | "POST"HTTP method, defaults to POST
requestMappingRecord<string, string>Maps data attribute paths to request fields
responseMappingServiceBridgeResponseMappingControls how the response maps back to UI or data
triggerOnstring[]Attribute paths that trigger a re-call when values change

ServiceBridgeResponseMapping

PropertyTypeDescription
valuestringPath to extract option value from each response item
labelstringPath or expression for the option label (supports concatenation like "code + ' - ' + description")
descriptionstringPath or expression for hint text shown below the label in dropdowns
autoSelectstringAuto-select a single best-match field from the response
attributesArray<{ from, to }>Map response fields to data attributes (from: response path, to: attribute path)

How It Works

When any attribute listed in triggerOn changes, the panel reads the current values from requestMapping, calls the service bridge endpoint, and maps the response back using responseMapping. This creates a reactive loop: user edits a field, the bridge fetches updated data, and dependent fields populate automatically.
{
  "component": "v2:panel",
  "props": {
    "title": "Carrier Details",
    "serviceBridge": {
      "ref": "cass-freight/data-entry-automation",
      "endpoint": "lookup-carrier",
      "requestMapping": {
        "scac": "Shipment/CarrierSCAC"
      },
      "responseMapping": {
        "value": "carrierId",
        "label": "scac + ' - ' + carrierName",
        "attributes": [
          { "from": "carrierName", "to": "Shipment/CarrierName" },
          { "from": "dotNumber", "to": "Shipment/DOTNumber" }
        ]
      },
      "triggerOn": ["Shipment/CarrierSCAC"]
    }
  }
}
In this example, when the user enters a SCAC code, the panel calls the carrier lookup endpoint and auto-populates the carrier name and DOT number fields from the response.