(Internal) Generate Expression JSON Endpoint

Converts a rule expression into an expressionJson format.

This endpoint generates a JSON representation (expressionJson) for a given logical rule expression (exp) provided in the request payload. This is used internally within Capillary to understand the rule logic used by the loyalty UI while creating the expression. For more information on rule expressions, refer to the rule writing documentation.

API endpoint example

https://eu.api.capillarytech.com/loyalty/api/v1/workflows/expJSON/{ProgramId}/{eventType}

Prerequisite

  • Authentication - Staging authentication

Resource information

URL/loyalty/api/v1/workflows/expJSON/{ProgramId}/{eventType}
HTTP methodPOST
Pagination supported?NA
Rate limitNA
Batch supportNA

Headers

Header
(* denotes mandatory fields)
Description
cookie*Authentication and session information. CT (token for user authentication) and OID (org ID) are mandatory.
x-cap-remote-userIdentifier for the remote user making the request. Useful for tracking which user or entity initiated a request.

📘

Note:

CT token can be taken from Cookies under Application Tab of DevTools once logged in to Intouch.

Path parameters

ParameterData TypeDescription
ProgramIdIntegerUnique identifier for the loyalty program.
eventTypeStringSpecifies the type of event for which the rule applies, Example: TargetCompleted.

Body parameters

ParameterData TypeDescription
expStringLogical rule expression to be tested or converted into JSON format.

Sample request

'{
    "exp":"currentEvent.targetName==\"Gatekeeper T&C Accepted\""
}'
'{
    "exp":"currentEven.target DSCCDCCDVDVBIAAMWEG BUNWG BKRG DVHGRDVBRGWDVBE FVILName==looooo"
}'

Response parameters

ParameterDescription
successIndicates whether the operation was successful, Example: true.
statusHTTP status code of the response, Example: 200.
resultArray containing the parsed expressionJson, the input expression, and error info.
-expressionJSONParsed or converted expressionJson.
-expressionOriginal expression passed in the request, Example: Gatekeeper T&C Accepted.
-isErrorIndicates if there was an error in processing the expression, isError=false indicates success, while isError=true indicates failure.

{
    "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
    }
}
{
    "success": true,
    "status": 200,
    "result": {
        "expressionJSON": "\n{\n  \"arity\":\"group\",\n  \"operands\":[\n    {\n      \"arity\":\"object_dereference\",\n      \"operands\":[\n        {\n          \"arity\":\"name\",\n          \"value\":\"currentEven\"\n        },\n        {\n          \"arity\":\"name\",\n          \"value\":\"target\"\n        }\n      ]\n    },\n    {\n      \"arity\":\"name\",\n      \"value\":\"DSCCDCCDVDVBIAAMWEG\"\n    },\n    {\n      \"arity\":\"name\",\n      \"value\":\"BUNWG\"\n    },\n    {\n      \"arity\":\"name\",\n      \"value\":\"BKRG\"\n    },\n    {\n      \"arity\":\"name\",\n      \"value\":\"DVHGRDVBRGWDVBE\"\n    },\n    {\n      \"arity\":\"binary_operation\",\n      \"value\":\"==\",\n      \"operands\":[\n        {\n          \"arity\":\"name\",\n          \"value\":\"FVILName\"\n        },\n        {\n          \"arity\":\"name\",\n          \"value\":\"looooo\"\n        }\n      ]\n    }\n  ]\n}",
        "expression": "currentEven.target DSCCDCCDVDVBIAAMWEG BUNWG BKRG DVHGRDVBRGWDVBE FVILName==looooo",
        "isError": true
    }
}
Language
Credentials
Basic
base64
:
URL
Click Try It! to start a request and see the response here!