Execute using REST API

◷ Reading Time: 4 minutes


In order to execute a Logic Document as a REST API call, you will need to install FlexRule Server first.

Once FlexRule Server is ready follow the following steps:

  1. Deploy a project using the Package Builder.
  2. Authenticate your command by getting an authentication token.
  3. Execute the service by creating a request object and sending it to your Service URL.
  4. Retrieve the response and handle the result from the command.

Execution can be done in either sync or async manners.

Once a package is deployed in FlexRule Server, it can be called from any application via a REST API methods (GET and POST).

Service URL

http://{your server address}/api/services/execute/{package name}/{package version}/{service name}

The URL is based on the following sections:

  • {package name}: This is the identifier of the package that is stored on the server
  • {package version}: The version string (e.g., number, string, etc.) that is stored for a package
  • {service name}: Name of the decision inside a package

For example:

http://localhost:9000/api/services/execute/agepackage/1/person growing state

Request Structure

Request {
    EnableFullLog (bool), 
[Server version 9.2 ==> fullLog (bool) and also 
"fullLog": "server" --> so the log is written to the Server and receive only a URL to the log in the response object]
    CorrelationId (string), 
    Actor (string),
    // Input parameters of the model (or the service)
    Inputs (array):[
             Name (string),
             Value (object)
         }, ...

    // Service selection strategy options
    UseEarliestVersion (bool),
    UseLatestVersion (bool),
    ServiceKey (string),
    ServiceVersion (string),

    // Workflow and long running behaviour
    Workflow: {
      WorkflowInstanceId (string),
      QueryTasks (bool),
      ResumeInfo: {
           Title (string),
           Category (string),
           Outcome (string)


A service can have several versions with different behaviors.

You can choose which version to execute by using the following options:

  • UseEarliestVersion: Always ensures the first version of the service will be selected.
  • UseLatestVersion: Ensures the last version of the service is chosen for execution.
  • ServiceKey: When specified, the service version associated with the service’s key will be chosen for execution.
  • ServiceVersion: The specified version of the service will be chosen for execution.


When executing a long running workflow the request object can be extended as below:

  • WorkflowInstanceId: the instance id that is associated to a workflow.
  • QueryTasks: indicates that the request is to only query a workflow based on its context or for execution.
  • ResumeInfo: contextual information about the request to be resumed.
    • Title
    • Category
    • Outcome

Asynchronous Method

FlexRule Server 3.0+ supports long-running asynchronous execution of a task. Follow the steps below:

  1. Authenticate your command and get an authorization token.
  2. Call the service endpoint with ?async=true in the Url.
  3. When the call is async, the server will return code 202 (Accepted), which means the task is created to process the client request.
  4. Follow the location service provided in order to retrieve the result once it is ready.
    If the result is not yet ready, the service will return 503 (Service Unavailable) code or 500 (Internal Server Error) code.
    If the result is ready, you will be able to retrieve the result.

Response Structure

Response {
    InvocationId (string),
    CorrelationId (string), 
    errorCode (string),
    messageId (string),
    isError (bool),

         Output (array): [{
             Name (string),
             Value (object)
         Notification (array),
         Elapsed (timespan), 

    ExtraOutput (array):[],
    WorkflowInstanceId (string),
    Exception (string),
    Agent (guid),
Updated on February 20, 2024

Was this article helpful?

Related Articles