Skip to main content
Version: v1 (Current)

Trigger State API

Every project page, form and portal widget has a trigger_state: a JSON object of runtime state that the platform broadcasts when it changes. A page's or form's state is also sent to the app rendered on it, as the store's triggerState. The Trigger State API lets an app page read and change that state on the server, so every client sees the change. Writing store.triggerState[key] in the browser only changes that browser and is gone on reload.

An app can reach its own page or form, and pages, forms and portal widgets bound to it. A portal widget's state can therefore serve as state shared by several apps.

This guide was reviewed against platform source at 208d36e1b5 on 2026-11-05. The bundled REST API reference includes a source-reviewed supplement for these endpoints; it is not a deployed-server capability check. Confirm the deployed platform includes them before relying on them.

Endpoints​

MethodPathAbility
GET/api/v1/projects/{team}/{project}/trigger-state/{target}None for the app's own state; view_trigger_state for other targets
PATCH/api/v1/projects/{team}/{project}/trigger-state/{target}update_own_trigger_state for the app's own state; update_trigger_state for other targets

Requests need the app page's context, which the store sends with every request. A request without it gets 404.

TargetMeaning
selfThe page or form the app is rendered on
page:{id}A project page, by numeric ID
form:{slug} or form:{id}A project form, by slug or numeric ID (an all-digit reference is read as an ID)
widget:{id}A portal widget, by numeric ID

page:{id} or form:... naming the app's own page or form is treated the same as self.

Both methods return the target and its state as this app may see it:

{
"target": "page:812",
"state": { "slide": 3, "overlay": { "color": "red" } },
"updated_at": "2026-10-28T15:00:00.000000Z"
}

target names a form by its slug. For the app's own target, state is the whole state, except on a form, where the keys hidden from attendees are removed: those in the form's ignore_keys, or on a quiz without its own list, the live quiz defaults. For any other target, state holds only the keys the app may read, without reserved keys.

Change state​

Send only the keys to change, under state:

{
"state": {
"slide": 4,
"overlay": { "color": "red" },
"banner": null
}
}

The change applies per key:

  • null removes the key.
  • Any other value replaces the stored value whole. An object is not merged into the stored object: after this request overlay is { "color": "red" }, whatever other properties it had.
  • Keys not sent are left as they are.

The write runs with the target's row locked, so two apps changing different keys at the same time don't lose each other's changes.

Limits on one PATCH:

  • At most 50 keys.
  • At most 8,192 bytes of JSON for state, so the broadcast stays well under the socket message limit.
  • Keys must match ^[A-Za-z_][A-Za-z0-9_]*$: letters, digits and underscores, not starting with a digit. A dot would make a nested path, so it is refused.

Reserved keys​

Some keys can't be written through this API whatever the app's allowlist says. A request that includes one gets 422 listing them (These keys are reserved: ...).

  • Keys starting with gxp_, on every target.
  • On quiz forms, the live quiz keys: live_mode, live_bank_id, live_question_ids, live_updated_at, mode, questions, question_windows, closed_question_windows, active_section_id, ignore_keys, initiated_by, admin_analytics, updated_by, updated_at, and every key starting with session_, review_ or leaderboard_.

Reads of another target leave reserved keys out. Live quiz state is changed only through the live quiz management endpoints. Other keys on a quiz form, such as a banner text, can be written here.

Permissions​

Trigger state abilities are for apps only. They are not admin role permissions, nobody grants them to admins, and API keys are not offered them.

AbilityOn dependency modelsAllows
update_own_trigger_stateProjectPage, ProjectFormWriting the app's own state
view_trigger_stateProjectPage, ProjectForm, ProjectPortalWidgetReading a bound target
update_trigger_stateProjectPage, ProjectForm, ProjectPortalWidgetWriting a bound target

update_trigger_state does not imply view_trigger_state. Grant both when the app reads what it writes.

The app's own state​

The app can always read its own state. To write it, the app needs a dependency on its own model with update_own_trigger_state: ProjectPage for an app on a page, ProjectForm for an app rendered on a form. That dependency does not need a binding. The keys it may write are the dependency's triggerStateKeys, or, when the dependency has none, the keys of the manifest's triggerState defaults.

{
"triggerState": { "slide": 1, "show_overlay": false },
"dependencies": [
{
"model": "ProjectPage",
"identifier": "own_page",
"permissions": ["update_own_trigger_state"]
}
]
}

This app may write slide and show_overlay on its own page.

Other pages, forms and widgets​

To reach another target, the app needs a dependency on the target's model that binds it, with view_trigger_state and/or update_trigger_state. The app may touch only the keys in that dependency's triggerStateKeys; "*" means every key except reserved ones. When several dependencies reach the same target, their keys are combined.

{
"model": "ProjectPortalWidget",
"identifier": "jukebox_widget",
"permissions": ["view_trigger_state", "update_trigger_state"],
"triggerStateKeys": ["now_playing", "queue"]
}
  • Binding. The installed page's dependency list binds the target by ID, slug, tag or *, as for other dependencies. A portal widget on the same portal as the app page counts as bound without a binding; the app still needs the ProjectPortalWidget dependency and its abilities. A widget on another portal of the project must be bound.
  • Typed bindings. The dashboard's picker for pages and portal widgets stores values such as App\Models\ProjectPortalWidget:12. A value of the form App\Models\<model>:<id> binds that ID for a dependency on the same model.
  • Unreachable targets — unbound, in another project, or not found — get 404, so an app can't probe which IDs exist.
  • Missing ability gets 403. Keys outside the allowlist get 422 (This app may not change: ...); a GET just leaves them out.

triggerStateKeys is stored with invalid names and gxp_ keys removed.

Narrowing keys per install​

In the installed page's permission rules, an admin can switch off keys the app declares in triggerStateKeys, per dependency, and can drop the abilities themselves. A rule can only narrow: it never adds keys the app did not declare. A dependency declared with "*" has no keys listed there to switch off; dropping the ability is the only per-install control for it.

Portal widgets as shared state​

Apps on a portal can share state through a portal widget's trigger_state: one app writes it with update_trigger_state, and others read it.

When an app page renders, the platform puts the state of each portal widget the app binds into the page as widgetStates, keyed by dependency identifier and limited to the keys the app may read:

{
"jukebox_widget": { "id": 12, "state": { "now_playing": "Heroes" } }
}

Read it with the store or the strings directive:

const nowPlaying = store.getWidgetState("jukebox_widget", "now_playing", "")
<span gxp-string="now_playing" gxp-state="jukebox_widget">Nothing playing</span>

A bare gxp-state still reads the page's own triggerState; gxp-state="<identifier>" reads that bound widget's state.

widgetStates includes each widget the dependency list binds, by its ID or by the dashboard picker's typed value (App\Models\ProjectPortalWidget:12). Widgets reached only because they are on the app's own portal have no identifier and are not included. Read those with GET .../trigger-state/widget:{id}.

Realtime events​

Each successful write broadcasts on the target's usual state channel. The payload carries the keys that changed: new or different values, and null for removed keys.

TargetChannelEventPayload
Pageportal.pages.{pageId}ProjectPageStateChangedproject_page_id, changes, updated_at
Formportal.forms.{formId}, and portal.pages.{formId} during the transitionProjectPageStateChangedproject_page_id (the form's ID), changes, updated_at
Quiz formAlso portal.forms.{formId}.livetrigger_state.changedFull state; see Realtime channels
Portal widgetportal.widgets.{widgetId}ProjectPortalWidgetStateChangedproject_portal_widget_id, changes, updated_at

A form's ProjectPageStateChanged is the diff as attendees may see it: the keys hidden from attendees (the form's ignore_keys, or the live quiz defaults on a quiz without its own list) are removed first, and nothing is broadcast when only those keys changed. Form IDs and page IDs can be equal, so forms have their own portal.forms.{formId} channel; the old portal.pages.{formId} copy remains only during the transition.

The store does not keep state live by itself. To have changes merged into the store, listen for them:

import { onUnmounted } from "vue"

// The app's own page or form: merges event.changes into store.triggerState.
const stopOwn = store.sockets.primary.listenForStateChange((event) => {
console.log("own state changed", Object.keys(event.changes))
})

// A bound widget: merges event.changes into getWidgetState("jukebox_widget", ...).
const stopWidget = store.sockets.widgets.listenForStateChange("jukebox_widget", (event) => {
console.log("widget state changed", Object.keys(event.changes))
})

onUnmounted(() => {
stopOwn()
stopWidget()
})

Both merge the event's changes before calling your callback, and return a cleanup function. A removed key becomes null in the store rather than disappearing. The widget helper subscribes only to widgets listed in widgetStates; for any other identifier it does nothing and returns a no-op cleanup. Its channel accepts the app only when it may read every key of that widget (triggerStateKeys: ["*"]); see Who may listen. Form-backed pages listen on portal.forms.{formId}, other pages on portal.pages.{pageId}.

Page and widget state broadcasts carry every key that changed, not only the keys a given app may read. That's why an app may listen to another page's or widget's channel only when it may read every key. An app limited to some keys reads them with GET .../trigger-state/{target} instead, and can poll for changes.

The store has no helper for another page's or form's state channel. An app that needs one can subscribe through the page's existing Echo connection, window.Echo, after the store has initialized its sockets (the store has already set the page key for channel authorization), and must remove its own listener:

const boardChannel = window.Echo.private(`portal.pages.${boardPageId}`)
const onBoardChange = (event) => {
// event.changes holds every changed key; merge into your own copy.
}
boardChannel.listen(".ProjectPageStateChanged", onBoardChange)

onUnmounted(() => boardChannel.stopListening(".ProjectPageStateChanged", onBoardChange))

Nothing merges these changes into the store for you. For a quiz's live channels, use the store's live quiz helper instead.

Who may listen​

For app pages, channel access follows the same reach as the API:

ChannelAn app page may listen when
portal.pages.{pageId}It is the app's own page, or a project page the app reaches with view_trigger_state on every key ("*"). A form-backed page may also join its form's legacy channel, unless a page with that ID exists in another project
portal.widgets.{widgetId}The widget is in the project and the app reaches it with view_trigger_state on every key ("*")
portal.forms.{formId}It is the app's own form, a form bound in the app's dependency list, or a form the app may read through the forms API

An app limited to some keys can't join another page's or widget's channel, because the broadcasts aren't filtered by key; it reads those keys through the API. The page/widget wildcard check and the forms-API permission fallback compile the app permission plan after checking its group gate. The current form-channel authorizer returns early for an own or explicitly bound form, before that gate; do not infer a per-subscriber group check from a successful form-channel subscription. Controller channels (.live and .live.analytics) separately check the group gate and their live-quiz abilities. Subscribers that are not app pages, such as attendee sessions, keep the project-wide check: the page, widget or form must be in a project they belong to.

Rate limit​

PATCH requests are limited per app page key, so apps behind one venue address don't throttle each other. The default is 120 writes a minute (RATE_LIMIT_PORTAL_TRIGGER_STATE_PER_MINUTE); over the limit the API returns 429. GET requests are not counted. Batch related keys into one PATCH rather than sending one per key.

Errors​

StatusCause
401No valid page key
403The app lacks the ability for this target and method, or an admin dropped it from the install
404No app page context, an unknown target format, or a target that is unbound, in another project or missing
422state missing, not an object, empty or over 50 keys; invalid key names; over 8,192 bytes; reserved keys; keys outside the allowlist
429Over the write rate limit

422 responses use the framework's validation shape, with the message under errors.state.

Local development​

Toolkit 2.1.47 provides getWidgetState, sockets.widgets and an in-memory Trigger State API mock under API_ENV=mock. Seed widget state with the manifest fixture and start the local mock relay. Direct store edits affect that browser; mock API state lasts only for the running mock process. The mock does not enforce installed-page bindings, permissions, quiz-specific reserved keys or private-channel isolation. It checks key syntax and the gxp_ prefix, but does not reproduce the full production validation and rate limits. See store preview helpers; validate those boundaries against the installed platform separately.