Generate Expression JSON

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

Converts a workflow rule expression (in plain text) into the structured expressionJSON format required by the loyalty promotions API. This endpoint validates and translates rule expressions written in the loyalty engine's expression language.

What this API supports

  • Parsing a rule expression string into a structured expressionJSON tree
  • Accepting any event type recognised by the loyalty engine (for example, TargetCompleted)

Example request

curl -L 'https://{host}/loyalty/api/v1/workflows/expJSON/{programId}/{eventType}' \
  -H 'content-type: application/json' \
  -H 'cookie: CT={ct-token}; OID={org-id}' \
  -d '{
    "exp": "currentTxn.value==1000"
  }'

Prerequisites

  • Cookie-based authentication — this endpoint requires a valid session cookie obtained from the Capillary UI. See Getting a session cookie below. Standard API key or Basic authentication is not supported.

Getting a session cookie

This is an internal API and requires a session cookie that you can obtain using the InTouch UI and the browser network tab. To get a session cookie do the following:

  1. Login to the InTouch UI and navigate to the required organisation.

  2. Open the browser developer tools (usually F12) and navigate to the network tab.

  3. Select Reload Page to refresh the page and begin recording network activities.

  4. Filter the logs by Fetch/XHR and select a successful network fetch.

  5. Navigate to the Cookies tab and copy the values for CT

  6. Paste these as the value for cookie under the API header in the following format CT={cookieValue};OID={OIDValue}.

API Quick Reference

POST /loyalty/api/v1/workflows/expJSON/{programId}/{eventType}

Request
  └─ exp (string)

Response
  ├─ success (boolean)
  ├─ status (number)
  └─ result
      ├─ expressionJSON (string)
      ├─ expression (string)
      └─ isError (boolean)

Path parameters

ParameterTypeRequiredDescription
programIdIntegerYesUnique identifier of the loyalty programme.
eventTypeStringYesEvent type the rule applies to. Supported standard values: TransactionAdd, TransactionUpdate, CustomerRegistration, CustomerUpdate, NewBill, PointsContributionToGroup, PointsTransfer, ReturnBill, TargetCompleted, PointsRedemption, VoucherRedemption, PartnerProgramDeLinking, PartnerProgramLinking, PartnerProgramTierUpdate. Also accepts the name of any valid behavioural event configured for the organisation.

Body parameters

ParameterTypeRequiredDescription
expStringYesThe rule expression to convert, written in the loyalty expression language. For example, currentTxn.value==1000.

Example response

{
    "success": true,
    "status": 200,
    "result": {
        "expressionJSON": "\n{\n  \"arity\":\"binary_operation\",\n  \"value\":\"==\",\n  \"type\":\"boolean:primitive\",\n  \"operands\":[\n    {\n      \"arity\":\"object_dereference\",\n      \"operands\":[\n        {\n          \"arity\":\"name\",\n          \"value\":\"currentTxn\"\n        },\n        {\n          \"arity\":\"name\",\n          \"value\":\"value\"\n        }\n      ]\n    },\n    {\n      \"arity\":\"literal\",\n      \"value\":\"1000\",\n      \"type\":\"number:primitive\"\n    }\n  ]\n}",
        "expression": "currentTxn.value==1000",
        "isError": true
    }
}
{
    "success": true,
    "status": 200,
    "result": {
        "expressionJSON": "\n{\n  \"arity\":\"binary_operation\",\n  \"value\":\"==\",\n  \"type\":\"boolean:primitive\",\n  \"operands\":[\n    {\n      \"arity\":\"object_dereference\",\n      \"type\":\"string:object:primitive\",\n      \"operands\":[\n        {\n          \"arity\":\"name\",\n          \"value\":\"currentEvent\",\n          \"type\":\"customer.targetCompletedEvent:object:primitive\"\n        },\n        {\n          \"arity\":\"name\",\n          \"value\":\"targetName\",\n          \"type\":\"string:object:primitive\"\n        }\n      ]\n    },\n    {\n      \"arity\":\"literal\",\n      \"value\":\"Gatekeeper T&C Accepted\",\n      \"type\":\"string:object:primitive\"\n    }\n  ]\n}",
        "expression": "currentEvent.targetName==\"Gatekeeper T&C Accepted\"",
        "isError": false
    }
}

Response parameters

FieldTypeDescription
successBooleantrue if the request was received and processed.
statusIntegerHTTP status code of the response.
resultObjectContains the output of the expression parse.
.expressionJSONStringJSON-encoded string of the parsed expression tree. Returned regardless of whether isError is true or false.
.expressionStringThe original expression string submitted in the request.
.isErrorBooleantrue if the parser detected an error in the expression (for example, an unrecognised variable or wrong context object for the event type). false if the expression parsed cleanly.

Error and warning codes

CodeTypeDescription
401ErrorMissing or invalid session cookie. Obtain a fresh cookie from the UI.
500ErrorInternal server error. Retry the request after a short delay.
Path Params
string
required
string
required
Body Params
string
required
Responses

401

Missing or invalid session cookie.

Language
Credentials
Basic
base64
:
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json