Skip to main content

Evaluation API

Evaluation API is used to connect directly to managed ZEN Engine over REST API.

Procedure

info

Make sure your decision is published before proceeding.

  1. Grab the evaluation URL by right-clicking on the document and pressing Copy URL
  2. Generate a project security token
    1. Navigate to Project -> Settings -> Security
    2. Press Generate token
    3. Fill out the form and confirm
    4. Copy the access token
  3. Execute decision by sending POST request with security token and payload to endpoint of the decision.

Examples

You can use one of the following code snippets to run the rule engine using API in your application.

// TODO: Define EvaluationResponse interface
const evaluate = async (): EvaluationResponse => {
const response = await fetch('<Your URL>', {
method: 'POST',
headers: {
'X-Access-Token': '<Your Access Token>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
context: {
customer: { country: 'US' },
cart: { totals: 100 },
product: { weight: 15 },
},
}),
});

const { data } = await response.json();
return data as EvaluationResponse;
};