Functional extensions to JSONata

You can use the following functional extensions to standard JSONata notation. Each extension corresponds to a part of the API context.

For more information, see API context variables.

$apiCtx()

Signature
$apiCtx()
Variable
Generic access to an API context
Description
The $apiCtx() extension gives generic access to an API context.
  • Sample transform field in an extract action.
    "$apiCtx().request.uri"
  • Sample condition of a case in a switch action.
    "$apiCtx().request.path = '/simple/apictx-function'"

$header()

Signature
$header(name)
Variable
message.headers.name
Description
Message header.

$httpVerb()

Signature
$httpVerb()
Variable
request.verb
Description
HTTP method of the request.

$operationID()

Signature
$operationID()
Variable
api.operation.id
Description
ID of the operation.

$operationPath()

Signature
$operationPath()
Variable
api.operation.path
Description
Path of the operation.

$queryParameter()

Signature
$queryParameter('name')
Variable
  • request.parameters.name.locations

    The supported keyword is query.

  • request.parameters.name.values
Description
Searches for the index of query in request.parameters.name.locations and returns request.parameters.name.values[index], where [index] is the value for query in locations. Parameter values are not URL decoded.

$statusCode()

Signature
$statusCode()
Variable
message.status.code
Description
Status code.

$storageType()

Signature
$storageType([arg])
Variable
variable.body

You can specify any variable in the API context. When no variable is specified, the default variable message.body is used.

Description
Storage type of the message. The supported values are binary, empty, graphql, json, stream, or xml.

$urlParameter()

Signature
$urlParameter('name')
Variable
  • request.parameters.name.locations

    The supported keywords are path and query.

  • request.parameters.name.values
Description
Searches for the index of path and query in request.parameters.name.locations and returns a single array that contains both path and query values from request.parameters.name.values. When the URL contains both path and query parameter values, the array includes the path values first followed by the query values. The values of each parameter type are added in the order that they are received. Parameter values are URL decoded.
For example, the following URL contains both path and query parameter values.
http://example.com/petstore/cats/adopt?breed=Sphynx&breed=Siamese
The $urlParameter('breed') URL returns the following array of values.
[cats, adopt, Sphynx, Siamese]

In this example, the URL includes an API path that is configured as /petstore/{breed}/{breed}, where breed is configured to be a path parameter of the API path. As a result, cats and adopt are included in the output.

$xpath()

Signature
$xpath(path, xpathExpression)
Variable
You can specify any writable variable in the API context. The xpathExpression must be a literal string.
Description
Allows use of XPath expressions. The following example specifies all price elements in the source.
$xpath($, '//price')