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. 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.

kodexa.data

Requires data:read. Methods that modify data also require data:write.

kodexa.navigation

Requires navigation. Spatial-viewer methods route to the document viewer for the form’s first document family by default; pass an explicit documentFamilyId when a form is bound to more than one document. Note that focusAttribute takes dataObjectUuid as the first parameter and attributePath as the second. rotatePage behaves differently from the absolute setPage:
  • Rotation is relative. Each call rotates by ±90° from the page’s current rotation — it is not an absolute angle. Calling rotatePage("right") twice leaves the page at 180°; a following rotatePage("left") returns it to 90°.
  • It affects only the current page. Rotating every page of the document remains a separate viewer menu action; the bridge method touches just the page the viewer is currently showing.
  • It requires the navigation permission and accepts an optional documentFamilyId to target a specific open document when the form is bound to more than one. A per-document rotation does not bleed across documents.
An invalid direction (anything other than "left" or "right") or a missing viewer is a no-op — a warning is logged to the browser console and no error is thrown.
These rotate actions are typically wired to keyboard shortcuts rather than called directly. The alt+R / alt+shift+R bindings are not hard-coded — they are authored declaratively as form shortcuts entries whose script calls kodexa.navigation.rotatePage(...):
The rotate-page-right script calls kodexa.navigation.rotatePage("right") and rotate-page-left calls kodexa.navigation.rotatePage("left"), so a shortcuts: block round-trips through the data form schema.

kodexa.viewer

Requires viewer. The viewer surface manipulates the spatial document viewport — its scroll and pan position, its zoom level, and whether the viewer is docked in the workspace or popped out into its own browser tab — rather than the page state. That separation is why it is a distinct permission from navigation.
  • scroll direction is one of "up", "down", "left", "right". Any other value is a no-op — a warning is logged to the browser console and no error is thrown. "up" / "down" scroll the viewer vertically; "left" / "right" pan the zoom transform (the spatial image is CSS-transformed, so left/right movement pans rather than scrolls). Both feel like a small “arrow key” nudge, not a full-screen jump.
  • zoom steps one increment in or out. "in" and "out" map to the toolbar’s zoom-in / zoom-out buttons — one call is one step. Any other value is a no-op with a browser-console warning and no error thrown.
  • detach pops the viewer out into a new browser tab. This is the same action as the viewer’s “Open in new tab” button. It is only meaningful from the main window — calling it from inside the popped-out tab is a no-op (a warning is logged). If the pop-out tab is already open, detach focuses that tab rather than opening a second one. It takes no arguments.
  • dock returns a popped-out viewer to the workspace. This mirrors the viewer’s “Dock back to workspace” button and works from either the main window or the popped-out tab. When no viewer is currently detached it is a no-op with a warning. It takes no arguments.
  • scroll and zoom can target one document. With no argument they act on the form’s default (first) document family; pass an optional documentFamilyId to target a specific open document. Both apply to the viewer whether it is docked or popped out. detach and dock always act on the workspace’s pop-out viewer and take no target.
  • Requires the viewer permission. Calling any kodexa.viewer method without "viewer" in bridge.permissions throws a Permission denied: viewer error.
Like the rest of the Bridge API, these actions are usually wired to keyboard shortcuts rather than called directly. Bindings are authored declaratively as form shortcuts entries (see Keyboard Shortcuts); zoom, detach, and dock fit the "zoom" help-dialog group. The keys below are only examples chosen by the form author — there are no fixed hotkeys for these actions:
Each scriptRef points at a script that calls the matching method — for example detach-viewer calls kodexa.viewer.detach() and dock-viewer calls kodexa.viewer.dock().

kodexa.form

Requires formState. 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.

kodexa.document

Requires document:read. The writable snapshot also requires data:write. 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. Requests are sent to apiBaseUrl + path. The base URL defaults to "/api" if not configured.

kodexa.serviceBridge

Requires http:post. Service bridges are named proxy endpoints that connect the platform to external APIs with centralized authentication. The ref is the bridge slug (e.g., "acme-logistics/carrier-lookup"), 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).

kodexa.log

No permission required. 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

ServiceBridgeResponseMapping

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.
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.

v2:serviceBridgeView

A container component that calls a service bridge endpoint and makes the response available to its children through the data context. Unlike the panel serviceBridge prop (which maps responses back to attributes), v2:serviceBridgeView is designed for read-only display — rendering bridge responses as tables, markdown, labels, or any combination of child components.

How It Works

  1. The component resolves the bridge slug to an ID via the platform’s /api/resolve endpoint.
  2. It POSTs the params to the bridge proxy endpoint (/api/service-bridges/{id}/proxy/{endpoint}).
  3. If a transform expression is provided, the response is reshaped using JSONata.
  4. The result is injected into a scoped DataContextV2 as ctx.$bridgeResult, along with ctx.$bridgeLoading and ctx.$bridgeError.
  5. Children render using bindings that reference these context variables.
The component handles loading and error states automatically — children are only rendered once data is available.

Props

Context Variables

Children of v2:serviceBridgeView receive these additional context variables: All existing context variables (ctx.dataObjects, ctx.tagMetadataMap, etc.) remain available — the bridge context is additive.

Reactive Parameters

When params is provided via bindings, the component re-calls the bridge whenever the bound values change. This creates a reactive chain: the user edits an attribute, the binding expression re-evaluates, new params are sent to the bridge, and children re-render with fresh data.
When referencing attributes in binding expressions, the tag property is the leaf name (e.g., originZip), not the full taxonomy path (shipment/originZip). The full path is available as path on the attribute. Use a.tag === 'originZip' or a.path === 'shipment/originZip' depending on which you need.

Example: Table from Bridge Response

Call a rate lookup endpoint, transform the response with JSONata, and render the results as a filterable AG Grid table:

Example: Markdown Summary

Fetch a report from a bridge and render it as markdown:

Example: Mixed Content

Combine multiple child components to render different parts of the bridge response:

JSONata Transform Reference

The transform prop accepts any valid JSONata expression. Common patterns: If the transform is omitted, the raw response is passed through as ctx.$bridgeResult.
The JSONata transform runs client-side after the response is received. For large responses, consider using the bridge’s postReplyScript to filter server-side before the data reaches the browser.

Comparison: Panel serviceBridge vs serviceBridgeView