Variables AI-generated

Every script field in MockMotor - match scripts, payload scripts, header scripts, account selectors, delay expressions, account-update scripts - sees the same set of variable namespaces, in either JavaScript (input.foo) or XQuery ($input//*:foo) form depending on which language the field is written in. A Simplified shorthand (see below) also lets you drop the namespace prefix entirely in most of these fields.

Namespaces

NamespaceJS formXQuery formWhat's in it
input / requestinput.header.account.id$input//*:AccountId/text()The parsed request payload (JSON or XML). request is a plain alias for input.
httphttp.headers['X-TxId'], http.parameters.id$http//*:header[@name='X-TxId']method, relativeURI, queryString (raw, not URL-decoded), parameters (parsed/decoded; a repeated parameter becomes multiple values), headers.
restrest.method, rest.parameters.userId$rest//*:parameter[@name='userId']/text()The HTTP method and the relative-URI's own {param} placeholders (see below) - a narrower, path-focused counterpart to http.
account / accountsaccount.level, accounts[0].id$account/*:level/text()The mock account(s) selected by the reaction's Account Selection script - see Mock Accounts. account/$account is one match (chosen arbitrarily if several matched - account/$account is null/empty-sequence if none did); accounts/$accounts is the full set. A property with multiple values becomes a JS array / repeated XML elements.
mockmetamockmeta.random, mockmeta.reaction.calls$mockmeta/*:random/text()random (0-1), randomUUID, epochMs (milliseconds since epoch), and .calls under environment/service/reaction (running call counts for each).
output / responseoutput.status$output//*:statusThe response computed so far. Not available in match scripts or the account selector (the response doesn't exist yet at that point) - only in delay expressions, custom headers, and account-update scripts, which run after the payload.
JWT / JSONJWT.verify(...)-Built-in helper modules - see CORS & Auth Basics and Script Library. JavaScript-only; not available to XQuery fields.

Relative URI path parameters

A reaction's Relative URI match field can contain named placeholders: /user/{userId}/statement/{statementId} binds userId/statementId as top-level variables (and under rest). A catch-all form, /acc/{alltherest:.*}, captures everything after the prefix into one variable.

Simplified Variables

In any field that supports scripting (matching, account selection, payload, status, delay), you don't have to spell out the full account/rest/http path - the property name alone resolves automatically:

Variable typeFull formSimplified
HTTP parameter (JS)http.parameters.userIduserId
REST path parameter (JS)rest.parameters.modemode
Account property (JS)account.streetNumberstreetNumber
HTTP parameter (XQuery)$http//*:parameter[@name='userId']/text()$userId
REST path parameter (XQuery)$rest//*:parameter[@name='mode']/text()$mode
Account property (XQuery)$account/*:streetNumber/text()$streetNumber

For example, a payload script can write "userId": userId instead of "userId": account.userId, or {$streetNumber} instead of {$account/streetNumber/text()}.

If a name exists in more than one namespace, the priority is REST parameters > HTTP parameters > account properties. mockmeta, input/request, and output/response are never simplified - always spell those out.

Quick reference

What to checkJavaScriptXQuery
Property exists in the payloadinput.user.birthDate$input//*:birthDate
Property matches a valueinput.user.id=='120000'$input//*:id='120000'
Property via JSONPath (request only)$..id-
Header matches a valuehttp.headers['X-TxId']=='8'$input//*:header[@name='X-TxId']/text()='8'
Mock account propertyaccount.level=='BASIC'$account//*:level/text()='BASIC'
HTTP query parameterhttp.parameters.id=='0'$http//*:parameter[@name='id']/text()='0'
HTTP method (either of two)rest.method=='GET' || rest.method=='XGET'$rest//*:method/text()=('GET','XGET')
Random / intermittent responsemockmeta.random < 0.1$mockmeta/random < 0.1